本文整理汇总了Java中android.support.test.espresso.Espresso.onView方法的典型用法代码示例。如果您正苦于以下问题:Java Espresso.onView方法的具体用法?Java Espresso.onView怎么用?Java Espresso.onView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.test.espresso.Espresso
的用法示例。
在下文中一共展示了Espresso.onView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyViewEnabledStates
import android.support.test.espresso.Espresso; //导入方法依赖的package包/类
private static void verifyViewEnabledStates(TestCase test) {
ViewInteraction[] buttonsInteractions = getButtonInteractions();
ViewInteraction[] altButtonsInteractions = getAltButtonInteractions();
for (int digit : test.sequence) {
buttonsInteractions[digit]
.check(ViewAssertions.matches(ViewMatchers.isEnabled()))
.perform(ViewActions.click());
}
for (int i = 0; i < 10; i++) {
buttonsInteractions[i].check(matchesIsEnabled(
i >= test.numberKeysEnabledStart && i < test.numberKeysEnabledEnd));
altButtonsInteractions[0].check(matchesIsEnabled(test.leftAltKeyEnabled));
altButtonsInteractions[1].check(matchesIsEnabled(test.rightAltKeyEnabled));
}
Espresso.onView(ViewMatchers.withText(android.R.string.ok))
.check(matchesIsEnabled(test.okButtonEnabled));
ViewInteraction backspaceInteraction = Espresso.onView(
ViewMatchers.withId(R.id.nptp_backspace));
// Reset after each iteration by backspacing on the button just clicked.
backspaceInteraction.check(matchesIsEnabled(true))
.perform(ViewActions.longClick())
.check(matchesIsEnabled(false));
}
示例2: getButtonInteractions
import android.support.test.espresso.Espresso; //导入方法依赖的package包/类
private static ViewInteraction[] getButtonInteractions() {
ViewInteraction[] buttonsInteractions = new ViewInteraction[10];
// We cannot rely on the withDigit() matcher to retrieve these because,
// after performing a click on a button, the time display will update to
// take on that button's digit text, and so withDigit() will return a matcher
// that matches multiple views with that digit text: the button
// itself and the time display. This will prevent us from performing
// validation on the same ViewInteractions later.
buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text10));
buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text0));
buttonsInteractions[2] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text1));
buttonsInteractions[3] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text2));
buttonsInteractions[4] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text3));
buttonsInteractions[5] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text4));
buttonsInteractions[6] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text5));
buttonsInteractions[7] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text6));
buttonsInteractions[8] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text7));
buttonsInteractions[9] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text8));
return buttonsInteractions;
}
示例3: init
import android.support.test.espresso.Espresso; //导入方法依赖的package包/类
@Before
public void init() {
if (CameraUtils.isCameraAvailable(InstrumentationRegistry.getTargetContext())) {
mCameraFragmentTestRule.launchActivity(null);
} else {
try {
mCameraFragmentTestRule.launchActivity(null);
fail("Should not initialize this ImageClassifierFragment if camera not there.");
} catch (IllegalArgumentException e) {
//Success
}
}
//Wait for 1200 ms.
//Wait for the camera to get stable
Delay.startDelay(1200);
Delay.stopDelay();
Espresso.onView(withId(R.id.container));
mImageClassifierFragment = mCameraFragmentTestRule.getFragment();
}
示例4: getAltButtonInteractions
import android.support.test.espresso.Espresso; //导入方法依赖的package包/类
private static ViewInteraction[] getAltButtonInteractions() {
ViewInteraction[] buttonsInteractions = new ViewInteraction[2];
buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text9));
buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text11));
return buttonsInteractions;
}