Search in sources :

Example 46 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppsSettingsRetainFilterTests method testDisablingSystemAppAndRotateDevice.

@Test
public void testDisablingSystemAppAndRotateDevice() throws Exception {
    launchAppsSettings();
    UiObject2 calculator = mDevice.wait(Until.findObject(By.text("Calculator")), TIMEOUT);
    assertThat(calculator).isNotNull();
    calculator.click();
    mDevice.waitForIdle(TIMEOUT);
    UiObject2 disableButton = mDevice.wait(Until.findObject(By.text("DISABLE")), TIMEOUT);
    assertThat(disableButton).isNotNull();
    disableButton.click();
    mDevice.waitForIdle(TIMEOUT);
    // Click on "Disable App" on dialog.
    UiObject2 dialogDisableButton = mDevice.wait(Until.findObject(By.text("DISABLE APP")), TIMEOUT);
    assertThat(dialogDisableButton).isNotNull();
    dialogDisableButton.click();
    mDevice.waitForIdle(TIMEOUT);
    UiObject2 enableButton = mDevice.wait(Until.findObject(By.text("ENABLE")), TIMEOUT);
    assertThat(enableButton).isNotNull();
    mDevice.pressBack();
    mDevice.waitForIdle(TIMEOUT);
    UiObject2 spinnerHeader = mDevice.wait(Until.findObject(By.text("All apps")), TIMEOUT);
    assertThat(spinnerHeader).isNotNull();
    spinnerHeader.click();
    UiObject2 optionDisabledApps = mDevice.wait(Until.findObject(By.text("Disabled apps")), TIMEOUT);
    assertThat(optionDisabledApps).isNotNull();
    optionDisabledApps.click();
    mDevice.waitForIdle(TIMEOUT);
    try {
        mDevice.setOrientationLeft();
        mDevice.waitForIdle(TIMEOUT);
    } catch (RemoteException e) {
        throw new RuntimeException("Failed to freeze device orientation", e);
    }
    try {
        mDevice.unfreezeRotation();
        mDevice.waitForIdle(TIMEOUT);
    } catch (RemoteException e) {
        throw new RuntimeException("Failed to un-freeze device orientation", e);
    }
    UiObject2 spinnerDisabledApps = mDevice.wait(Until.findObject(By.text("Disabled apps")), TIMEOUT);
    assertThat(spinnerDisabledApps).isNotNull();
}
Also used : RemoteException(android.os.RemoteException) UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test)

Example 47 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SpellCheckerSettingsUITest method launchSettings_hasSwitchBar.

@Test
public void launchSettings_hasSwitchBar() {
    mInstrumentation.getContext().startActivity(mIntent);
    final UiObject2 switchBar = mUiDevice.wait(Until.findObject(By.text("Use spell checker")), TIMEOUT);
    assertThat(switchBar).isNotNull();
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test)

Example 48 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppOpsSettingsTest 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;
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Switch(android.widget.Switch) UiObject2(android.support.test.uiautomator.UiObject2)

Example 49 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HomepageDisplayTests method testHomepageCategory.

@Presubmit
@Test
public void testHomepageCategory() throws Exception {
    // Launch Settings
    SettingsHelper.launchSettingsPage(InstrumentationRegistry.getContext(), Settings.ACTION_SETTINGS);
    // Scroll to top
    final UiObject2 view = mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "main_content")), TIMEOUT);
    view.scroll(Direction.UP, 100f);
    // Inspect each item
    for (String item : HOMEPAGE_ITEMS) {
        SettingsTestUtils.assertTitleMatch(mDevice, item);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Presubmit(android.platform.test.annotations.Presubmit) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 50 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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