use of android.app.Instrumentation.ActivityResult in project android-testing by googlesamples.
the class DialerActivityTest method pickContactButton_click_SelectsPhoneNumber.
@Test
public void pickContactButton_click_SelectsPhoneNumber() {
// Stub all Intents to ContactsActivity to return VALID_PHONE_NUMBER. Note that the Activity
// is never launched and result is stubbed.
intending(hasComponent(hasShortClassName(".ContactsActivity"))).respondWith(new ActivityResult(Activity.RESULT_OK, ContactsActivity.createResultData(VALID_PHONE_NUMBER)));
// Click the pick contact button.
onView(withId(R.id.button_pick_contact)).perform(click());
// Check that the number is displayed in the UI.
onView(withId(R.id.edit_text_caller_number)).check(matches(withText(VALID_PHONE_NUMBER)));
}
use of android.app.Instrumentation.ActivityResult in project collect by opendatakit.
the class AllWidgetsFormTest method testExIntegerWidget.
public void testExIntegerWidget() {
// Manually input the value:
String exIntegerFirstValue = randomIntegerString();
when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(false);
onView(withText("Launch")).perform(click());
onVisibleEditText().perform(replaceText(exIntegerFirstValue));
Screengrab.screenshot("ex-integer");
openWidgetList();
onView(withText("Ex integer widget")).perform(click());
onVisibleEditText().check(matches(withText(exIntegerFirstValue)));
// Replace with Intent value:
String exIntegerSecondValue = randomIntegerString();
Intent stringIntent = new Intent();
stringIntent.putExtra("value", Integer.parseInt(exIntegerSecondValue));
ActivityResult exStringResult = new ActivityResult(RESULT_OK, stringIntent);
intending(allOf(hasAction("change.uw.android.BREATHCOUNT"), hasExtra("value", Integer.parseInt(exIntegerFirstValue)))).respondWith(exStringResult);
when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(true);
onView(withText("Launch")).perform(click());
onView(withText(exIntegerSecondValue)).check(matches(isDisplayed()));
Screengrab.screenshot("ex-integer2");
openWidgetList();
onView(withText("Ex integer widget")).perform(click());
onVisibleEditText().check(matches(withText(exIntegerSecondValue)));
onView(withText("Ex integer widget")).perform(swipeLeft());
}
use of android.app.Instrumentation.ActivityResult in project collect by opendatakit.
the class AllWidgetsFormTest method testExDecimalWidget.
public void testExDecimalWidget() {
// Manually input the value:
String exDecimalFirstValue = randomDecimalString();
when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(false);
onView(withText("Launch")).perform(click());
onVisibleEditText().perform(replaceText(exDecimalFirstValue));
Screengrab.screenshot("ex-decimal");
openWidgetList();
onView(withText("Ex decimal widget")).perform(click());
onVisibleEditText().check(matches(withText(exDecimalFirstValue)));
// Replace with Intent value:
String exDecimalSecondValue = randomDecimalString();
Intent stringIntent = new Intent();
stringIntent.putExtra("value", Double.parseDouble(exDecimalSecondValue));
ActivityResult exStringResult = new ActivityResult(RESULT_OK, stringIntent);
intending(allOf(hasAction("change.uw.android.BREATHCOUNT"), hasExtra("value", Double.parseDouble(exDecimalFirstValue)))).respondWith(exStringResult);
when(activityAvailability.isActivityAvailable(any(Intent.class))).thenReturn(true);
onView(withText("Launch")).perform(click());
onView(withText(exDecimalSecondValue)).check(matches(isDisplayed()));
Screengrab.screenshot("ex-decimal2");
openWidgetList();
onView(withText("Ex decimal widget")).perform(click());
onVisibleEditText().check(matches(withText(exDecimalSecondValue)));
onView(withText("Ex decimal widget")).perform(swipeLeft());
}
use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by LineageOS.
the class FingerprintEnrollFinishTest method clickAddAnother_shouldLaunchEnrolling.
@Test
public void clickAddAnother_shouldLaunchEnrolling() {
final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_CANCELED, null));
onView(withId(R.id.add_another_button)).perform(click());
intended(hasComponent(enrollingComponent));
assertFalse(mActivityRule.getActivity().isFinishing());
}
use of android.app.Instrumentation.ActivityResult in project android_packages_apps_Settings by LineageOS.
the class FingerprintEnrollFinishTest method clickAddAnother_shouldPropagateResults.
@Test
public void clickAddAnother_shouldPropagateResults() {
final ComponentName enrollingComponent = new ComponentName(getTargetContext(), FingerprintEnrollEnrolling.class);
intending(hasComponent(enrollingComponent)).respondWith(new ActivityResult(Activity.RESULT_OK, null));
onView(withId(R.id.add_another_button)).perform(click());
intended(hasComponent(enrollingComponent));
assertTrue(mActivityRule.getActivity().isFinishing());
}
Aggregations