use of android.app.Instrumentation.ActivityResult in project platform_packages_apps_Settings by BlissRoms.
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());
}
use of android.app.Instrumentation.ActivityResult in project robolectric by robolectric.
the class LocalActivityInvoker method getActivityResult.
@Override
public ActivityResult getActivityResult() {
checkNotNull(controller);
checkState(controller.get().isFinishing(), "You must finish your Activity first");
ShadowActivity shadowActivity = Shadow.extract(controller.get());
return new ActivityResult(shadowActivity.getResultCode(), shadowActivity.getResultIntent());
}
use of android.app.Instrumentation.ActivityResult in project robolectric by robolectric.
the class IntentsTest method intending_callsOnActivityResult.
@Test
public void intending_callsOnActivityResult() {
intending(hasComponent(hasClassName(DummyActivity.class.getName()))).respondWith(new ActivityResult(Activity.RESULT_OK, new Intent().putExtra("key", 123)));
ActivityScenario<ResultCapturingActivity> activityScenario = ActivityScenario.launch(ResultCapturingActivity.class);
activityScenario.onActivity(activity -> activity.startActivityForResult(new Intent(activity, DummyActivity.class), 0));
activityScenario.onActivity(activity -> {
assertThat(activity.activityResult.getResultCode()).isEqualTo(Activity.RESULT_OK);
assertThat(activity.activityResult.getResultData()).extras().containsKey("key");
});
}
use of android.app.Instrumentation.ActivityResult in project android-testing by googlesamples.
the class ImageViewerActivityTest method createImageCaptureActivityResultStub.
private ActivityResult createImageCaptureActivityResultStub() {
// Put the drawable in a bundle.
Bundle bundle = new Bundle();
bundle.putParcelable(ImageViewerActivity.KEY_IMAGE_DATA, BitmapFactory.decodeResource(InstrumentationRegistry.getInstrumentation().getTargetContext().getResources(), R.drawable.ic_launcher));
// Create the Intent that will include the bundle.
Intent resultData = new Intent();
resultData.putExtras(bundle);
// Create the ActivityResult with the Intent.
return new ActivityResult(Activity.RESULT_OK, resultData);
}
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)));
}
Aggregations