Search in sources :

Example 21 with UiDevice

use of android.support.test.uiautomator.UiDevice in project android_packages_apps_Settings by DirtyUnicorns.

the class SettingsRestoreAfterCloseTest method testRtlStability_AppCloseAndReOpen_shouldNotCrash.

@Test
public void testRtlStability_AppCloseAndReOpen_shouldNotCrash() throws Exception {
    final UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    uiDevice.pressHome();
    // Open the settings app
    startSettingsMainActivity(uiDevice);
    // Press home button
    uiDevice.pressHome();
    final String launcherPackage = uiDevice.getLauncherPackageName();
    uiDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), TIME_OUT);
    // Open the settings again
    startSettingsMainActivity(uiDevice);
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 22 with UiDevice

use of android.support.test.uiautomator.UiDevice in project android_packages_apps_Settings by SudaMod.

the class SettingsRestoreAfterCloseTest method testRtlStability_AppCloseAndReOpen_shouldNotCrash.

@Test
public void testRtlStability_AppCloseAndReOpen_shouldNotCrash() throws Exception {
    final UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    uiDevice.pressHome();
    // Open the settings app
    startSettingsMainActivity(uiDevice);
    // Press home button
    uiDevice.pressHome();
    final String launcherPackage = uiDevice.getLauncherPackageName();
    uiDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), TIME_OUT);
    // Open the settings again
    startSettingsMainActivity(uiDevice);
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 23 with UiDevice

use of android.support.test.uiautomator.UiDevice in project platform_packages_apps_Settings by BlissRoms.

the class SettingsRestoreAfterCloseTest method testRtlStability_AppCloseAndReOpen_shouldNotCrash.

@Test
public void testRtlStability_AppCloseAndReOpen_shouldNotCrash() throws Exception {
    final UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    uiDevice.pressHome();
    // Open the settings app
    startSettingsMainActivity(uiDevice);
    // Press home button
    uiDevice.pressHome();
    final String launcherPackage = uiDevice.getLauncherPackageName();
    uiDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), TIME_OUT);
    // Open the settings again
    startSettingsMainActivity(uiDevice);
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 24 with UiDevice

use of android.support.test.uiautomator.UiDevice in project kiwix-android by kiwix.

the class TestUtils method allowPermissionsIfNeeded.

public static void allowPermissionsIfNeeded() {
    if (Build.VERSION.SDK_INT >= 23 && !hasStoragePermission()) {
        UiDevice device = UiDevice.getInstance(getInstrumentation());
        UiObject allowPermissions = device.findObject(new UiSelector().clickable(true).checkable(false).index(1));
        if (allowPermissions.exists()) {
            try {
                allowPermissions.click();
            } catch (UiObjectNotFoundException e) {
            }
        }
    }
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) UiDevice(android.support.test.uiautomator.UiDevice) UiObjectNotFoundException(android.support.test.uiautomator.UiObjectNotFoundException)

Example 25 with UiDevice

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

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

UiDevice (android.support.test.uiautomator.UiDevice)25 Test (org.junit.Test)8 Intent (android.content.Intent)6 SmallTest (android.support.test.filters.SmallTest)6 Context (android.content.Context)5 UiObject2 (android.support.test.uiautomator.UiObject2)5 DirectoryListBot (com.android.documentsui.bots.DirectoryListBot)5 RootsListBot (com.android.documentsui.bots.RootsListBot)5 UiObject (android.support.test.uiautomator.UiObject)4 UiSelector (android.support.test.uiautomator.UiSelector)4 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)3 Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 CancellationSignal (android.os.CancellationSignal)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 RemoteException (android.os.RemoteException)1 PrintAttributes (android.print.PrintAttributes)1 PrintDocumentAdapter (android.print.PrintDocumentAdapter)1 PrintJob (android.print.PrintJob)1 PrintManager (android.print.PrintManager)1