Search in sources :

Example 16 with UiDevice

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

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 17 with UiDevice

use of android.support.test.uiautomator.UiDevice in project SEProject by NicholasBarreyre.

the class RecordActivityUnitTests method recordWhileScreenIsLocked.

/**
 * Assert that recording continues when the device is locked.
 */
@Test
public void recordWhileScreenIsLocked() {
    onView(withId(R.id.record_button)).perform(click());
    UiDevice dev = UiDevice.getInstance(getInstrumentation());
    try {
        dev.sleep();
        Thread.sleep(2000);
        dev.wakeUp();
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    assertTrue(recordActivityTestRule.getActivity().getIsRecording());
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) RemoteException(android.os.RemoteException) Test(org.junit.Test)

Example 18 with UiDevice

use of android.support.test.uiautomator.UiDevice in project platform_frameworks_base by android.

the class Utils method waitForActivity.

private static UiObject2 waitForActivity(Instrumentation instrumentation, BySelector selector) {
    UiDevice device = UiDevice.getInstance(instrumentation);
    UiObject2 window = device.wait(Until.findObject(selector), WAIT_FOR_ACTIVITY_TIMEOUT);
    if (window == null) {
        throw new RuntimeException(selector.toString() + " has not been started.");
    }
    // Get root object.
    while (window.getParent() != null) {
        window = window.getParent();
    }
    return window;
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice) UiObject2(android.support.test.uiautomator.UiObject2)

Example 19 with UiDevice

use of android.support.test.uiautomator.UiDevice in project platform_frameworks_base by android.

the class Utils method rotateDevice.

public static void rotateDevice(Instrumentation instrumentation, int rotationMode) {
    try {
        UiDevice device = UiDevice.getInstance(instrumentation);
        long startTime = System.currentTimeMillis();
        switch(rotationMode) {
            case ROTATION_MODE_NATURAL:
                device.setOrientationNatural();
                break;
            case ROTATION_MODE_LEFT:
                device.setOrientationLeft();
                break;
            case ROTATION_MODE_RIGHT:
                device.setOrientationRight();
                break;
            default:
                throw new RuntimeException("Unsupported rotation mode: " + rotationMode);
        }
        long toSleep = ROTATION_ANIMATION_TIME_FULL_SCREEN_MS - (System.currentTimeMillis() - startTime);
        if (toSleep > 0) {
            SystemClock.sleep(toSleep);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : UiDevice(android.support.test.uiautomator.UiDevice)

Example 20 with UiDevice

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

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)

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