use of android.support.test.uiautomator.UiScrollable in project android_frameworks_base by crdroidandroid.
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();
}
}
}
use of android.support.test.uiautomator.UiScrollable in project android_frameworks_base by crdroidandroid.
the class FilesJankPerfTest method testFlingJankPerformance.
@JankTest(expectedFrames = 0, beforeLoop = "setupAndOpenInLoop", afterLoop = "tearDownInLoop")
@GfxMonitor(processName = DOCUMENTSUI_PACKAGE)
public void testFlingJankPerformance() throws Exception {
new UiScrollable(mDirListBot.findDocumentsList().getSelector()).flingToEnd(MAX_FLINGS);
getInstrumentation().waitForIdleSync();
}
use of android.support.test.uiautomator.UiScrollable in project android_packages_apps_Settings by LineageOS.
the class UserSettingsTest method launchUserSettings.
private void launchUserSettings() throws Exception {
launchSettings();
final UiScrollable settings = new UiScrollable(new UiSelector().packageName(mTargetPackage).scrollable(true));
final String titleUsersAndAccounts = USER_AND_ACCOUNTS;
settings.scrollTextIntoView(titleUsersAndAccounts);
mDevice.findObject(new UiSelector().text(titleUsersAndAccounts)).click();
mDevice.findObject(new UiSelector().text(USERS)).click();
}
use of android.support.test.uiautomator.UiScrollable in project android_frameworks_base by ResurrectionRemix.
the class FilesJankPerfTest method testFlingJankPerformance.
@JankTest(expectedFrames = 0, beforeLoop = "setupAndOpenInLoop", afterLoop = "tearDownInLoop")
@GfxMonitor(processName = DOCUMENTSUI_PACKAGE)
public void testFlingJankPerformance() throws Exception {
new UiScrollable(mDirListBot.findDocumentsList().getSelector()).flingToEnd(MAX_FLINGS);
getInstrumentation().waitForIdleSync();
}
use of android.support.test.uiautomator.UiScrollable in project focus-android by mozilla-mobile.
the class SettingsScreenshots method takeScreenShotsOfSettings.
@Test
public void takeScreenShotsOfSettings() throws Exception {
openSettings();
Screengrab.screenshot("Settings_View_Top");
/* Language List (First page only */
onView(withText(R.string.preference_language)).perform(click());
// Cancel button is not translated in some locales, and there are no R.id defined
// That can be checked in the language list dialog
UiObject CancelBtn = device.findObject(new UiSelector().resourceId("android:id/button2").enabled(true));
CancelBtn.waitForExists(waitingTime);
Screengrab.screenshot("Language_Selection");
CancelBtn.click();
onView(withText(R.string.preference_language)).check(matches(isDisplayed()));
/* Search Engine List */
onView(withText(R.string.preference_search_engine_default)).perform(click());
onView(withText(R.string.preference_search_installed_search_engines)).check(matches(isDisplayed()));
Screengrab.screenshot("SearchEngine_Selection");
/* Remove Search Engine page */
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getContext());
// wait until dialog fully appears
device.waitForIdle();
onView(withText(R.string.preference_search_remove)).check(matches(isDisplayed()));
Screengrab.screenshot("SearchEngine_Search_Engine_Menu");
// Menu items don't have ids, so we have to match by text
onView(withText(R.string.preference_search_remove)).perform(click());
// wait until dialog fully disappears
device.waitForIdle();
assertToolbarMatchesText(R.string.preference_search_remove_title);
Screengrab.screenshot("SearchEngine_Remove_Search_Engines");
Espresso.pressBack();
/* Manual Search Engine page */
final String addEngineLabel = getString(R.string.preference_search_add2);
onData(withTitleText(addEngineLabel)).perform(click());
onView(withId(R.id.edit_engine_name)).check(matches(isEnabled()));
Screengrab.screenshot("SearchEngine_Add_Search_Engine");
Espresso.pressBack();
Espresso.pressBack();
Espresso.pressBack();
/* Tap autocomplete menu */
final String urlAutocompletemenu = getString(R.string.preference_subitem_autocomplete);
onData(withTitleText(urlAutocompletemenu)).perform(click());
onView(withText(getString(R.string.preference_autocomplete_custom_summary))).check(matches(isDisplayed()));
Screengrab.screenshot("Autocomplete_Menu_Item");
/* Enable Autocomplete, and enter Custom URLs */
onView(withText(getString(R.string.preference_autocomplete_custom_summary))).perform(click());
/* Add custom URL */
final String key = InstrumentationRegistry.getTargetContext().getString(R.string.pref_key_screen_custom_domains);
onData(withKey(key)).perform(click());
final String addCustomURLAction = getString(R.string.preference_autocomplete_action_add);
onView(withText(addCustomURLAction)).check(matches(isDisplayed()));
Screengrab.screenshot("Autocomplete_Custom_URL_List");
onView(withText(addCustomURLAction)).perform(click());
onView(withId(R.id.domainView)).check(matches(isDisplayed()));
Screengrab.screenshot("Autocomplete_Add_Custom_URL_Dialog");
onView(withId(R.id.domainView)).perform(typeText("screenshot.com"), closeSoftKeyboard());
onView(withId(R.id.save)).perform(click());
onView(withText(addCustomURLAction)).check(matches(isDisplayed()));
/* Remove menu */
final String removeMenu = getString(R.string.preference_autocomplete_menu_remove);
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getContext());
// wait until dialog fully appears
device.waitForIdle();
onView(withText(removeMenu)).check(matches(isDisplayed()));
Screengrab.screenshot("Autocomplete_Custom_URL_Remove_Menu_Item");
onView(withText(removeMenu)).perform(click());
// wait until dialog fully disappears
device.waitForIdle();
/* Remove dialog */
onView(withText(getString(R.string.preference_autocomplete_title_remove))).check(matches(isDisplayed()));
Screengrab.screenshot("Autocomplete_Custom_URL_Remove_Dialog");
Espresso.pressBack();
onView(withText(addCustomURLAction)).check(matches(isDisplayed()));
Espresso.pressBack();
onView(withText(urlAutocompletemenu)).check(matches(isDisplayed()));
Espresso.pressBack();
/* scroll down */
assertTrue(TestHelper.settingsHeading.waitForExists(waitingTime));
UiScrollable settingsView = new UiScrollable(new UiSelector().scrollable(true));
settingsView.scrollToEnd(4);
Screengrab.screenshot("Settings_View_Bottom");
// "About" screen
final String aboutLabel = getString(R.string.preference_about, getString(R.string.app_name));
onData(withTitleText(aboutLabel)).check(matches(isDisplayed())).perform(click());
onView(allOf(withClassName(endsWith("TextView")), withParent(withId(R.id.toolbar)))).check(matches(isDisplayed())).check(matches(withText(R.string.menu_about)));
onWebView().withElement(findElement(Locator.ID, "wordmark")).perform(webClick());
Screengrab.screenshot("About_Page");
// Leave about page
device.pressBack();
// "Your rights" screen
final String yourRightsLabel = getString(R.string.menu_rights);
onData(withTitleText(yourRightsLabel)).check(matches(isDisplayed())).perform(click());
onView(allOf(withClassName(endsWith("TextView")), withParent(withId(R.id.toolbar)))).check(matches(isDisplayed())).check(matches(withText(yourRightsLabel)));
onWebView().withElement(findElement(Locator.ID, "first")).perform(webClick());
Screengrab.screenshot("YourRights_Page");
}
Aggregations