From 3a0eed23795fc1029d38da8c3cb2de2d1fbfb330 Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Fri, 17 May 2019 14:16:48 +0100 Subject: [PATCH] Add tests for optional screenshot Fd in bugreport API Not all bugreports need screenshots, and hence it should not be mandatory to pass screenshotfd in parameters to startBugreport (call to bugreport API). Ensuring the above by passing null screenshotFd. Bug: 123578274 Test: atest BugreportManagerTest Change-Id: I79f4a71cc79e655a64c4cf9ac04fef0814db8ff1 --- .../server/bugreports/BugreportManagerTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java b/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java index 220f854c337a7..c72707db9560d 100644 --- a/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java +++ b/core/tests/bugreports/src/android/server/bugreports/BugreportManagerTest.java @@ -88,7 +88,9 @@ public class BugreportManagerTest { @Test public void normalFlow_wifi() throws Exception { BugreportCallbackImpl callback = new BugreportCallbackImpl(); - mBrm.startBugreport(mBugreportFd, mScreenshotFd, wifi(), mExecutor, callback); + // wifi bugreport does not take screenshot + mBrm.startBugreport(mBugreportFd, null /*screenshotFd = null*/, wifi(), + mExecutor, callback); waitTillDoneOrTimeout(callback); assertThat(callback.isDone()).isTrue(); @@ -99,13 +101,15 @@ public class BugreportManagerTest { // of mBugreportFd. assertThat(callback.getErrorCode()).isEqualTo( BugreportCallback.BUGREPORT_ERROR_USER_CONSENT_TIMED_OUT); - assertFdsAreClosed(mBugreportFd, mScreenshotFd); + assertFdsAreClosed(mBugreportFd); } @Test public void normalFlow_interactive() throws Exception { BugreportCallbackImpl callback = new BugreportCallbackImpl(); - mBrm.startBugreport(mBugreportFd, mScreenshotFd, interactive(), mExecutor, callback); + // interactive bugreport does not take screenshot + mBrm.startBugreport(mBugreportFd, null /*screenshotFd = null*/, interactive(), + mExecutor, callback); waitTillDoneOrTimeout(callback); assertThat(callback.isDone()).isTrue(); @@ -113,7 +117,7 @@ public class BugreportManagerTest { assertThat(callback.hasReceivedProgress()).isTrue(); assertThat(callback.getErrorCode()).isEqualTo( BugreportCallback.BUGREPORT_ERROR_USER_CONSENT_TIMED_OUT); - assertFdsAreClosed(mBugreportFd, mScreenshotFd); + assertFdsAreClosed(mBugreportFd); } @Test