Search in sources :

Example 61 with UiObject2

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();
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Presubmit(android.platform.test.annotations.Presubmit) Ignore(org.junit.Ignore) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 62 with UiObject2

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);
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 63 with UiObject2

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);
}
Also used : RemoteException(android.os.RemoteException) UiObject2(android.support.test.uiautomator.UiObject2)

Example 64 with UiObject2

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;
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 65 with UiObject2

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);
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

UiObject2 (android.support.test.uiautomator.UiObject2)133 Test (org.junit.Test)30 BySelector (android.support.test.uiautomator.BySelector)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)16 ListView (android.widget.ListView)8 MediumTest (androidx.test.filters.MediumTest)8 Switch (android.widget.Switch)7 Intent (android.content.Intent)6 RemoteException (android.os.RemoteException)6 LargeTest (android.support.test.filters.LargeTest)6 UiDevice (android.support.test.uiautomator.UiDevice)6 Presubmit (android.platform.test.annotations.Presubmit)4 SdkSuppress (android.support.test.filters.SdkSuppress)4 Activity (android.app.Activity)2 NfcAdapter (android.nfc.NfcAdapter)2 NfcManager (android.nfc.NfcManager)2 Bundle (android.os.Bundle)2 CancellationSignal (android.os.CancellationSignal)2 ParcelFileDescriptor (android.os.ParcelFileDescriptor)2 PrintAttributes (android.print.PrintAttributes)2