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 File: IntentTest.java From stitch with Apache License 2.0 | 5 votes |
@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 File: IntentTest.java From stitch with Apache License 2.0 | 5 votes |
@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 File: EspContactStubTest.java From espresso-macchiato with MIT License | 5 votes |
@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 File: EspContactStubTest.java From espresso-macchiato with MIT License | 5 votes |
@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 File: WebAuthProviderTest.java From Auth0.Android with MIT License | 5 votes |
@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 File: WebAuthProviderTest.java From Auth0.Android with MIT License | 5 votes |
@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 File: TestMainActivityWithEspresso.java From vb-android-app-quality with Apache License 2.0 | 5 votes |
@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 File: TestMainActivityWithEspresso.java From vb-android-app-quality with Apache License 2.0 | 5 votes |
@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 File: HomeActivityTest.java From kaif-android with Apache License 2.0 | 4 votes |
@Test public void showLoginActivity_if_not_signIn() { Mockito.when(accountDaemon.hasAccount()).thenReturn(false); activityRule.launchActivity(new Intent()); intended(IntentMatchers.hasComponent(LoginActivity.class.getName())); }