Search in sources :

Example 71 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.

the class MoreWirelessSettingsTests method testVPNMenuLoad.

@MediumTest
public void testVPNMenuLoad() throws Exception {
    SettingsHelper.launchSettingsPage(getInstrumentation().getContext(), Settings.ACTION_WIRELESS_SETTINGS);
    mDevice.wait(Until.findObject(By.text("VPN")), TIMEOUT).click();
    Thread.sleep(TIMEOUT);
    UiObject2 usbTethering = mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "vpn_create")), TIMEOUT);
    assertNotNull("VPN screen did not load correctly", usbTethering);
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 72 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.

the class ZonePickerSettingsTest method testSelectTimeZone.

private void testSelectTimeZone(String region, String timezone, String expectedTimeZoneOffset, String expectedTimeZoneId, boolean assumeOneTimeZoneInRegion) throws Exception {
    mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE, 0);
    SettingsHelper.launchSettingsPage(InstrumentationRegistry.getContext(), Settings.ACTION_DATE_SETTINGS);
    UiObject2 selectTimeZone = wait(SELECTOR_SELECT_TIME_ZONE);
    assertTrue(selectTimeZone.isEnabled());
    selectTimeZone.click();
    wait(By.text("Region")).click();
    // Speed-up the test by searching with the first 2 characters of the region name
    wait(By.res("android", "search_src_text")).setText(region.substring(0, 2));
    // Select region in the list
    selectItemInList(new UiSelector().textContains(region)).click();
    // Only select time zone explicitly if there are more than one time zones in a region
    if (!assumeOneTimeZoneInRegion) {
        wait(By.text("Time zone"));
        selectItemInList(new UiSelector().textContains(timezone)).click();
    }
    mDevice.pressBack();
    // The select button should include the GMT offset in the summary
    BySelector summarySelector = By.res("android:id/summary");
    UiObject2 selectedTimeZone = selectTimeZone.findObject(summarySelector);
    assertUiObjectFound(selectedTimeZone, summarySelector);
    assertTrue("Expect " + expectedTimeZoneOffset + " is shown for " + timezone, selectedTimeZone.getText().startsWith(expectedTimeZoneOffset));
    waitAndAssertTimeGetDefault(expectedTimeZoneId);
    assertEquals("Time zone change in Settings should update persist.sys.timezone", expectedTimeZoneId, SystemProperties.get("persist.sys.timezone"));
}
Also used : BySelector(android.support.test.uiautomator.BySelector) UiSelector(android.support.test.uiautomator.UiSelector) UiObject2(android.support.test.uiautomator.UiObject2)

Example 73 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.

the class ZonePickerSettingsTest method zonePickerDisabled.

@Test
public void zonePickerDisabled() throws Exception {
    mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE, 1);
    SettingsHelper.launchSettingsPage(InstrumentationRegistry.getContext(), Settings.ACTION_DATE_SETTINGS);
    UiObject2 selectTimeZone = wait(SELECTOR_SELECT_TIME_ZONE);
    assertFalse(selectTimeZone.isEnabled());
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 74 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.

the class ZonePickerSettingsTest method wait.

/**
 * @throws UiObjectNotFoundException if UiDevice.wait returns null
 */
private UiObject2 wait(BySelector selector) throws UiObjectNotFoundException {
    UiObject2 item = mDevice.wait(Until.findObject(selector), TIMEOUT);
    assertUiObjectFound(item, selector);
    return item;
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 75 with UiObject2

use of android.support.test.uiautomator.UiObject2 in project android_packages_apps_Settings by omnirom.

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)

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