Java Code Examples for android.support.test.espresso.matcher.ViewMatchers#withText()
The following examples show how to use
android.support.test.espresso.matcher.ViewMatchers#withText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cortado_Tests.java From cortado with Apache License 2.0 | 6 votes |
@Test public void addMatcher_doesNotNegateMatcher_when_negateNextMatcher_isFalse() { 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 = false; cortado.addMatcher(viewMatcher); assertThat(cortado.matchers).hasSize(1); // one matcher added assertThat(cortado.negateNextMatcher).isFalse(); // negateNextMatcher is still false final Matcher<? super View> addedMatcher = cortado.matchers.get(0); Utils.assertThat(addedMatcher).isEqualTo(viewMatcher); Utils.assertThat(addedMatcher).isNotEqualTo(negatedViewMatcher); }
Example 2
Source File: Cortado_Tests.java From cortado with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: NumberPadTimePickerDialogTest.java From NumberPadTimePicker with Apache License 2.0 | 5 votes |
/** * Helper method that wraps {@link ViewMatchers#withText(String) withText(String)}. * * @return A Matcher that matches a number key button by its text representation * of {@code digit}. */ private static Matcher<View> withDigit(int digit) { // TODO: When we're comfortable with the APIs, we can statically import them and // make direct calls to these methods and cut down on the verbosity, instead of // writing helper methods that wrap these APIs. return ViewMatchers.withText(text(digit)); }