use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.
the class LifecycleEventHandlingTest method launchDashboard_shouldSeeFooter.
@Test
@Presubmit
@Ignore("b/133334887")
public void launchDashboard_shouldSeeFooter() {
new SubSettingLauncher(mContext).setDestination(FeatureFlagsDashboard.class.getName()).setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN).addFlags(FLAG_ACTIVITY_NEW_TASK).launch();
final String footerText = "Experimental";
// Scroll to bottom
final UiObject2 view = mDevice.wait(Until.findObject(By.res(mTargetPackage, "main_content")), TIMEOUT);
view.scroll(Direction.DOWN, 100f);
assertThat(mDevice.wait(Until.findObject(By.text(footerText)), TIMEOUT)).isNotNull();
}
use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.
the class AppsSettingsTests method testDisablingAndEnablingSystemApp.
@MediumTest
public void testDisablingAndEnablingSystemApp() throws Exception {
launchAppsSettings();
UiObject2 calculator = mDevice.wait(Until.findObject(By.text("Calculator")), TIMEOUT);
calculator.click();
mDevice.waitForIdle(TIMEOUT);
UiObject2 appInfoList = mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "list")), TIMEOUT);
appInfoList.scroll(Direction.DOWN, 100.0f);
UiObject2 disableButton = mDevice.wait(Until.findObject(By.text("DISABLE")), TIMEOUT);
disableButton.click();
mDevice.waitForIdle(TIMEOUT);
// Click on "Disable App" on dialog.
mDevice.wait(Until.findObject(By.text("DISABLE APP")), TIMEOUT).click();
mDevice.waitForIdle(TIMEOUT);
UiObject2 enableButton = mDevice.wait(Until.findObject(By.text("ENABLE")), TIMEOUT);
assertNotNull("App not disabled successfully", enableButton);
enableButton.click();
mDevice.waitForIdle(TIMEOUT);
disableButton = mDevice.wait(Until.findObject(By.text("DISABLE")), TIMEOUT);
assertNotNull("App not enabled successfully", disableButton);
}
use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.
the class AppsSettingsTests method setUp.
@Override
public void setUp() throws Exception {
if (LOCAL_LOGV) {
Log.d(TAG, "-------");
}
super.setUp();
mDevice = UiDevice.getInstance(getInstrumentation());
mActivityHelper = ActivityHelper.getInstance();
try {
mDevice.setOrientationNatural();
} catch (RemoteException e) {
throw new RuntimeException("Failed to freeze device orientaion", e);
}
// make sure we are in a clean state before starting the test
mDevice.pressHome();
Thread.sleep(TIMEOUT * 2);
launchAppsSettings();
UiObject2 view = mDevice.wait(Until.findObject(By.text("All apps")), TIMEOUT);
assertNotNull("Could not find Settings > Apps screen", view);
}
use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.
the class MoreWirelessSettingsTest2 method scrollToObject.
private UiObject2 scrollToObject(BySelector scrollableSelector, BySelector objectSelector) throws Exception {
UiObject2 scrollable = mDevice.wait(Until.findObject(scrollableSelector), TIMEOUT);
if (scrollable == null) {
fail("Could not find scrollable UI object identified by " + scrollableSelector);
}
UiObject2 found = null;
// Scroll all the way up first, then all the way down.
while (true) {
// Optimization: terminate if we find the object while scrolling up to reset, so
// we save the time spent scrolling down again.
boolean canScrollAgain = scrollable.scroll(Direction.UP, SCROLL_UP_PERCENT, SCROLL_SPEED);
found = mDevice.findObject(objectSelector);
if (found != null)
return found;
if (!canScrollAgain)
break;
}
for (int attempts = 0; found == null && attempts < MAX_SCROLL_ATTEMPTS; ++attempts) {
// Return value of UiObject2.scroll() is not reliable, so do not use it in loop
// condition, in case it causes this loop to terminate prematurely.
scrollable.scroll(Direction.DOWN, SCROLL_DOWN_PERCENT, SCROLL_SPEED);
found = mDevice.findObject(objectSelector);
}
if (found == null) {
fail("Could not scroll to UI object identified by " + objectSelector);
}
return found;
}
use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.
the class MoreWirelessSettingsTest2 method testWifiMenuLoadConfigure.
@MediumTest
public void testWifiMenuLoadConfigure() throws Exception {
loadWiFiConfigureMenu();
Thread.sleep(SLEEP_TIME);
UiObject2 configureWiFiHeading = mDevice.wait(Until.findObject(By.text(CONFIGURE_WIFI_PREFERENCE_TEXT)), TIMEOUT);
assertNotNull("Configure WiFi menu has not loaded correctly", configureWiFiHeading);
}
Aggregations