本文整理汇总了Java中android.support.test.espresso.ViewInteraction.perform方法的典型用法代码示例。如果您正苦于以下问题:Java ViewInteraction.perform方法的具体用法?Java ViewInteraction.perform怎么用?Java ViewInteraction.perform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.test.espresso.ViewInteraction
的用法示例。
在下文中一共展示了ViewInteraction.perform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performChooseWeapons
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
public void performChooseWeapons() {
ViewInteraction button4 = onView(
allOf(withId(R.id.buttonAddweapon), withText("Add Weapon"),
childAtPosition(
withParent(withId(R.id.pager)),
1),
isDisplayed()));
button4.perform(click());
ViewInteraction button5 = onView(
allOf(withId(android.R.id.button1), withText("Ok"),
childAtPosition(
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
0),
2),
isDisplayed()));
button5.perform(click());
}
示例2: verifyMessageSentToMessageActivity
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void verifyMessageSentToMessageActivity() {
ViewInteraction appCompatTextView2 = onView(
allOf(withId(R.id.subtitle), withText("NEARBY"), isDisplayed()));
appCompatTextView2.perform(click());
// Types a message into a EditText element.
onView(withId(R.id.searchText))
.perform(typeText(MESSAGE), closeSoftKeyboard());
//onView(withId(R.id.submit)).perform(click());
// Verifies that the DisplayMessageActivity received an intent
// with the correct package name and message.
// Check that the text was changed.
onView(withId(R.id.subtitle))
.check(matches(withText(MESSAGE)));
}
示例3: deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding() throws Exception {
//arrange
//just adapt input items list to required start values
items.remove(1);
activity.runOnUiThread(() -> activity.initialize());
ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
InstrumentalUtil.waitForIdle();
View second = layoutManager.getChildAt(1);
int startHeight = second.getHeight();
double expectedY = second.getY();
//act
recyclerView.perform(
actionDelegate(((uiController, view) -> items.remove(1))),
notifyItemRemovedAction(1));
InstrumentalUtil.waitForIdle();
second = layoutManager.getChildAt(1);
int endHeight = second.getHeight();
double resultY = second.getY();
//assert
//check test behaviour
assumeTrue(startHeight > endHeight);
assertNotEquals(0, expectedY, 0.01);
assertNotEquals(0, resultY, 0.01);
assertEquals(resultY, expectedY, 0.01);
}
示例4: testSearchIsInvokedWhenSubmittingInSearchView
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testSearchIsInvokedWhenSubmittingInSearchView() {
CountDownLatch latch = new CountDownLatch(1);
app().mainActivitySubcomponent()
.withPermissionService(activity -> new PermissionServiceStub(activity, false))
.and().searchFragmentSubcomponent()
.withSearchViewModel(new SearchViewModelStubDelegate(latch));
rule.launchActivity(null);
this.allowPermissionsIfNeeded();
ViewInteraction viewPager = onView(allOf(withId(R.id.container), isDisplayed()));
viewPager.perform(swipeLeft());
ViewInteraction appCompatTextView = onView(allOf(withText("Search"), isDisplayed()));
appCompatTextView.perform(click());
ViewInteraction actionMenuItemView = onView(allOf(withId(R.id.action_search), isDisplayed()));
actionMenuItemView.perform(click());
ViewInteraction searchAutoComplete = onView(
allOf(withId(R.id.search_src_text),
withParent(allOf(withId(R.id.search_plate),
withParent(withId(R.id.search_edit_frame)))),
isDisplayed()));
searchAutoComplete.perform(replaceText("AAA"));
SystemClock.sleep(1500);
assertEquals(0, latch.getCount());
}
示例5: interceptorsFileTest
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void interceptorsFileTest() {
ViewInteraction buttonPost = onView(
allOf(withId(R.id.button_pdf), withText("FILE"), isDisplayed()));
buttonPost.perform(click());
buttonPost.check(matches(isDisplayed()));
}
示例6: testAvailableRewards
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testAvailableRewards() throws ParseException {
ViewInteraction appCompatImageButton =
onView(allOf(withContentDescription("Open navigation profile"), withParent(
allOf(withId(R.id.toolbar), withParent(withId(R.id.bar_layout)))),
isDisplayed()));
appCompatImageButton.perform(click());
ViewInteraction appCompatCheckedTextView =
onView(allOf(withId(R.id.design_menu_item_text), withText("Rewards"),
isDisplayed()));
appCompatCheckedTextView.perform(click());
pressBack();
}
示例7: testActivityRun
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testActivityRun() {
calculatorActivity.launchActivity(new Intent());
ViewInteraction calculateButton = onView(withId(R.id.calculate_button));
calculateButton.check(matches(isDisplayed()));
calculateButton.check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
if(view.isEnabled()) {
throw new IllegalStateException("button enabled");
}
}
});
onView(withId(R.id.input_field_edit_text)).perform(typeText("1+2"));
calculateButton.check(matches(isEnabled()));
calculateButton.perform(click());
/*onView(withId(R.id.result_text_view)).check(new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
if(!((TextView)view).getText().toString().equals("3")) {
throw new IllegalStateException("result wrong. Aspected 3");
}
}
});*/
}
示例8: testMissing
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testMissing() {
ViewInteraction appCompatButton10 = onView(
allOf(withText("missing"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton10.perform(click());
}
示例9: devModeEasterEggOffWorking
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@SuppressLint("ApplySharedPref")
@Test
public void devModeEasterEggOffWorking() {
Context appContext = InstrumentationRegistry.getTargetContext();
ViewInteraction interact = onView(withId(R.id.btn_about_advancedmode_easteregg));
PreferenceUtil.getSharedPreferences(appContext).edit().putBoolean(appContext.getString(R.string.pref_advanced_mode_bool), true).commit();
InstrumentationRegistry.getInstrumentation().startActivitySync(new Intent(appContext, AboutActivity.class));
interact.perform(click());
Assert.assertThat(PreferenceUtil.getDeveloperModePreference(appContext), is(false));
}
示例10: devModeEasterEggOnWorking
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@SuppressLint("ApplySharedPref")
@Test
public void devModeEasterEggOnWorking() {
Context appContext = InstrumentationRegistry.getTargetContext();
ViewInteraction interact = onView(withId(R.id.btn_about_advancedmode_easteregg));
PreferenceUtil.getSharedPreferences(appContext).edit().putBoolean(appContext.getString(R.string.pref_advanced_mode_bool), false).commit();
InstrumentationRegistry.getInstrumentation().startActivitySync(new Intent(appContext, AboutActivity.class));
for (int i = 0; i < 8; i++)
interact.perform(click());
Assert.assertThat(PreferenceUtil.getDeveloperModePreference(appContext), is(true));
}
示例11: clickOnBuildListItem
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
private void clickOnBuildListItem(int position) {
ViewInteraction recyclerView = onView(
allOf(withId(R.id.build_list),
withParent(allOf(withId(R.id.pager),
withParent(withId(R.id.activity_main_root_view)))),
isDisplayed()));
recyclerView.perform(actionOnItemAtPosition(position, click()));
}
示例12: testInt
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testInt() {
ViewInteraction appCompatButton3 = onView(
allOf(withText("Int"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton3.perform(click());
}
示例13: itShouldShowWeatherForNextDay
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void itShouldShowWeatherForNextDay() throws IOException
{
doReturn(Observable.empty()).when(weatherApi).getCurrentWeather(anyDouble(), anyDouble());
doReturn(Observable.empty()).when(weatherApi).getTomorrowWeather(anyDouble(), anyDouble());
when(weatherApi.getForecastWeather(eq(FAKE_LONGITUDE), eq(FAKE_LATITUDE))).thenReturn(
Observable.just(fakeResponse(Responses.JSON.THREE_HOUR_FORECAST))
);
rule.launchActivity(null);
allowPermissionsIfNeeded();
ViewInteraction appCompatTextView = onView(
allOf(withText(R.string.tomorrow), isDisplayed()));
appCompatTextView.perform(click());
ViewInteraction appCompatImageView = onView(
allOf(withId(R.id.imageView), isDisplayed()));
appCompatImageView.perform(click());
final String threeHourForecastDataResult =
"2017-01-23 00:00:00: -11.55°C\n" +
"2017-01-23 03:00:00: -12.0°C\n" +
"2017-01-23 06:00:00: -12.15°C\n" +
"2017-01-23 09:00:00: -11.34°C\n" +
"2017-01-23 12:00:00: -8.84°C\n" +
"2017-01-23 15:00:00: -7.94°C\n" +
"2017-01-23 18:00:00: -9.35°C\n" +
"2017-01-23 21:00:00: -10.29°C\n";
ViewInteraction textView = onView(withId(R.id.textView));
textView.check(matches(withText(threeHourForecastDataResult)));
ViewInteraction textView2 = onView(withId(R.id.textView6));
textView2.check(matches(withText("Three Hour Forecast")));
}
示例14: interceptorsGetTest
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void interceptorsGetTest() {
ViewInteraction buttonPost = onView(
allOf(withId(R.id.button_get), withText("GET"), isDisplayed()));
buttonPost.perform(click());
buttonPost.check(matches(isDisplayed()));
}
示例15: testRegisterListener
import android.support.test.espresso.ViewInteraction; //导入方法依赖的package包/类
@Test
public void testRegisterListener() {
ViewInteraction appCompatButton8 = onView(
allOf(withText("registerListener"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton8.perform(click());
}