diff options
author | Felipe Leme <felipeal@google.com> | 2016-03-21 17:34:21 -0700 |
---|---|---|
committer | Felipe Leme <felipeal@google.com> | 2016-03-22 10:05:30 -0700 |
commit | 3fc44b9a6274254e8d3a53b6b1e245c5f9177229 (patch) | |
tree | 0c75e8504428032280bacfd6b6de8eba1b0496bc /packages/Shell/tests | |
parent | 1981e602ad97e3a21bc987dbeb0625e87a58ff8d (diff) |
Changed logic when dumpstate's max progress increases.
When dumpstate starts, it estimates its maximum duration and sends it
through an extra on BUGREPORT_STARTED; as it progress, it sets a system
property with its current progress and if the progress value overflows
the estimated max, it increases the max as well.
Shell uses the max/progress to display the progress % in the
system notification, and need to handle the scenario where the max
changes. The initial implementation would recalculate the progress, with
makes it swing back and forth as dumpstate increases the max.
This CL changes the Shell logic so the progress never go back, just
forward. The drawback of this approach is that if dumpstate
underestimate the maximum, the progress might get stuck in a high
value (99%) early on, but such issue will be addressed in the long
term by tuning the estimated max value.
BUG: 26354314
Change-Id: I3a5416acaffaaa43fd28d2f1f8ec8ea12aa0d91e
Diffstat (limited to 'packages/Shell/tests')
-rw-r--r-- | packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java | 27 | ||||
-rw-r--r-- | packages/Shell/tests/src/com/android/shell/UiBot.java | 6 |
2 files changed, 28 insertions, 5 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java index 17f6f6b5ac89..e1e0c3b448b7 100644 --- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java @@ -26,6 +26,7 @@ import static com.android.shell.BugreportProgressService.EXTRA_PID; import static com.android.shell.BugreportProgressService.EXTRA_SCREENSHOT; import static com.android.shell.BugreportProgressService.INTENT_BUGREPORT_FINISHED; import static com.android.shell.BugreportProgressService.INTENT_BUGREPORT_STARTED; +import static com.android.shell.BugreportProgressService.POLLING_FREQUENCY; import static com.android.shell.BugreportProgressService.SCREENSHOT_DELAY_SECONDS; import java.io.BufferedOutputStream; @@ -92,7 +93,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { private static final String TAG = "BugreportReceiverTest"; // Timeout for UI operations, in milliseconds. - private static final int TIMEOUT = (int) BugreportProgressService.POLLING_FREQUENCY * 4; + private static final int TIMEOUT = (int) POLLING_FREQUENCY * 4; // Timeout for when waiting for a screenshot to finish. private static final int SAFE_SCREENSHOT_DELAY = SCREENSHOT_DELAY_SECONDS + 10; @@ -190,8 +191,30 @@ public class BugreportReceiverTest extends InstrumentationTestCase { SystemProperties.set(PROGRESS_PROPERTY, "500"); assertProgressNotification(NAME, nf.format(0.50)); + SystemProperties.set(PROGRESS_PROPERTY, "950"); + assertProgressNotification(NAME, nf.format(0.95)); + + // Make sure progress never goes back... SystemProperties.set(MAX_PROPERTY, "2000"); - assertProgressNotification(NAME, nf.format(0.25)); + Thread.sleep(POLLING_FREQUENCY + DateUtils.SECOND_IN_MILLIS); + assertProgressNotification(NAME, nf.format(0.95)); + + SystemProperties.set(PROGRESS_PROPERTY, "1000"); + assertProgressNotification(NAME, nf.format(0.95)); + + // ...only forward... + SystemProperties.set(PROGRESS_PROPERTY, "1902"); + assertProgressNotification(NAME, nf.format(0.9510)); + + SystemProperties.set(PROGRESS_PROPERTY, "1960"); + assertProgressNotification(NAME, nf.format(0.98)); + + // ...but never more than the capped value. + SystemProperties.set(PROGRESS_PROPERTY, "2000"); + assertProgressNotification(NAME, nf.format(0.99)); + + SystemProperties.set(PROGRESS_PROPERTY, "3000"); + assertProgressNotification(NAME, nf.format(0.99)); Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID, mPlainTextPath, mScreenshotPath); diff --git a/packages/Shell/tests/src/com/android/shell/UiBot.java b/packages/Shell/tests/src/com/android/shell/UiBot.java index 384c3daa51c9..5bfe1a084bc4 100644 --- a/packages/Shell/tests/src/com/android/shell/UiBot.java +++ b/packages/Shell/tests/src/com/android/shell/UiBot.java @@ -32,7 +32,7 @@ import static junit.framework.Assert.assertTrue; final class UiBot { private static final String TAG = "UiBot"; - private static final String SYSTEMUI_PACKAGED = "com.android.systemui"; + private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; private final UiDevice mDevice; private final int mTimeout; @@ -51,8 +51,8 @@ final class UiBot { public UiObject getNotification(String text) { boolean opened = mDevice.openNotification(); Log.v(TAG, "openNotification(): " + opened); - boolean gotIt = mDevice.wait(Until.hasObject(By.pkg(SYSTEMUI_PACKAGED)), mTimeout); - assertTrue("could not get system ui (" + SYSTEMUI_PACKAGED + ")", gotIt); + boolean gotIt = mDevice.wait(Until.hasObject(By.pkg(SYSTEMUI_PACKAGE)), mTimeout); + assertTrue("could not get system ui (" + SYSTEMUI_PACKAGE + ")", gotIt); return getObject(text); } |