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