summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/Shell/tests/src/com/android/shell/ActionSendMultipleConsumerActivity.java4
-rw-r--r--packages/Shell/tests/src/com/android/shell/UiBot.java37
2 files changed, 25 insertions, 16 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/ActionSendMultipleConsumerActivity.java b/packages/Shell/tests/src/com/android/shell/ActionSendMultipleConsumerActivity.java
index e3e99b0d5711..e34f5c85c0b8 100644
--- a/packages/Shell/tests/src/com/android/shell/ActionSendMultipleConsumerActivity.java
+++ b/packages/Shell/tests/src/com/android/shell/ActionSendMultipleConsumerActivity.java
@@ -113,7 +113,9 @@ public class ActionSendMultipleConsumerActivity extends Activity {
Bundle getExtras() {
Bundle bundle = null;
try {
- bundle = mQueue.poll(TIMEOUT, TimeUnit.SECONDS);
+ // UI operations can be slower the very first time the tests are run due
+ // because ActionSendMultipleConsumer is not the default activity chosen.
+ bundle = mQueue.poll(2 * TIMEOUT, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
diff --git a/packages/Shell/tests/src/com/android/shell/UiBot.java b/packages/Shell/tests/src/com/android/shell/UiBot.java
index 5bfe1a084bc4..30f16928ba52 100644
--- a/packages/Shell/tests/src/com/android/shell/UiBot.java
+++ b/packages/Shell/tests/src/com/android/shell/UiBot.java
@@ -144,37 +144,44 @@ final class UiBot {
String shareText = "Share with " + name;
Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'");
boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout);
+ boolean justOnceHack = false;
if (gotIt) {
Log.v(TAG, "Found activity " + name + ", it's the default action");
- // Clicks the "Just Once" button.
- gotIt = mDevice
- .wait(Until.hasObject(By.res("android", "button_once")), mTimeout);
- assertTrue("'Just Once' button not visible yet", gotIt);
-
- UiObject justOnce = mDevice
- .findObject(new UiSelector().resourceId("android:id/button_once"));
- assertTrue("'Just Once' button not found", justOnce.exists());
-
- click(justOnce, "Just Once");
+ clickJustOnce();
} else {
// Since it's not, need to find it in the scrollable list...
Log.v(TAG, "Activity " + name + " is not default action");
UiScrollable activitiesList = new UiScrollable(new UiSelector().scrollable(true));
-
- UiObject activity;
try {
activitiesList.scrollForward();
- activity = getVisibleObject(name);
} catch (UiObjectNotFoundException e) {
- throw new IllegalStateException("didn't find activity '" + name
- + "' on activities chooser", e);
+ // TODO: for some paranormal issue, the first time a test is run the scrollable
+ // activity list is displayed but calling scrollForwad() (or even isScrollable())
+ // throws a "UiObjectNotFoundException: UiSelector[SCROLLABLE=true]" exception
+ justOnceHack = true;
+ Log.d(TAG, "could not scroll forward", e);
}
+ UiObject activity = getVisibleObject(name);
// ... then select it.
click(activity, name);
+ if (justOnceHack) {
+ clickJustOnce();
+ }
}
}
+ private void clickJustOnce() {
+ boolean gotIt = mDevice.wait(Until.hasObject(By.res("android", "button_once")), mTimeout);
+ assertTrue("'Just Once' button not visible yet", gotIt);
+
+ UiObject justOnce = mDevice
+ .findObject(new UiSelector().resourceId("android:id/button_once"));
+ assertTrue("'Just Once' button not found", justOnce.exists());
+
+ click(justOnce, "Just Once");
+ }
+
public void pressBack() {
mDevice.pressBack();
}