use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by DirtyUnicorns.
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;
}
use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by ResurrectionRemix.
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;
}
use of android.support.test.uiautomator.UiDevice in project coins-android by bubelov.
the class MainActivityTest method allowPermissionsIfNeeded.
private void allowPermissionsIfNeeded() {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject allowPermissions = device.findObject(new UiSelector().text("ALLOW"));
if (allowPermissions.exists()) {
try {
allowPermissions.click();
} catch (UiObjectNotFoundException e) {
Timber.e(e, "Couldn't find dialog");
}
}
}
use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by crdroidandroid.
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;
}
use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by crdroidandroid.
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);
}
}
Aggregations