当前位置: 首页>>代码示例>>Java>>正文


Java ViewMatchers类代码示例

本文整理汇总了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));
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:26,代码来源:NumberPadTimePickerDialogTest.java

示例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());
}
 
开发者ID:vincetreur,项目名称:Ristretto,代码行数:20,代码来源:OnViewAllOfWithIsDisplayedNoImport.java

示例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);
        }
    };
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:22,代码来源:EspressoUtils.java

示例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(""))));

}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:17,代码来源:MainActivityTest.java

示例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);
}
 
开发者ID:blipinsk,项目名称:cortado,代码行数:25,代码来源:Cortado_Tests.java

示例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")));
}
 
开发者ID:sumio,项目名称:RxJavaEspressoSample,代码行数:11,代码来源:ActivityCountingIdlingResourceTest.java

示例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;
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:12,代码来源:PropertyActivityManager.java

示例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));
}
 
开发者ID:blipinsk,项目名称:cortado,代码行数:12,代码来源:NotCompletable_Tests.java

示例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);
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:14,代码来源:ExamsFragmentInstrumentedTest.java

示例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());
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:10,代码来源:SharedPreferencesReadWriteTest.java

示例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)));
}
 
开发者ID:brunogabriel,项目名称:TestCoverageReport-Android,代码行数:10,代码来源:MainActivityInstrumentalTest.java

示例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")));
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:14,代码来源:UserAccountInstrumentedTest.java

示例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));
}
 
开发者ID:blipinsk,项目名称:cortado,代码行数:12,代码来源:NotCompletable_Tests.java

示例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();
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:12,代码来源:SharedPreferencesReadWriteTest.java

示例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());
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:11,代码来源:SharedPreferencesReadWriteTest.java


注:本文中的android.support.test.espresso.matcher.ViewMatchers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。