use of android.support.test.uiautomator.UiDevice in project android by nextcloud.
the class InitialTest method clickByText.
/**
* Helper to click on object that match the text value.
*
* @param text the text
* @throws UiObjectNotFoundException
*/
private void clickByText(String text) throws UiObjectNotFoundException {
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
UiObject obj = device.findObject(new UiSelector().text(text));
obj.clickAndWaitForNewWindow();
}
use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by crdroidandroid.
the class FilesJankPerfTest method setUpInLoop.
public void setUpInLoop() {
final UiDevice device = UiDevice.getInstance(getInstrumentation());
final Context context = getInstrumentation().getTargetContext();
mRootsListBot = new RootsListBot(device, context, BOT_TIMEOUT);
mDirListBot = new DirectoryListBot(device, context, BOT_TIMEOUT);
final Intent intent = new Intent(context, FilesActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity = getInstrumentation().startActivitySync(intent);
}
use of android.support.test.uiautomator.UiDevice in project android_frameworks_base by AOSPA.
the class FilesJankPerfTest method setUpInLoop.
public void setUpInLoop() {
final UiDevice device = UiDevice.getInstance(getInstrumentation());
final Context context = getInstrumentation().getTargetContext();
mRootsListBot = new RootsListBot(device, context, BOT_TIMEOUT);
mDirListBot = new DirectoryListBot(device, context, BOT_TIMEOUT);
final Intent intent = new Intent(context, FilesActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity = getInstrumentation().startActivitySync(intent);
}
use of android.support.test.uiautomator.UiDevice in project android_packages_apps_Settings by crdroidandroid.
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);
}
use of android.support.test.uiautomator.UiDevice in project chefly_android by chef-ly.
the class PermissionGranter method allowPermissionsIfNeeded.
public static void allowPermissionsIfNeeded(String permissionNeeded) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !hasNeededPermission(permissionNeeded)) {
sleep(PERMISSIONS_DIALOG_DELAY);
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject allowPermissions = device.findObject(new UiSelector().clickable(true).checkable(false).index(GRANT_BUTTON_INDEX));
if (allowPermissions.exists()) {
allowPermissions.click();
}
}
} catch (UiObjectNotFoundException e) {
System.out.println("There is no permissions dialog to interact with");
}
}
Aggregations