android.support.test.espresso.intent.matcher.IntentMatchers Java Examples

The following examples show how to use android.support.test.espresso.intent.matcher.IntentMatchers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: stitch   Author: bambootang   File: IntentTest.java    License: Apache License 2.0 5 votes vote down vote up
@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)));
}
 
Example #2
Source Project: stitch   Author: bambootang   File: IntentTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void cleanTopFlag() {

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

    //测试是否对应的Intent被发送
    intended(allOf(
            hasComponent(hasShortClassName(".intenttest.IntentTestActivity")),
            IntentMatchers.hasFlag(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
}
 
Example #3
Source Project: espresso-macchiato   Author: nenick   File: EspContactStubTest.java    License: MIT License 5 votes vote down vote up
@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());
}
 
Example #4
Source Project: espresso-macchiato   Author: nenick   File: EspContactStubTest.java    License: MIT License 5 votes vote down vote up
@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("");
}
 
Example #5
Source Project: Auth0.Android   Author: auth0   File: WebAuthProviderTest.java    License: MIT License 5 votes vote down vote up
@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));
}
 
Example #6
Source Project: Auth0.Android   Author: auth0   File: WebAuthProviderTest.java    License: MIT License 5 votes vote down vote up
@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));
}
 
Example #7
Source Project: vb-android-app-quality   Author: vincentbrison   File: TestMainActivityWithEspresso.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkShareWentOK() {
    intended(allOf(
            hasAction(Intent.ACTION_SEND),
            IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))));
    return true;
}
 
Example #8
Source Project: vb-android-app-quality   Author: vincentbrison   File: TestMainActivityWithEspresso.java    License: Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #9
Source Project: kaif-android   Author: kaif-open   File: HomeActivityTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void showLoginActivity_if_not_signIn() {
  Mockito.when(accountDaemon.hasAccount()).thenReturn(false);
  activityRule.launchActivity(new Intent());
  intended(IntentMatchers.hasComponent(LoginActivity.class.getName()));
}