use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by crdroidandroid.
the class ExternalSourcesSettingsTest method testSwitchToggle.
private void testSwitchToggle(int fromAppOp, int toAppOp) throws Exception {
final int packageUid = mPackageManager.getPackageUid(mPackageName, 0);
final boolean initialState = (fromAppOp == MODE_ALLOWED || fromAppOp == MODE_DEFAULT);
mAppOpsManager.setMode(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName, fromAppOp);
mContext.startActivity(createManageExternalSourcesAppIntent(mPackageName));
final UiObject2 switchPref = findAndVerifySwitchState(initialState);
switchPref.click();
Thread.sleep(1000);
assertEquals("Toggling switch did not change app op", toAppOp, mAppOpsManager.checkOpNoThrow(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName));
mUiDevice.pressBack();
}
use of android.support.test.uiautomator.UiObject2 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();
}
}
use of android.support.test.uiautomator.UiObject2 in project incubator-weex by apache.
the class BenchmarkTest method testScrollFPS.
@Repeat(TIMES)
@Test
@SdkSuppress(minSdkVersion = 23)
public void testScrollFPS() {
UiObject2 uiObject2 = loadPageForFPS();
if (uiObject2 != null) {
uiObject2.scroll(Direction.DOWN, 6, SCROLL_SPEED);
processGfxInfo(scrollFrameSeconds);
}
}
use of android.support.test.uiautomator.UiObject2 in project platform_packages_apps_Settings by BlissRoms.
the class TestUtils method setEditTextWithValue.
/**
* Find {@link android.widget.EditText} with {@code res} and set its {@code value}
*/
public static void setEditTextWithValue(UiDevice uiDevice, String res, long value) {
final UiObject2 editText = uiDevice.findObject(By.res(res));
assertWithMessage("Cannot find editText with res: " + res).that(editText).isNotNull();
editText.setText(String.valueOf(value));
}
use of android.support.test.uiautomator.UiObject2 in project platform_packages_apps_Settings by BlissRoms.
the class ExternalSourcesSettingsTest method testSwitchToggle.
private void testSwitchToggle(int fromAppOp, int toAppOp) throws Exception {
final int packageUid = mPackageManager.getPackageUid(mPackageName, 0);
final boolean initialState = (fromAppOp == MODE_ALLOWED || fromAppOp == MODE_DEFAULT);
mAppOpsManager.setMode(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName, fromAppOp);
mContext.startActivity(createManageExternalSourcesAppIntent(mPackageName));
final UiObject2 switchPref = findAndVerifySwitchState(initialState);
switchPref.click();
Thread.sleep(1000);
assertEquals("Toggling switch did not change app op", toAppOp, mAppOpsManager.checkOpNoThrow(OP_REQUEST_INSTALL_PACKAGES, packageUid, mPackageName));
mUiDevice.pressBack();
}
Aggregations