Search in sources :

Example 66 with UiObject2

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

the class NotificationSettingsTests method launchAppsSettings.

private void launchAppsSettings() throws Exception {
    Intent appsSettingsIntent = new Intent(Settings.ACTION_SETTINGS);
    mActivityHelper.launchIntent(appsSettingsIntent);
    mSettingsHelper.flingSettingsToStart();
    UiObject2 view = mDevice.wait(Until.findObject(By.text("Apps & notifications")), TIMEOUT);
    view.click();
    UiObject2 title = mDevice.wait(Until.findObject(By.text("Apps & notifications")), TIMEOUT);
    assertNotNull("Could not find Settings > Apps & notifications screen", title);
}
Also used : Intent(android.content.Intent) UiObject2(android.support.test.uiautomator.UiObject2)

Example 67 with UiObject2

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

the class NotificationSettingsTests method testNotificationsSettingsListForPhone.

@MediumTest
public void testNotificationsSettingsListForPhone() {
    UiObject2 configureNotifications = mDevice.wait(Until.findObject(By.text("Notifications")), TIMEOUT);
    configureNotifications.click();
    mDevice.wait(Until.findObject(By.text("Blink light")), TIMEOUT);
    UiObject2 appNotifications = mDevice.wait(Until.findObject(By.text("On for all apps")), TIMEOUT);
    appNotifications.click();
    UiObject2 view = mDevice.wait(Until.findObject(By.text("All apps")), TIMEOUT);
    assertNotNull("Could not find Settings > Apps screen", view);
    final BySelector preferenceListSelector = By.clazz(ListView.class).res("android:id/list");
    UiObject2 apps = mDevice.wait(Until.findObject(preferenceListSelector), TIMEOUT);
    UiObject2 phone = scrollTo(mDevice, apps, By.text("Phone"), Direction.DOWN);
    assertNotNull("Could not find Phone notification settings", phone);
    phone.click();
    UiObject2 incomingCalls = mDevice.wait(Until.findObject(By.text("Incoming calls")), TIMEOUT);
    assertNotNull("Could not find incoming calls channel", incomingCalls);
    incomingCalls.click();
    // here's the meat of this test: make sure that you cannot change
    // most settings for this channel
    UiObject2 importance = mDevice.wait(Until.findObject(By.text("Importance")), TIMEOUT);
    assertNotNull("Could not find importance toggle", importance);
    assertFalse(importance.isEnabled());
    assertFalse(mDevice.wait(Until.findObject(By.text("Sound")), TIMEOUT).isEnabled());
    ;
    assertFalse(mDevice.wait(Until.findObject(By.text("Vibrate")), TIMEOUT).isEnabled());
    assertFalse(mDevice.wait(Until.findObject(By.text("Override Do Not Disturb")), TIMEOUT).isEnabled());
}
Also used : BySelector(android.support.test.uiautomator.BySelector) ListView(android.widget.ListView) UiObject2(android.support.test.uiautomator.UiObject2) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 68 with UiObject2

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

the class SoundSettingsTest method findRingtoneInList.

private UiObject2 findRingtoneInList(String ringtone) throws Exception {
    mHelper.scrollVert(false);
    SystemClock.sleep(1000);
    UiObject2 ringToneObject = mDevice.wait(Until.findObject(By.text(ringtone)), TIMEOUT);
    int count = 0;
    while (ringToneObject == null && count < 5) {
        mHelper.scrollVert(true);
        SystemClock.sleep(1000);
        ringToneObject = mDevice.wait(Until.findObject(By.text(ringtone)), TIMEOUT);
        count++;
    }
    return ringToneObject;
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 69 with UiObject2

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

the class SoundSettingsTest method clickMore.

private void clickMore() throws InterruptedException {
    UiObject2 more = mDevice.wait(Until.findObject(By.text("Advanced")), TIMEOUT);
    if (more != null) {
        more.click();
        Thread.sleep(TIMEOUT);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 70 with UiObject2

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

the class LocationSettingsTests method dismissAlertDialogs.

// This method dismisses both alert dialogs that might popup and
// interfere with the test. Since the order in which the dialog
// shows up changes in no specific known way, we're checking for
// both dialogs in any order for a robust test. Bug b/36233151
// filed against Location team for specifications. This is a
// workaround in the meantime to ensure coverage.
private void dismissAlertDialogs() throws Exception {
    for (int count = 0; count < 2; count++) {
        UiObject2 agreeDialog = mDevice.wait(Until.findObject(By.text("Improve location accuracy?")), TIMEOUT);
        UiObject2 previousChoiceYesButton = mDevice.wait(Until.findObject(By.text("YES")), TIMEOUT);
        if (agreeDialog != null) {
            mDevice.wait(Until.findObject(By.text("AGREE")), TIMEOUT).click();
            Thread.sleep(TIMEOUT);
            assertNull("Improve location dialog not dismissed", mDevice.wait(Until.findObject(By.text("Improve location accuracy?")), TIMEOUT));
        }
        if (previousChoiceYesButton != null) {
            previousChoiceYesButton.click();
            // Short sleep to wait for the new screen
            Thread.sleep(TIMEOUT);
        }
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

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