summaryrefslogtreecommitdiff
path: root/packages/Shell/tests
diff options
context:
space:
mode:
authorFelipe Leme <felipeal@google.com>2016-07-28 15:16:55 -0700
committerFelipe Leme <felipeal@google.com>2016-07-28 15:29:17 -0700
commit91699af8c6dae2a3ca703abc410fc00c0ab5de59 (patch)
treee0dce2a05ed587df9d548f64226a6a19ac00f1da /packages/Shell/tests
parente116bcf72a71f96c0c5bfcd79a329c7c77eabf34 (diff)
Always use chooser for Share Bug Report intent.
When using startActivity(intent), the platform allows the user to pick the same activity for the intent, which can be a problem for sharing bug reports when the device has personal and work profiles. Change-Id: I1fd66905feb5d894307bbe5656c2aec705a59ab7 Fixes: 22115530
Diffstat (limited to 'packages/Shell/tests')
-rw-r--r--packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java2
-rw-r--r--packages/Shell/tests/src/com/android/shell/UiBot.java53
2 files changed, 12 insertions, 43 deletions
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index ad66dfc992d0..8eed6a27d942 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -175,6 +175,8 @@ public class BugreportReceiverTest extends InstrumentationTestCase {
mDescription = sb.toString();
setWarningState(mContext, STATE_HIDE);
+
+ mUiBot.turnScreenOn();
}
public void testProgress() throws Exception {
diff --git a/packages/Shell/tests/src/com/android/shell/UiBot.java b/packages/Shell/tests/src/com/android/shell/UiBot.java
index ef24791aac72..d9f5b7a0415c 100644
--- a/packages/Shell/tests/src/com/android/shell/UiBot.java
+++ b/packages/Shell/tests/src/com/android/shell/UiBot.java
@@ -22,7 +22,6 @@ import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
-import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import android.util.Log;
@@ -156,56 +155,24 @@ final class UiBot {
}
/**
- * Chooses a given activity to handle an Intent, using the "Just Once" button.
+ * Chooses a given activity to handle an Intent.
*
* @param name name of the activity as displayed in the UI (typically the value set by
* {@code android:label} in the manifest).
*/
- // TODO: UI Automator should provide such logic.
public void chooseActivity(String name) {
- // First check if the activity is the default option.
- 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");
- 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));
- try {
- activitiesList.scrollForward();
- } catch (UiObjectNotFoundException 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");
+ // It uses an intent chooser now, so just getting the activity by text is enough...
+ UiObject activity = getVisibleObject(name);
+ click(activity, name);
}
public void pressBack() {
mDevice.pressBack();
}
+
+ public void turnScreenOn() throws Exception {
+ mDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP");
+ mDevice.executeShellCommand("wm dismiss-keyguard");
+ }
+
}