Java 类android.support.test.espresso.intent.matcher.IntentMatchers 实例源码

项目:urlforwarder    文件:LinkDialogActivityTest.java   
@Test
public void shouldStartIntentWithCorrectUriWhenUriNotEncoded() throws UnsupportedEncodingException {
    createFilterTestRule.launchActivity(new Intent(Intent.ACTION_MAIN));

    String filterName = "MyTestFilter-" + UUID.randomUUID();

    clickAddFilter();
    setFilterData(filterName, "http://daverix.net/test/@uri", "@uri", "");
    closeSoftKeyboard();
    clickEncodeCheckbox();
    saveUsingIdlingResource(getApplication());

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, "http://example2.com");
    testRule.launchActivity(intent);

    onData(withLinkFilter(filterName)).perform(click());
    intended(allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW),
            IntentMatchers.hasData("http://daverix.net/test/http://example2.com")));
}
项目:iosched    文件:SessionDetailActivity_InScheduleStarredSessionTest.java   
@Test
public void speakerImage_WhenClicked_IntentFired() {
    Intent resultData = new Intent();
    resultData.putExtras(new Bundle());

    // Create the ActivityResult with the Intent.
    Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())).respondWith(
            new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData));

    // When clicking on speaker image
    onView(withId(R.id.session_detail_frag)).perform(swipeUp());
    onView(withId(R.id.speaker_image)).perform(click());

    // Then the intent to display the speaker url is fired
    Uri expectedSpeakerUri = Uri.parse(SpeakersMockCursor.FAKE_SPEAKER_URL);
    intended(CoreMatchers.allOf(
            hasAction(IsEqual.equalTo(Intent.ACTION_VIEW)),
            hasData(expectedSpeakerUri)));
}
项目:iosched    文件:SessionDetailActivity_EndedLiveStarredSessionTest.java   
@Test
public void youTubeVideo_WhenClicked_IntentFired() {
    Intent resultData = new Intent();
    resultData.putExtras(new Bundle());

    // Create the ActivityResult with the Intent.
    Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())).respondWith(
            new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData));

    // When clicking on video
    onView(withId(R.id.watch)).perform(click());

    // Then the intent to play the video is fired
    IntentUtils.checkVideoIntentIsFired(SessionsMockCursor.FAKE_YOUTUBE_URL,
            mActivityRule.getActivity(), false);
}
项目:espresso-macchiato    文件:EspContactStubTest.java   
@Test
public void testContactPickerStubWithExtraMatcher() {
    Uri dummyContactDataUri = ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, CONTACT_ID);
    EspContactStub.register(dummyContactDataUri, Activity.RESULT_OK, IntentMatchers.hasExtraWithKey("MyKey"));

    Intent contactPickerIntent = createContactPickerIntent();
    contactPickerIntent.putExtra("MyKey", "myValue");
    activity.startForResult(contactPickerIntent, REQUEST_CODE);

    requestCodeTextView.assertTextIs(String.valueOf(REQUEST_CODE));
    resultCodeTextView.assertTextIs(String.valueOf(Activity.RESULT_OK));
    dataTextView.assertTextIs(dummyContactDataUri.toString());
}
项目:espresso-macchiato    文件:EspContactStubTest.java   
@Test
@Ignore("result will be delivered in tear down, after all checks are done")
public void testWhenNotMatchingExtraMatcher() {
    Uri dummyContactDataUri = ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, CONTACT_ID);
    EspContactStub.register(dummyContactDataUri, Activity.RESULT_OK, IntentMatchers.hasExtraWithKey("MyKey"));

    activity.startForResult(createContactPickerIntent(), REQUEST_CODE);

    requestCodeTextView.assertTextIs("");
    resultCodeTextView.assertTextIs("");
    dataTextView.assertTextIs("");
}
项目:RecipeFinderJavaVersion    文件:RecipeAnalysisFragmentTest.java   
@Test
public void testRecipeAnalysis() {
    when(repository.getRecipeAnalysisData(ArgumentMatchers.<RecipeAnalysisParams>any()))
            .thenReturn(Single.just(AssetUtils.getRecipeAnalysisResult(context)));

    rule.launchActivity(new Intent());

    selectTab();
    inputFields();

    onView(withId(R.id.btn_analyze)).perform(click());
    Intents.intended(IntentMatchers.hasComponent(RecipeAnalysisDetailsActivity.class.getName()));
}
项目:vb-android-app-quality    文件:TestMainActivityWithEspresso.java   
@Override
protected boolean checkShareWentOK() {
    intended(allOf(
            hasAction(Intent.ACTION_SEND),
            IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))));
    return true;
}
项目:vb-android-app-quality    文件:TestMainActivityWithEspresso.java   
@Override
public void testThatDefaultBehaviorIsWorking() throws Exception {
    Instrumentation.ActivityResult dummyResult = new Instrumentation.ActivityResult(0, null);
    Intents.intending(allOf(
            hasAction(Intent.ACTION_SEND),
            IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))))
            .respondWith(dummyResult);
    super.testThatDefaultBehaviorIsWorking();
}
项目:kaif-android    文件:HomeActivityTest.java   
@Test
public void showLoginActivity_if_not_signIn() {
  Mockito.when(accountDaemon.hasAccount()).thenReturn(false);
  activityRule.launchActivity(new Intent());
  intended(IntentMatchers.hasComponent(LoginActivity.class.getName()));
}