Search in sources :

Example 11 with BySelector

use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by crdroidandroid.

the class ExternalSourcesSettingsTest method testManageExternalSourcesList.

@Test
public void testManageExternalSourcesList() throws Exception {
    final String testAppLabel = getApplicationLabel(mPackageName);
    mContext.startActivity(createManageExternalSourcesListIntent());
    final BySelector preferenceListSelector = By.clazz(ListView.class).res("android:id/list");
    final UiObject2 preferenceList = mUiDevice.wait(Until.findObject(preferenceListSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("App list not shown", preferenceList);
    final BySelector appLabelTextViewSelector = By.clazz(TextView.class).res("android:id/title").text(testAppLabel);
    List<UiObject2> listOfMatchingTextViews;
    do {
        listOfMatchingTextViews = preferenceList.findObjects(appLabelTextViewSelector);
    // assuming the number of profiles will be sufficiently small so that all the entries
    // for the same package will fit in one screen at some time during the scroll.
    } while (listOfMatchingTextViews.size() != mProfiles.size() && preferenceList.scroll(Direction.DOWN, 0.2f));
    assertEquals("Test app not listed for each profile", mProfiles.size(), listOfMatchingTextViews.size());
    for (UiObject2 matchingObject : listOfMatchingTextViews) {
        matchingObject.click();
        findAndVerifySwitchState(true);
        mUiDevice.pressBack();
    }
}
Also used : BySelector(android.support.test.uiautomator.BySelector) ListView(android.widget.ListView) UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 12 with BySelector

use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by crdroidandroid.

the class ExternalSourcesSettingsTest method testAppDetailScreenForAppOp.

private void testAppDetailScreenForAppOp(int appOpMode, int userId) throws Exception {
    final String testAppLabel = getApplicationLabel(mPackageName);
    final BySelector appDetailTitleSelector = By.clazz(TextView.class).res("com.android.settings:id/app_detail_title").text(testAppLabel);
    mAppOpsManager.setMode(OP_REQUEST_INSTALL_PACKAGES, mPackageManager.getPackageUidAsUser(mPackageName, userId), mPackageName, appOpMode);
    mContext.startActivityAsUser(createManageExternalSourcesAppIntent(mPackageName), UserHandle.of(userId));
    mUiDevice.wait(Until.findObject(appDetailTitleSelector), START_ACTIVITY_TIMEOUT);
    findAndVerifySwitchState(appOpMode == MODE_ALLOWED || appOpMode == MODE_DEFAULT);
    mUiDevice.pressBack();
}
Also used : BySelector(android.support.test.uiautomator.BySelector)

Example 13 with BySelector

use of android.support.test.uiautomator.BySelector in project platform_packages_apps_Settings by BlissRoms.

the class ExternalSourcesSettingsTest method findAndVerifySwitchState.

private UiObject2 findAndVerifySwitchState(boolean checked) {
    final BySelector switchSelector = By.clazz(Switch.class).res("android:id/switch_widget");
    final UiObject2 switchPref = mUiDevice.wait(Until.findObject(switchSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("Switch not shown", switchPref);
    assertTrue("Switch in invalid state", switchPref.isChecked() == checked);
    return switchPref;
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Switch(android.widget.Switch) UiObject2(android.support.test.uiautomator.UiObject2)

Example 14 with BySelector

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

the class AppOpsSettingsTest method findAndVerifySwitchState.

private UiObject2 findAndVerifySwitchState(boolean checked) {
    final BySelector switchSelector = By.clazz(Switch.class).res("android:id/switch_widget");
    final UiObject2 switchPref = mUiDevice.wait(Until.findObject(switchSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("Switch not shown", switchPref);
    assertTrue("Switch in invalid state", switchPref.isChecked() == checked);
    return switchPref;
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Switch(android.widget.Switch) UiObject2(android.support.test.uiautomator.UiObject2)

Example 15 with BySelector

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

the class AppOpsSettingsTest method testAppDetailScreenForAppOp.

private void testAppDetailScreenForAppOp(int appOpMode, int userId) throws Exception {
    final String testAppLabel = getApplicationLabel(mPackageName);
    final BySelector appDetailTitleSelector = By.clazz(TextView.class).res("com.android.settings:id/app_detail_title").text(testAppLabel);
    mAppOpsManager.setMode(mAppOpCode, mPackageManager.getPackageUidAsUser(mPackageName, userId), mPackageName, appOpMode);
    mContext.startActivityAsUser(createManageSingleAppIntent(mPackageName), UserHandle.of(userId));
    mUiDevice.wait(Until.findObject(appDetailTitleSelector), START_ACTIVITY_TIMEOUT);
    findAndVerifySwitchState(appOpMode == MODE_ALLOWED || appOpMode == MODE_DEFAULT);
    mUiDevice.pressBack();
}
Also used : BySelector(android.support.test.uiautomator.BySelector)

Aggregations

BySelector (android.support.test.uiautomator.BySelector)37 UiObject2 (android.support.test.uiautomator.UiObject2)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 Suppress (android.test.suitebuilder.annotation.Suppress)8 ListView (android.widget.ListView)8 Test (org.junit.Test)8 Switch (android.widget.Switch)7 LargeTest (android.support.test.filters.LargeTest)6 UiSelector (android.support.test.uiautomator.UiSelector)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)1