use of android.support.test.uiautomator.BySelector in project quickstart-android by firebase.
the class UiAutomatorTest method testLaunchDialog.
@Test
public void testLaunchDialog() {
// Floating action button
BySelector fabSelector = By.res(APP_PACKAGE, "invite_button");
// Click floating action button
Assert.assertTrue(mDevice.wait(Until.hasObject(fabSelector), UI_TIMEOUT));
mDevice.findObject(fabSelector).click();
// Radio button in the account picker dialog
BySelector firstAccountSelector = By.clazz(CLASS_CHECKED_TEXT_VIEW);
// Wait for account picker (may not appear)
if (mDevice.wait(Until.hasObject(firstAccountSelector), UI_TIMEOUT)) {
// Click first account
mDevice.findObjects(firstAccountSelector).get(0).click();
// Button with the text "OK" (enabled)
BySelector okButtonSelector = By.clazz(CLASS_BUTTON).text("OK").enabled(true);
// Click OK on account picker
Assert.assertTrue(mDevice.wait(Until.hasObject(okButtonSelector), UI_TIMEOUT));
mDevice.findObject(okButtonSelector).click();
}
// Check that we can see the title and message
String titleText = mContext.getString(R.string.invitation_title);
String messageText = mContext.getString(R.string.invitation_message);
BySelector titleTextSelector = By.text(titleText);
BySelector messageTextSelector = By.text(messageText);
assertTrue(mDevice.wait(Until.hasObject(titleTextSelector), UI_TIMEOUT));
assertTrue(mDevice.wait(Until.hasObject(messageTextSelector), UI_TIMEOUT));
// Back out of the dialog
mDevice.pressBack();
}
use of android.support.test.uiautomator.BySelector in project android_packages_apps_Settings by LineageOS.
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.BySelector in project android_packages_apps_Settings by LineageOS.
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 omnirom.
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.BySelector in project android_packages_apps_Settings by omnirom.
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;
}
Aggregations