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

下面列出了怎么用android.support.test.espresso.intent.matcher.IntentMatchers的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: stitch   文件: IntentTest.java
@Test
public void cleanTaskFlag() {

    onView(withText("ClearTask")).perform(ViewActions.click());

    //测试是否对应的Intent被发送
    intended(allOf(
            IntentMatchers.hasAction("hhhh"),
            hasComponent(hasShortClassName(".intenttest.IntentTestActivity")),
            IntentMatchers.hasFlag(Intent.FLAG_ACTIVITY_CLEAR_TASK)));
}
 
源代码2 项目: stitch   文件: IntentTest.java
@Test
public void cleanTopFlag() {

    onView(withText("ClearTop")).perform(ViewActions.click());

    //测试是否对应的Intent被发送
    intended(allOf(
            hasComponent(hasShortClassName(".intenttest.IntentTestActivity")),
            IntentMatchers.hasFlag(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
 
源代码3 项目: 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());
}
 
源代码4 项目: 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("");
}
 
源代码5 项目: Auth0.Android   文件: WebAuthProviderTest.java
@Test
public void shouldHaveBrowserAppInstalled() {
    ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
    prepareBrowserApp(true, intentCaptor);

    boolean hasBrowserApp = WebAuthProvider.hasBrowserAppInstalled(activity.getPackageManager());
    MatcherAssert.assertThat(hasBrowserApp, Is.is(true));
    MatcherAssert.assertThat(intentCaptor.getValue(), Is.is(IntentMatchers.hasAction(Intent.ACTION_VIEW)));
    MatcherAssert.assertThat(URLUtil.isValidUrl(intentCaptor.getValue().getDataString()), Is.is(true));
}
 
源代码6 项目: Auth0.Android   文件: WebAuthProviderTest.java
@Test
public void shouldNotHaveBrowserAppInstalled() {
    ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
    prepareBrowserApp(false, intentCaptor);

    boolean hasBrowserApp = WebAuthProvider.hasBrowserAppInstalled(activity.getPackageManager());
    MatcherAssert.assertThat(hasBrowserApp, Is.is(false));
    MatcherAssert.assertThat(intentCaptor.getValue(), Is.is(IntentMatchers.hasAction(Intent.ACTION_VIEW)));
    MatcherAssert.assertThat(URLUtil.isValidUrl(intentCaptor.getValue().getDataString()), Is.is(true));
}
 
@Override
protected boolean checkShareWentOK() {
    intended(allOf(
            hasAction(Intent.ACTION_SEND),
            IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))));
    return true;
}
 
@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();
}
 
源代码9 项目: 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()));
}
 
 类所在包
 同包方法