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);
}
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);
}
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);
}
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) {
}
}
}
}
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());
}
Aggregations