summaryrefslogtreecommitdiff
path: root/packages/Shell/tests
diff options
context:
space:
mode:
authorFelipe Leme <felipeal@google.com>2016-04-15 11:32:53 -0700
committerFelipe Leme <felipeal@google.com>2016-04-15 12:04:46 -0700
commit3fb3d88d2b81122038a47c831d10f6b5ecf2b83a (patch)
treebdd60c9ff833e197fda8c40839fe328ff8447cb9 /packages/Shell/tests
parent067f821ec84d3bcb556a8de77f3e3d3b8c042186 (diff)
Fix first-time usage.
When tests run for the first time, the list of activities that can handle ACTION_SEND_MULTIPLE might not be scrollable, which was cause the scrollForward() method to fail. BUG: 27431998 Change-Id: I5992bc9fec6291c74c4af7887ee66eb4f96e87c0
Diffstat (limited to 'packages/Shell/tests')
-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();
}