Search in sources :

Example 1 with UiScrollable

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

the class GestureSettingsTest method getDozeSwitch.

private UiObject getDozeSwitch() throws Exception {
    UiScrollable settings = navigateToAmbientDisplay();
    UiObject dozeSwitch = null;
    UiSelector relativeLayoutSelector = new UiSelector().className(RelativeLayout.class.getName());
    String titleDoze = mTargetContext.getResources().getString(R.string.doze_title);
    for (int i = 0; i <= settings.getChildCount(relativeLayoutSelector); i++) {
        UiObject relativeLayout = settings.getChild(relativeLayoutSelector.instance(i));
        if (relativeLayout.getChildCount() != 2) {
            continue;
        }
        UiObject obj1 = relativeLayout.getChild(new UiSelector().index(0));
        if (obj1.getText() == titleDoze) {
            return relativeLayout.getFromParent(new UiSelector().className(Switch.class.getName()));
        }
    }
    return null;
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) RelativeLayout(android.widget.RelativeLayout) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 2 with UiScrollable

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

the class GestureSettingsTest method navigateToAmbientDisplay.

private UiScrollable navigateToAmbientDisplay() throws Exception {
    UiScrollable settings = new UiScrollable(new UiSelector().packageName(mTargetPackage).scrollable(true));
    String titleDisplay = mTargetContext.getResources().getString(R.string.display_settings_title);
    settings.scrollTextIntoView(titleDisplay);
    mDevice.findObject(new UiSelector().text(titleDisplay)).click();
    settings.scrollTextIntoView(mTargetContext.getResources().getString(R.string.doze_title));
    return settings;
}
Also used : UiSelector(android.support.test.uiautomator.UiSelector) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 3 with UiScrollable

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

the class GestureSettingsTest method navigateToMovesSetting.

private void navigateToMovesSetting(String title) throws Exception {
    launchMoves();
    UiScrollable moves = new UiScrollable(new UiSelector().packageName(mTargetPackage).scrollable(true));
    moves.scrollTextIntoView(title);
}
Also used : UiSelector(android.support.test.uiautomator.UiSelector) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 4 with UiScrollable

use of android.support.test.uiautomator.UiScrollable in project android_frameworks_base by ResurrectionRemix.

the class RootsListBot method findRoot.

private UiObject findRoot(String label) throws UiObjectNotFoundException {
    final UiSelector rootsList = new UiSelector().resourceId("com.android.documentsui:id/container_roots").childSelector(new UiSelector().resourceId(ROOTS_LIST_ID));
    // We might need to expand drawer if not visible
    if (!new UiObject(rootsList).waitForExists(mTimeout)) {
        Log.d(TAG, "Failed to find roots list; trying to expand");
        final UiSelector hamburger = new UiSelector().resourceId("com.android.documentsui:id/toolbar").childSelector(new UiSelector().className("android.widget.ImageButton").clickable(true));
        new UiObject(hamburger).click();
    }
    // Wait for the first list item to appear
    new UiObject(rootsList.childSelector(new UiSelector())).waitForExists(mTimeout);
    // Now scroll around to find our item
    new UiScrollable(rootsList).scrollIntoView(new UiSelector().text(label));
    return new UiObject(rootsList.childSelector(new UiSelector().text(label)));
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 5 with UiScrollable

use of android.support.test.uiautomator.UiScrollable in project android_frameworks_base by ResurrectionRemix.

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

UiScrollable (android.support.test.uiautomator.UiScrollable)33 UiSelector (android.support.test.uiautomator.UiSelector)28 UiObject (android.support.test.uiautomator.UiObject)17 Test (org.junit.Test)6 GfxMonitor (android.support.test.jank.GfxMonitor)5 JankTest (android.support.test.jank.JankTest)5 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)5 Intent (android.content.Intent)1 RadioButton (android.widget.RadioButton)1 RelativeLayout (android.widget.RelativeLayout)1