本文整理匯總了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;
}