Search in sources :

Example 31 with BySelector

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

the class AppOpsSettingsTest method testAppList.

@Test
public void testAppList() throws Exception {
    final String testAppLabel = getApplicationLabel(mPackageName);
    mContext.startActivity(createManageAllAppsIntent());
    final BySelector preferenceListSelector = By.clazz(RecyclerView.class).res("com.android.settings:id/apps_list");
    final UiObject2 preferenceList = mUiDevice.wait(Until.findObject(preferenceListSelector), START_ACTIVITY_TIMEOUT);
    assertNotNull("App list not shown", preferenceList);
    final BySelector appLabelTextViewSelector = By.clazz(TextView.class).res("android:id/title").text(testAppLabel);
    List<UiObject2> listOfMatchingTextViews;
    do {
        listOfMatchingTextViews = preferenceList.findObjects(appLabelTextViewSelector);
    // assuming the number of profiles will be sufficiently small so that all the entries
    // for the same package will fit in one screen at some time during the scroll.
    } while (listOfMatchingTextViews.size() != mProfiles.size() && preferenceList.scroll(Direction.DOWN, 0.2f));
    assertEquals("Test app not listed for each profile", mProfiles.size(), listOfMatchingTextViews.size());
    for (UiObject2 matchingObject : listOfMatchingTextViews) {
        matchingObject.click();
        findAndVerifySwitchState(true);
        mUiDevice.pressBack();
    }
}
Also used : BySelector(android.support.test.uiautomator.BySelector) RecyclerView(androidx.recyclerview.widget.RecyclerView) UiObject2(android.support.test.uiautomator.UiObject2) Test(org.junit.Test)

Example 32 with BySelector

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

the class MoreWirelessSettingsTest2 method testAddNetworkMenu_IpSettings.

@Suppress
@MediumTest
public void testAddNetworkMenu_IpSettings() throws Exception {
    loadAddNetworkMenu();
    // Toggle advanced options.
    mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID).clazz(CHECKBOX_CLASS)), TIMEOUT).click();
    // Verify IP settings defaults to DHCP.
    BySelector ipSettingsBySelector = By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IP_SETTINGS_RES_ID).clazz(SPINNER_CLASS);
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector);
    assertEquals("DHCP", mDevice.wait(Until.findObject(ipSettingsBySelector), TIMEOUT).getChildren().get(0).getText());
    // Verify that Static IP settings options appear.
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector).click();
    mDevice.wait(Until.findObject(By.text("Static")), TIMEOUT).click();
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "ipaddress"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "gateway"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "network_prefix_length"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "dns1"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "dns2"));
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 33 with BySelector

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

the class MoreWirelessSettingsTest2 method testAddNetworkMenu_Proxy.

@Suppress
@MediumTest
public void testAddNetworkMenu_Proxy() throws Exception {
    loadAddNetworkMenu();
    // Toggle advanced options.
    mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID).clazz(CHECKBOX_CLASS)), TIMEOUT).click();
    // Verify Proxy defaults to None.
    BySelector proxySettingsBySelector = By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID).clazz(SPINNER_CLASS);
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
    assertEquals("None", mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).getChildren().get(0).getText());
    // Verify that Proxy Manual fields appear.
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
    mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
    mDevice.wait(Until.findObject(By.text("Manual")), TIMEOUT).click();
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "proxy_warning_limited_support"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "proxy_hostname"));
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "proxy_exclusionlist"));
    // Verify that Proxy Auto-Config options appear.
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
    mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
    mDevice.wait(Until.findObject(By.text("Proxy Auto-Config")), TIMEOUT).click();
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, By.res(SETTINGS_PACKAGE, "proxy_pac"));
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 34 with BySelector

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

the class MoreWirelessSettingsTest2 method testPhase2Settings.

@Suppress
@MediumTest
public void testPhase2Settings() throws Exception {
    loadAddNetworkMenu();
    selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
    BySelector phase2SettingsBySelector = By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID).clazz(SPINNER_CLASS);
    findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, phase2SettingsBySelector);
    assertEquals(PHASE2_MENU_NONE_TEXT, mDevice.wait(Until.findObject(phase2SettingsBySelector), TIMEOUT).getChildren().get(0).getText());
    mDevice.wait(Until.findObject(phase2SettingsBySelector), TIMEOUT).click();
    Thread.sleep(SLEEP_TIME);
    // Verify Phase 2 authentication spinner options.
    assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_NONE_TEXT)), TIMEOUT));
    assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_MSCHAPV2_TEXT)), TIMEOUT));
    assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_GTC_TEXT)), TIMEOUT));
}
Also used : BySelector(android.support.test.uiautomator.BySelector) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 35 with BySelector

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

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)

Aggregations

BySelector (android.support.test.uiautomator.BySelector)37 UiObject2 (android.support.test.uiautomator.UiObject2)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 Suppress (android.test.suitebuilder.annotation.Suppress)8 ListView (android.widget.ListView)8 Test (org.junit.Test)8 Switch (android.widget.Switch)7 LargeTest (android.support.test.filters.LargeTest)6 UiSelector (android.support.test.uiautomator.UiSelector)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)1