Search in sources :

Example 76 with UiSelector

use of android.support.test.uiautomator.UiSelector in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GestureSettingsTest method launchMoves.

private void launchMoves() throws Exception {
    launchSettings();
    UiScrollable settings = new UiScrollable(new UiSelector().packageName(mTargetPackage).scrollable(true));
    String titleMoves = mTargetContext.getResources().getString(R.string.gesture_preference_title);
    settings.scrollTextIntoView(titleMoves);
    mDevice.findObject(new UiSelector().text(titleMoves)).click();
}
Also used : UiSelector(android.support.test.uiautomator.UiSelector) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 77 with UiSelector

use of android.support.test.uiautomator.UiSelector in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GestureSettingsTest method getGestureSwitch.

private UiObject getGestureSwitch(String title) throws Exception {
    UiObject titleView = mDevice.findObject(new UiSelector().text(title));
    UiObject gestureSwitch = titleView.getFromParent(new UiSelector().className(Switch.class.getName()));
    assertNotNull(gestureSwitch);
    assertTrue(gestureSwitch.exists());
    return gestureSwitch;
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector)

Example 78 with UiSelector

use of android.support.test.uiautomator.UiSelector in project android_frameworks_base by crdroidandroid.

the class DirectoryListBot method findDocument.

public UiObject findDocument(String label) throws UiObjectNotFoundException {
    final UiSelector docList = new UiSelector().resourceId("com.android.documentsui:id/container_directory").childSelector(new UiSelector().resourceId(DIR_LIST_ID));
    // Wait for the first list item to appear
    new UiObject(docList.childSelector(new UiSelector())).waitForExists(mTimeout);
    // new UiScrollable(docList).scrollIntoView(new UiSelector().text(label));
    return mDevice.findObject(docList.childSelector(new UiSelector().text(label)));
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector)

Example 79 with UiSelector

use of android.support.test.uiautomator.UiSelector in project android_frameworks_base by crdroidandroid.

the class UiBot method findDownloadRetryDialog.

public UiObject findDownloadRetryDialog() {
    UiSelector selector = new UiSelector().text("Couldn't download");
    UiObject title = mDevice.findObject(selector);
    title.waitForExists(mTimeout);
    return title;
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector)

Example 80 with UiSelector

use of android.support.test.uiautomator.UiSelector in project android_frameworks_base by crdroidandroid.

the class UiBot method chooseActivity.

/**
     * Chooses a given activity to handle an Intent, using the "Just Once" button.
     *
     * @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();
        }
    }
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) UiObjectNotFoundException(android.support.test.uiautomator.UiObjectNotFoundException) UiScrollable(android.support.test.uiautomator.UiScrollable)

Aggregations

UiSelector (android.support.test.uiautomator.UiSelector)125 UiObject (android.support.test.uiautomator.UiObject)103 Test (org.junit.Test)46 UiScrollable (android.support.test.uiautomator.UiScrollable)29 Intent (android.content.Intent)26 SmallTest (android.support.test.filters.SmallTest)18 KeyguardManager (android.app.KeyguardManager)14 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)9 UiDevice (android.support.test.uiautomator.UiDevice)3 SmallTest (androidx.test.filters.SmallTest)3 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 Context (android.content.Context)2 BySelector (android.support.test.uiautomator.BySelector)2 UiObject2 (android.support.test.uiautomator.UiObject2)2 Activity (android.app.Activity)1 Preference (android.preference.Preference)1 ViewInteraction (android.support.test.espresso.ViewInteraction)1 MediumTest (android.support.test.filters.MediumTest)1 RadioButton (android.widget.RadioButton)1