當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。