本文整理汇总了Java中android.support.test.espresso.intent.matcher.IntentMatchers类的典型用法代码示例。如果您正苦于以下问题:Java IntentMatchers类的具体用法?Java IntentMatchers怎么用?Java IntentMatchers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntentMatchers类属于android.support.test.espresso.intent.matcher包,在下文中一共展示了IntentMatchers类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldStartIntentWithCorrectUri
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@Test
public void shouldStartIntentWithCorrectUri() throws UnsupportedEncodingException {
createFilterTestRule.launchActivity(new Intent(Intent.ACTION_MAIN));
String filterName = "MyTestFilter-" + UUID.randomUUID();
clickAddFilter();
setFilterData(filterName, "http://daverix.net/[email protected]&[email protected]", "@uri", "@subject");
saveUsingIdlingResource(getApplication());
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "http://example.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Example");
testRule.launchActivity(intent);
onData(withLinkFilter(filterName)).perform(click());
intended(allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW),
IntentMatchers.hasData("http://daverix.net/test.php?url=" + URLEncoder.encode("http://example.com", "UTF-8") + "&subject=Example")));
}
示例2: shouldStartIntentWithCorrectUriWhenUriNotEncoded
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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")));
}
示例3: speakerImage_WhenClicked_IntentFired
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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)));
}
示例4: youTubeVideo_WhenClicked_IntentFired
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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);
}
示例5: testContactPickerStubWithExtraMatcher
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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());
}
示例6: testWhenNotMatchingExtraMatcher
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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("");
}
示例7: testRecipeAnalysis
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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()));
}
示例8: checkShareWentOK
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@Override
protected boolean checkShareWentOK() {
intended(allOf(
hasAction(Intent.ACTION_SEND),
IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, mActivityRule.getActivity().getString(R.string.share_title))));
return true;
}
示例9: testThatDefaultBehaviorIsWorking
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@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();
}
示例10: showLoginActivity_if_not_signIn
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
@Test
public void showLoginActivity_if_not_signIn() {
Mockito.when(accountDaemon.hasAccount()).thenReturn(false);
activityRule.launchActivity(new Intent());
intended(IntentMatchers.hasComponent(LoginActivity.class.getName()));
}
示例11: shouldLoginWithSkip
import android.support.test.espresso.intent.matcher.IntentMatchers; //导入依赖的package包/类
public void shouldLoginWithSkip() {
onView(withId(R.id.emailEditText)).check(matches(isDisplayed()));
onView(withId(R.id.passwordEditText)).perform(typeText("[email protected]"));
onView(withId(R.id.signupButton)).perform(click());
Intents.intended(IntentMatchers.hasComponent(MainActivity.class.getName()));
}