Search in sources :

Example 56 with UiSelector

use of android.support.test.uiautomator.UiSelector in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 57 with UiSelector

use of android.support.test.uiautomator.UiSelector in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetupChooseLockGenericTest method clickSkipFigerprintPreference_deviceNotProvisioned_shouldBeAbleToProceed.

@Test
public void clickSkipFigerprintPreference_deviceNotProvisioned_shouldBeAbleToProceed() throws Throwable {
    final Intent newPasswordIntent = new Intent(getTargetContext(), SetupChooseLockGeneric.class).putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true).setAction(ACTION_SET_NEW_PASSWORD).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    getInstrumentation().getContext().startActivity(newPasswordIntent);
    mDevice.waitForIdle();
    mDevice.findObject(new UiSelector().textContains("Continue without ")).click();
    final Activity activity = getCurrentActivity();
    assertThat(activity).isInstanceOf(SetupChooseLockGeneric.InternalActivity.class);
}
Also used : UiSelector(android.support.test.uiautomator.UiSelector) Activity(android.app.Activity) Intent(android.content.Intent) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 58 with UiSelector

use of android.support.test.uiautomator.UiSelector in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountsSettingsTest method launchAccountsSettings.

private void launchAccountsSettings() throws UiObjectNotFoundException {
    // launch settings
    Intent settingsIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setPackage(mTargetPackage).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(settingsIntent);
    // selects Accounts
    final UiScrollable settings = new UiScrollable(new UiSelector().packageName(mTargetPackage).scrollable(true));
    final String titleAccounts = ACCOUNTS;
    settings.scrollTextIntoView(titleAccounts);
    mDevice.findObject(new UiSelector().text(titleAccounts)).click();
}
Also used : UiSelector(android.support.test.uiautomator.UiSelector) Intent(android.content.Intent) UiScrollable(android.support.test.uiautomator.UiScrollable)

Example 59 with UiSelector

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

use of android.support.test.uiautomator.UiSelector in project cw-omnibus by commonsguy.

the class ListTests method openActivity.

private void openActivity() throws UiObjectNotFoundException {
    device.pressHome();
    UiObject allAppsButton = device.findObject(new UiSelector().description("Apps"));
    allAppsButton.clickAndWaitForNewWindow();
    UiObject appsTab = device.findObject(new UiSelector().text("Apps"));
    appsTab.click();
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.setAsHorizontalList();
    UiObject ourApp = appViews.getChildByText(new UiSelector().className("android.widget.TextView"), "Action Bar Fragment Demo");
    ourApp.clickAndWaitForNewWindow();
    UiObject appValidation = device.findObject(new UiSelector().packageName("com.commonsware.android.abf"));
    Assert.assertTrue("Could not open test app", appValidation.exists());
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) UiScrollable(android.support.test.uiautomator.UiScrollable)

Aggregations

UiSelector (android.support.test.uiautomator.UiSelector)124 UiObject (android.support.test.uiautomator.UiObject)104 Test (org.junit.Test)46 UiScrollable (android.support.test.uiautomator.UiScrollable)28 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)4 Context (android.content.Context)2 SmallTest (androidx.test.filters.SmallTest)2 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 Activity (android.app.Activity)1 Preference (android.preference.Preference)1 ViewInteraction (android.support.test.espresso.ViewInteraction)1 MediumTest (android.support.test.filters.MediumTest)1 BySelector (android.support.test.uiautomator.BySelector)1 UiCollection (android.support.test.uiautomator.UiCollection)1 UiObject2 (android.support.test.uiautomator.UiObject2)1