Search in sources :

Example 51 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by crdroidandroid.

the class UiBot method findDialogOkButton.

public UiObject findDialogOkButton() {
    UiObject object = findObject("android:id/content", "android:id/button1");
    object.waitForExists(mTimeout);
    return object;
}
Also used : UiObject(android.support.test.uiautomator.UiObject)

Example 52 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by crdroidandroid.

the class UiBot method findDialogCancelButton.

public UiObject findDialogCancelButton() {
    UiObject object = findObject("android:id/content", "android:id/button2");
    object.waitForExists(mTimeout);
    return object;
}
Also used : UiObject(android.support.test.uiautomator.UiObject)

Example 53 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by crdroidandroid.

the class UiBot method assertSearchTextField.

public void assertSearchTextField(boolean isFocused, String query) throws UiObjectNotFoundException {
    UiObject textField = findSearchViewTextField();
    UiObject searchIcon = findSearchViewIcon();
    assertFalse(searchIcon.exists());
    assertTrue(textField.exists());
    assertEquals(isFocused, textField.isFocused());
    if (query != null) {
        assertEquals(query, textField.getText());
    }
}
Also used : UiObject(android.support.test.uiautomator.UiObject)

Example 54 with UiObject

use of android.support.test.uiautomator.UiObject 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 55 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by crdroidandroid.

the class BugreportReceiverTest method bugreportFinishedWithWarningTest.

private void bugreportFinishedWithWarningTest(Integer propertyState) throws Exception {
    if (propertyState == null) {
        // Clear properties
        mContext.getSharedPreferences(PREFS_BUGREPORT, Context.MODE_PRIVATE).edit().clear().commit();
        // Sanity check...
        assertEquals("Did not reset properties", STATE_UNKNOWN, getWarningState(mContext, STATE_UNKNOWN));
    } else {
        setWarningState(mContext, propertyState);
    }
    // Send notification and click on share.
    sendBugreportFinished(NO_ID, mPlainTextPath, null);
    acceptBugreport(NO_ID);
    // Handle the warning
    mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm));
    // TODO: get ok and dontShowAgain from the dialog reference above
    UiObject dontShowAgain = mUiBot.getVisibleObject(mContext.getString(R.string.bugreport_confirm_dont_repeat));
    final boolean firstTime = propertyState == null || propertyState == STATE_UNKNOWN;
    if (firstTime) {
        if (Build.TYPE.equals("user")) {
            assertFalse("Checkbox should NOT be checked by default on user builds", dontShowAgain.isChecked());
            mUiBot.click(dontShowAgain, "dont-show-again");
        } else {
            assertTrue("Checkbox should be checked by default on build type " + Build.TYPE, dontShowAgain.isChecked());
        }
    } else {
        assertFalse("Checkbox should not be checked", dontShowAgain.isChecked());
        mUiBot.click(dontShowAgain, "dont-show-again");
    }
    UiObject ok = mUiBot.getVisibleObject(mContext.getString(com.android.internal.R.string.ok));
    mUiBot.click(ok, "ok");
    // Share the bugreport.
    mUiBot.chooseActivity(UI_NAME);
    Bundle extras = mListener.getExtras();
    assertActionSendMultiple(extras, BUGREPORT_CONTENT, NO_SCREENSHOT);
    // Make sure it's hidden now.
    int newState = getWarningState(mContext, STATE_UNKNOWN);
    assertEquals("Didn't change state", STATE_HIDE, newState);
}
Also used : UiObject(android.support.test.uiautomator.UiObject) Bundle(android.os.Bundle)

Aggregations

UiObject (android.support.test.uiautomator.UiObject)140 UiSelector (android.support.test.uiautomator.UiSelector)44 UiScrollable (android.support.test.uiautomator.UiScrollable)13 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)7 DownloadManager (android.app.DownloadManager)5 Request (android.app.DownloadManager.Request)5 Bundle (android.os.Bundle)5 Suppress (android.test.suitebuilder.annotation.Suppress)5 NumberFormat (java.text.NumberFormat)5 Test (org.junit.Test)3 MediumTest (android.support.test.filters.MediumTest)2 UiDevice (android.support.test.uiautomator.UiDevice)2 RelativeLayout (android.widget.RelativeLayout)1