use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by DirtyUnicorns.
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();
}
use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by SudaMod.
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;
}
use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by SudaMod.
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();
}
use of android.support.test.uiautomator.BySelector in project platform_packages_apps_Settings by BlissRoms.
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();
}
use of android.support.test.uiautomator.BySelector in project platform_packages_apps_Settings by BlissRoms.
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();
}
}
Aggregations