diff options
author | Rhed Jao <rhedjao@google.com> | 2020-12-07 17:58:26 +0800 |
---|---|---|
committer | Rhed Jao <rhedjao@google.com> | 2020-12-21 04:19:52 +0000 |
commit | 39b6acbb55b037ba6dbeb092eb93caddd277a2cd (patch) | |
tree | c7cbb811c89ad9b85a169e389e6e74ee6fa8a68b /packages/Shell/tests | |
parent | e9a2038f8a2f2ece8de044e3ace57ac285391db7 (diff) |
Fixes an error handling in BugreportProgressService
Calls onError function when bugreport is finished and file is empty.
Bug: 174314124
Bug: 175287931
Test: atest BugreportReceiverTest
Change-Id: I4542568fd2d2ad1c75c7c3b223accca4995938a3
Merged-In: I4542568fd2d2ad1c75c7c3b223accca4995938a3
Diffstat (limited to 'packages/Shell/tests')
-rw-r--r-- | packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java index 43147cdfc86d..89cdeaea199c 100644 --- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java @@ -513,6 +513,17 @@ public class BugreportReceiverTest { } @Test + public void testBugreportFinished_withEmptyBugreportFile() throws Exception { + sendBugreportStarted(); + + IoUtils.closeQuietly(mBugreportFd); + mBugreportFd = null; + sendBugreportFinished(); + + assertServiceNotRunning(); + } + + @Test public void testShareBugreportAfterServiceDies() throws Exception { sendBugreportStarted(); waitForScreenshotButtonEnabled(true); @@ -647,7 +658,9 @@ public class BugreportReceiverTest { * Callbacks to service to finish the bugreport. */ private void sendBugreportFinished() throws Exception { - writeZipFile(mBugreportFd, BUGREPORT_FILE, BUGREPORT_CONTENT); + if (mBugreportFd != null) { + writeZipFile(mBugreportFd, BUGREPORT_FILE, BUGREPORT_CONTENT); + } if (mScreenshotFd != null) { writeScreenshotFile(mScreenshotFd, SCREENSHOT_CONTENT); } |