From 9ca5e5639048375100acd98a40ad82d8b699c575 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Mon, 11 Apr 2016 10:27:02 -0700 Subject: [PATCH] "Temporarily" removed progress check. The code that asserts the right progress is displayed was based on the percentage text displayed in the system notification, but such text is gone. Since UIObject doesn't easily expose the underlying ProgressBar, such checks were temporarily disabled. BUG: 28114251 Change-Id: Idb64fe97cf84f5f73e08e293b8fd0384bc8b70d6 --- .../android/shell/BugreportReceiverTest.java | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java index e1e0c3b448b75..3b5305527ba5e 100644 --- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java +++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java @@ -179,42 +179,37 @@ public class BugreportReceiverTest extends InstrumentationTestCase { sendBugreportStarted(1000); waitForScreenshotButtonEnabled(true); - final NumberFormat nf = NumberFormat.getPercentInstance(); - nf.setMinimumFractionDigits(2); - nf.setMaximumFractionDigits(2); - - assertProgressNotification(NAME, nf.format(0)); + assertProgressNotification(NAME, 0f); SystemProperties.set(PROGRESS_PROPERTY, "108"); - assertProgressNotification(NAME, nf.format(0.108)); + assertProgressNotification(NAME, 10.80f); - SystemProperties.set(PROGRESS_PROPERTY, "500"); - assertProgressNotification(NAME, nf.format(0.50)); + assertProgressNotification(NAME, 50.00f); SystemProperties.set(PROGRESS_PROPERTY, "950"); - assertProgressNotification(NAME, nf.format(0.95)); + assertProgressNotification(NAME, 95.00f); // Make sure progress never goes back... SystemProperties.set(MAX_PROPERTY, "2000"); Thread.sleep(POLLING_FREQUENCY + DateUtils.SECOND_IN_MILLIS); - assertProgressNotification(NAME, nf.format(0.95)); + assertProgressNotification(NAME, 95.00f); SystemProperties.set(PROGRESS_PROPERTY, "1000"); - assertProgressNotification(NAME, nf.format(0.95)); + assertProgressNotification(NAME, 95.00f); // ...only forward... SystemProperties.set(PROGRESS_PROPERTY, "1902"); - assertProgressNotification(NAME, nf.format(0.9510)); + assertProgressNotification(NAME, 95.10f); SystemProperties.set(PROGRESS_PROPERTY, "1960"); - assertProgressNotification(NAME, nf.format(0.98)); + assertProgressNotification(NAME, 98.00f); // ...but never more than the capped value. SystemProperties.set(PROGRESS_PROPERTY, "2000"); - assertProgressNotification(NAME, nf.format(0.99)); + assertProgressNotification(NAME, 99.00f); SystemProperties.set(PROGRESS_PROPERTY, "3000"); - assertProgressNotification(NAME, nf.format(0.99)); + assertProgressNotification(NAME, 99.00f); Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID, mPlainTextPath, mScreenshotPath); @@ -233,7 +228,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2); - assertProgressNotification(NAME, nf.format(0)); + assertProgressNotification(NAME, 00.00f); openProgressNotification(ID); UiObject cancelButton = mUiBot.getVisibleObject(mContext.getString( @@ -338,7 +333,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.clickOk(); assertPropertyValue(NAME_PROPERTY, NEW_NAME); - assertProgressNotification(NEW_NAME, "0.00%"); + assertProgressNotification(NEW_NAME, 00.00f); Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID, mPlainTextPath, mScreenshotPath); @@ -375,7 +370,7 @@ public class BugreportReceiverTest extends InstrumentationTestCase { detailsUi.clickOk(); assertPropertyValue(NAME_PROPERTY, NEW_NAME); - assertProgressNotification(NEW_NAME, "0.00%"); + assertProgressNotification(NEW_NAME, 00.00f); Bundle extras = sendBugreportFinishedAndGetSharedIntent(ID, plainText? mPlainTextPath : mZipPath, mScreenshotPath); @@ -571,13 +566,13 @@ public class BugreportReceiverTest extends InstrumentationTestCase { } } - private void assertProgressNotification(String name, String percent) { + private void assertProgressNotification(String name, float percent) { // TODO: it currently looks for 3 distinct objects, without taking advantage of their // relationship. openProgressNotification(ID); Log.v(TAG, "Looking for progress notification details: '" + name + "-" + percent + "'"); mUiBot.getObject(name); - mUiBot.getObject(percent); + // TODO: need a way to get the ProgresBar from the "android:id/progress" UIObject... } private UiObject openProgressNotification(int id) {