Search in sources :

Example 56 with UiObject2

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

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 57 with UiObject2

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

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 58 with UiObject2

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

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 59 with UiObject2

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

the class DataSaverSummaryUITest method launchDataSaverSettings.

private void launchDataSaverSettings() throws InterruptedException {
    mInstrumentation.getContext().startActivity(mIntent);
    final UiObject2 prefDataSaver = mUiDevice.wait(Until.findObject(By.text("Data Saver")), TIMEOUT);
    assertThat(prefDataSaver).isNotNull();
    prefDataSaver.click();
    Thread.sleep(TIMEOUT * 2);
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2)

Example 60 with UiObject2

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

the class PrintJobSettingsActivityTest method viewPrintJobSettings.

@Test
@LargeTest
public void viewPrintJobSettings() throws Exception {
    UUID uuid = UUID.randomUUID();
    Object isWriteCalled = new Object();
    // Create adapter that is good enough to start a print preview
    PrintDocumentAdapter adapter = new PrintDocumentAdapter() {

        @Override
        public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) {
            callback.onLayoutFinished(new PrintDocumentInfo.Builder(uuid.toString()).build(), true);
        }

        @Override
        public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
            synchronized (isWriteCalled) {
                isWriteCalled.notify();
            }
            callback.onWriteFailed(null);
        }
    };
    Activity activity = mActivityRule.getActivity();
    PrintManager pm = mActivityRule.getActivity().getSystemService(PrintManager.class);
    // Start printing
    PrintJob printJob = pm.print(uuid.toString(), adapter, null);
    // Wait until print preview is up
    synchronized (isWriteCalled) {
        isWriteCalled.wait();
    }
    // Start print job settings
    Intent intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
    intent.putExtra(EXTRA_PRINT_JOB_ID, printJob.getId().flattenToString());
    intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
    activity.startActivity(intent);
    UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    UiObject2 printPrefTitle = uiDevice.wait(Until.findObject(By.text("Configuring " + uuid.toString())), 5000);
    assertNotNull(printPrefTitle);
    Log.i(LOG_TAG, "Found " + printPrefTitle.getText());
}
Also used : PrintJob(android.print.PrintJob) Bundle(android.os.Bundle) UiDevice(android.support.test.uiautomator.UiDevice) Activity(android.app.Activity) Intent(android.content.Intent) PrintAttributes(android.print.PrintAttributes) PrintManager(android.print.PrintManager) ParcelFileDescriptor(android.os.ParcelFileDescriptor) UUID(java.util.UUID) PrintDocumentAdapter(android.print.PrintDocumentAdapter) CancellationSignal(android.os.CancellationSignal) UiObject2(android.support.test.uiautomator.UiObject2) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

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