Search in sources :

Example 81 with UiSelector

use of android.support.test.uiautomator.UiSelector 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");
        }
    }
}
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 82 with UiSelector

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

the class DefaultAppSettingsTest method testSelectDefaultHome_shouldLaunchHomePicker.

@Test
public void testSelectDefaultHome_shouldLaunchHomePicker() throws Exception {
    launchDefaultApps();
    final String titleHomeApp = mTargetContext.getResources().getString(R.string.home_app);
    mDevice.findObject(new UiSelector().text(titleHomeApp)).click();
    final UiObject actionBar = mDevice.findObject(new UiSelector().resourceId("com.android.settings:id/action_bar"));
    final UiObject title = actionBar.getChild(new UiSelector().className(TextView.class.getName()));
    assertEquals(titleHomeApp, title.getText());
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) SmallTest(android.support.test.filters.SmallTest) Test(org.junit.Test)

Example 83 with UiSelector

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

the class ChooseLockGenericTest method clearPassword.

/**
 * Clears the previous set PIN password.
 */
private void clearPassword() throws Exception {
    Intent newPasswordIntent = new Intent(getTargetContext(), ChooseLockGeneric.class).putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    getInstrumentation().getContext().startActivity(newPasswordIntent);
    mDevice.waitForIdle();
    // Enter current PIN
    UiObject view = new UiObject(new UiSelector().resourceId(mSettingPackage + ":id/password_entry"));
    if (!view.waitForExists(TIMEOUT)) {
        // Odd, maybe there is a crash dialog showing; try dismissing it
        mDevice.pressBack();
        mDevice.waitForIdle();
        assertTrue("password_entry", view.waitForExists(TIMEOUT));
    }
    enterTestPin(view);
    mDevice.pressBack();
    assertThat(getTargetContext().getSystemService(KeyguardManager.class).isDeviceSecure()).isFalse();
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager)

Example 84 with UiSelector

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

the class ChooseLockGenericTest method setPassword.

/**
 * Sets a PIN password, 12345, for testing.
 */
private void setPassword() throws Exception {
    Intent newPasswordIntent = new Intent(getTargetContext(), ChooseLockGeneric.class).putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_NUMERIC).putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, "12345").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getInstrumentation().getContext().startActivity(newPasswordIntent);
    mDevice.waitForIdle();
    // Ignore any interstitial options
    UiObject view = new UiObject(new UiSelector().resourceId(mSettingPackage + ":id/encrypt_dont_require_password"));
    if (view.waitForExists(TIMEOUT)) {
        view.click();
        mDevice.waitForIdle();
    }
    // Set our PIN
    view = new UiObject(new UiSelector().resourceId(mSettingPackage + ":id/password_entry"));
    assertTrue("password_entry", view.waitForExists(TIMEOUT));
    // Enter it twice to confirm
    enterTestPin(view);
    enterTestPin(view);
    mDevice.pressBack();
    assertThat(getTargetContext().getSystemService(KeyguardManager.class).isDeviceSecure()).isTrue();
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) Intent(android.content.Intent) KeyguardManager(android.app.KeyguardManager)

Example 85 with UiSelector

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

the class UserSettingsTest method testEmergencyInfoNotExists.

@Test
public void testEmergencyInfoNotExists() throws Exception {
    launchUserSettings();
    UiObject emergencyInfoPreference = mDevice.findObject(new UiSelector().text(EMERGNENCY_INFO));
    assertFalse(emergencyInfoPreference.exists());
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) SmallTest(android.support.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

UiSelector (android.support.test.uiautomator.UiSelector)125 UiObject (android.support.test.uiautomator.UiObject)103 Test (org.junit.Test)46 UiScrollable (android.support.test.uiautomator.UiScrollable)29 Intent (android.content.Intent)26 SmallTest (android.support.test.filters.SmallTest)18 KeyguardManager (android.app.KeyguardManager)14 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)9 UiDevice (android.support.test.uiautomator.UiDevice)3 SmallTest (androidx.test.filters.SmallTest)3 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 Context (android.content.Context)2 BySelector (android.support.test.uiautomator.BySelector)2 UiObject2 (android.support.test.uiautomator.UiObject2)2 Activity (android.app.Activity)1 Preference (android.preference.Preference)1 ViewInteraction (android.support.test.espresso.ViewInteraction)1 MediumTest (android.support.test.filters.MediumTest)1 RadioButton (android.widget.RadioButton)1