use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AboutPhoneSettingsTests method removeItemsAndTakeAction.
/**
* Removes items found in the view and optionally takes some action.
*/
private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind) {
for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
String itemText = iterator.next();
UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
if (item != null) {
iterator.remove();
}
}
}
use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AboutPhoneSettingsTests method setUp.
@Before
public void setUp() throws Exception {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mDevice = UiDevice.getInstance(mInstrumentation);
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);
launchAboutPhoneSettings(Settings.ACTION_DEVICE_INFO_SETTINGS);
// TODO: make sure we are always at the top of the app
// currently this will fail if the user has navigated into submenus
UiObject2 view = mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE + ":id/main_content")), TIMEOUT);
assertThat(view).isNotNull();
view.scroll(Direction.UP, 1.0f);
}
use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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 Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConnectedDeviceTests method testNFCToggle.
// This NFC toggle test is set up this way since there's no way to set
// the NFC flag to enabled or disabled without touching UI.
// This way, we get coverage for whether or not the toggle button works.
@Test
public void testNFCToggle() throws Exception {
NfcManager manager = (NfcManager) InstrumentationRegistry.getTargetContext().getSystemService(Context.NFC_SERVICE);
NfcAdapter nfcAdapter = manager.getDefaultAdapter();
boolean nfcInitiallyEnabled = nfcAdapter.isEnabled();
InstrumentationRegistry.getContext().startActivity(new Intent().setClassName(SETTINGS_PACKAGE, "com.android.settings.Settings$ConnectedDeviceDashboardActivity"));
UiObject2 nfcSetting = mDevice.wait(Until.findObject(By.text("NFC")), TIMEOUT);
nfcSetting.click();
Thread.sleep(TIMEOUT * 2);
if (nfcInitiallyEnabled) {
assertFalse("NFC wasn't disabled on toggle", nfcAdapter.isEnabled());
nfcSetting.click();
Thread.sleep(TIMEOUT * 2);
assertTrue("NFC wasn't enabled on toggle", nfcAdapter.isEnabled());
} else {
assertTrue("NFC wasn't enabled on toggle", nfcAdapter.isEnabled());
nfcSetting.click();
Thread.sleep(TIMEOUT * 2);
assertFalse("NFC wasn't disabled on toggle", nfcAdapter.isEnabled());
}
}
use of android.support.test.uiautomator.UiObject2 in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
}
Aggregations