本文整理汇总了Java中android.support.test.espresso.matcher.ViewMatchers类的典型用法代码示例。如果您正苦于以下问题:Java ViewMatchers类的具体用法?Java ViewMatchers怎么用?Java ViewMatchers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewMatchers类属于android.support.test.espresso.matcher包,在下文中一共展示了ViewMatchers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyViewEnabledStates
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的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: fooMatchers
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
public void fooMatchers() {
Espresso.onView(Matchers.allOf(ViewMatchers.withId(R.id.some_id), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.withText(R.string.some_text), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.withText("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(RistrettoViewMatchers.with("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.withId(R.id.some_id), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.withText(R.string.some_text), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.withText("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(RistrettoViewMatchers.with("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withId(R.id.some_id))).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText(R.string.some_text))).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText("some text"))).perform(ViewAction.click());
Espresso.onView(Matchers.allOf(ViewMatchers.isDisplayed(), RistrettoViewMatchers.with("some text"))).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withId(R.id.some_id))).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText(R.string.some_text))).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText("some text"))).perform(ViewAction.click());
Ristretto.withView(Matchers.allOf(ViewMatchers.isDisplayed(), RistrettoViewMatchers.with("some text"))).perform(ViewAction.click());
}
示例3: setNumber
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
/**
* Set value for {@link NumberPicker}
*/
public static ViewAction setNumber(final int n) {
return new ViewAction() {
@Override
public void perform(UiController uiController, View view) {
((NumberPicker) view).setValue(n);
}
@Override
public String getDescription() {
return "Set NumberPicker value";
}
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(NumberPicker.class);
}
};
}
示例4: clickOnFirstItem_opensComments
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void clickOnFirstItem_opensComments() throws Throwable {
drain();
// When clicking on the first product
onView(ViewMatchers.withContentDescription(R.string.cd_products_list))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
drain();
// Then the second screen with the comments should appear.
onView(withContentDescription(R.string.cd_comments_list))
.check(matches(isDisplayed()));
drain();
// Then the second screen with the comments should appear.
onView(withContentDescription(R.string.cd_product_name))
.check(matches(not(withText(""))));
}
示例5: addMatcher_negatesMatcher_when_negateNextMatcher_isTrue
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void addMatcher_negatesMatcher_when_negateNextMatcher_isTrue() {
final Start.Matcher matcher = Cortado.view();
final Cortado cortado = matcher.getCortado();
assertThat(cortado.matchers).hasSize(0);
assertThat(cortado.negateNextMatcher).isFalse();
// no matchers added, negateNextMatcher is false
org.hamcrest.Matcher<View> viewMatcher = ViewMatchers.withText("test");
org.hamcrest.Matcher<View> negatedViewMatcher = Matchers.not(viewMatcher);
cortado.negateNextMatcher = true;
cortado.addMatcher(viewMatcher);
assertThat(cortado.matchers).hasSize(1);
// one matcher added
assertThat(cortado.negateNextMatcher).isFalse();
// negateNextMatcher is back to false
final Matcher<? super View> addedMatcher = cortado.matchers.get(0);
Utils.assertThat(addedMatcher).isNotEqualTo(viewMatcher);
Utils.assertThat(addedMatcher).isEqualTo(negatedViewMatcher);
}
示例6: test_wait_debounce
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void test_wait_debounce() {
onView(ViewMatchers.withId(R.id.button_debounce)).perform(click());
// In this case, CountingIdlingResource has no effect.
// Use UiDevice.wait() of UIAutomator instead.
uiDevice.wait(Until.hasObject(By.text("Debounce Completed")), 5000L);
onView(withId(R.id.text_debounce_result))
.check(matches(withText("Debounce Completed")));
}
示例7: createMap
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
protected static Map<String, Matcher<View>> createMap() {
Map<String, Matcher<View>> thisMap = new HashMap<String, Matcher<View>>();
thisMap.put("isClickable", ViewMatchers.isClickable());
thisMap.put("isDisplayed", ViewMatchers.isDisplayed());
thisMap.put("isEnabled", ViewMatchers.isEnabled());
thisMap.put("supportsInputMethods", ViewMatchers.supportsInputMethods());
thisMap.put("isSelected", ViewMatchers.isSelected());
return thisMap;
}
示例8: withTagKey_withMatcher_addsCorrectMatcher
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void withTagKey_withMatcher_addsCorrectMatcher() {
//given
org.hamcrest.Matcher<Object> testMatcher = SimpleMatcher.instance();
//when
notCompletable.withTagKey(1, testMatcher);
//then
assertExpectedAddedMatcher(ViewMatchers.withTagKey(1, testMatcher));
}
示例9: shouldClickOnExamButton
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void shouldClickOnExamButton(){
onView(withId(R.id.salas_item))
.perform(click());
onData(anything()).inAdapterView(withId(R.id.recycler))
.atPosition(0).perform(click());
onView(ViewMatchers.withText("EXAMS"))
.perform(click());
onView(withId(R.id.floating_btn)).perform(click());
assertNotNull(examRule);
}
示例10: testString
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void testString() {
ViewInteraction appCompatButton = onView(
allOf(withText("String"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton.perform(click());
}
示例11: shouldHideButtonAfterClick
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void shouldHideButtonAfterClick() {
// then
onView(withId(R.id.button_hide)).perform(click());
// when
onView(withId(R.id.button_hide)).
check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
}
示例12: shouldValidateNullEmailLogin
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void shouldValidateNullEmailLogin() throws UserException{
onView(ViewMatchers.withId(R.id.edit_text_email))
.perform(typeText(""));
closeSoftKeyboard();
onView(withId(R.id.edit_text_password))
.perform(typeText("Aluno1"));
closeSoftKeyboard();
onView(withId(R.id.button_login))
.perform(click());
onView(withId(R.id.edit_text_email)).check(matches(hasErrorText("O email não pode estar vazio")));
}
示例13: hasSibling_addsCorrectMatcher
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void hasSibling_addsCorrectMatcher() {
//given
org.hamcrest.Matcher<View> testMatcher = SimpleMatcher.instance();
//when
notCompletable.hasSibling(testMatcher);
//then
assertExpectedAddedMatcher(ViewMatchers.hasSibling(testMatcher));
}
示例14: testFloat
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void testFloat() {
ViewInteraction appCompatButton5 = onView(
allOf(withText("Float"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton5.perform();
}
示例15: testBoolean
import android.support.test.espresso.matcher.ViewMatchers; //导入依赖的package包/类
@Test
public void testBoolean() {
ViewInteraction appCompatButton6 = onView(
allOf(withText("Boolean"),
withParent(allOf(ViewMatchers.withId(R.id.activity_main),
withParent(withId(android.R.id.content)))),
isDisplayed()));
appCompatButton6.perform(click());
}