當前位置: 首頁>>代碼示例>>Java>>正文


Java Matcher.describeTo方法代碼示例

本文整理匯總了Java中org.hamcrest.Matcher.describeTo方法的典型用法代碼示例。如果您正苦於以下問題:Java Matcher.describeTo方法的具體用法?Java Matcher.describeTo怎麽用?Java Matcher.describeTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hamcrest.Matcher的用法示例。


在下文中一共展示了Matcher.describeTo方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: childAtPosition

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
開發者ID:privacyidea,項目名稱:privacyidea-authenticator,代碼行數:19,代碼來源:MainActivityTest.java

示例2: childAtPosition

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<View> childAtPosition(final Matcher<View> parentMatcher, final int position) {
    
    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }
        
        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent) && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
開發者ID:parthdave93,項目名稱:AndroidTestingTutorial,代碼行數:17,代碼來源:RecorderActivityTest.java

示例3: childAtPosition

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<View> childAtPosition(final Matcher<View> parentMatcher,
        final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent) && view.equals(
                    ((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:19,代碼來源:RegistrationActivityTest.java

示例4: childAtPosition

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, @SuppressWarnings("SameParameterValue") final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
開發者ID:orionlee,項目名稱:aDictOnCopy,代碼行數:19,代碼來源:MainActivityTest.java

示例5: withIndex

import org.hamcrest.Matcher; //導入方法依賴的package包/類
public static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
    return new TypeSafeMatcher<View>() {
        int currentIndex = 0;

        @Override
        public void describeTo(Description description) {
            description.appendText("with index: ");
            description.appendValue(index);
            matcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            return matcher.matches(view) && currentIndex++ == index;
        }
    };
}
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:18,代碼來源:MatchWithIndex.java

示例6: withItemViewAtPosition

import org.hamcrest.Matcher; //導入方法依賴的package包/類
/**
 * <p>
 * Returns a matcher that matches an item view at the given position
 * in the RecyclerView matched by {@code recyclerViewMatcher}.
 * </p>
 * <p>
 * If the item view at the given position is not laid out,
 * the matcher returned by this method will not match anything.
 * Call {@link android.support.test.espresso.contrib.RecyclerViewActions#scrollToPosition(int)}
 * with the same position prior to calling this method
 * in order to ensure that the item view is laid out.
 * </p>
 * <pre><code>
 *     onView(withId(R.id.recyclerView).perform(RecyclerViewActions.scrollToPosition(position);
 * </code></pre>
 *
 * @param recyclerViewMatcher a matcher for RecyclerView containing the item view.
 * @param position            position of the item view in RecyclerView
 */
public static Matcher<View> withItemViewAtPosition(final Matcher<View> recyclerViewMatcher, final int position) {
    return new TypeSafeMatcher<View>() {
        @Override
        protected boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            if (!(parent instanceof RecyclerView) || !recyclerViewMatcher.matches(parent)) {
                return false;
            }
            RecyclerView.ViewHolder viewHolder = ((RecyclerView) parent).findViewHolderForAdapterPosition(position);
            return viewHolder != null && viewHolder.itemView.equals(view);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Item view at position " + position + " in recycler view ");
            recyclerViewMatcher.describeTo(description);
        }
    };
}
 
開發者ID:sumio,項目名稱:espresso-sample-for-droidkaigi2017,代碼行數:39,代碼來源:RecyclerViewUtils.java

示例7: withIndex

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
    return new TypeSafeMatcher<View>() {
        int currentIndex = 0;

        @Override
        public void describeTo(Description description) {
            description.appendText("with index: ");
            description.appendValue(index);
            matcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            return matcher.matches(view) && currentIndex++ == index;
        }
    };
}
 
開發者ID:aschattney,項目名稱:dagger-test-example,代碼行數:18,代碼來源:SimpleEspressoTest.java

示例8: withCollapsingToolbarTitle

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<Object> withCollapsingToolbarTitle(
        final Matcher<CharSequence> textMatcher) {
    return new BoundedMatcher<Object, CollapsingToolbarLayout>(CollapsingToolbarLayout.class) {

        @Override
        public void describeTo(Description description) {
            description.appendText("with collapsing toolbar title: ");
            textMatcher.describeTo(description);
        }

        @Override
        protected boolean matchesSafely(CollapsingToolbarLayout collapsingToolbarLayout) {
            return textMatcher.matches(collapsingToolbarLayout.getTitle());
        }

    };
}
 
開發者ID:ecarrara-araujo,項目名稱:yabaking,代碼行數:18,代碼來源:ToolbarMatchers.java

示例9: isNthChildOf

import org.hamcrest.Matcher; //導入方法依賴的package包/類
/**
 * Returns a matcher that matches a {@link View} that is a child of the described parent
 * at the specified index.
 *
 * @param parentMatcher A matcher that describes the view's parent.
 * @param childIndex The index of the view at which it is a child of the described parent.
 */
private static Matcher<View> isNthChildOf(final Matcher<View> parentMatcher, final int childIndex) {
    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("is child at index "+childIndex+" of view matched by parentMatcher: ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewGroup parent = (ViewGroup) view.getParent();
            return parentMatcher.matches(parent) && view.equals(parent.getChildAt(childIndex));
        }
    };
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:23,代碼來源:NumberPadTimePickerDialogTest.java

示例10: withToolbarTitle

import org.hamcrest.Matcher; //導入方法依賴的package包/類
private static Matcher<Object> withToolbarTitle(final Matcher<CharSequence> textMatcher) {
    return new BoundedMatcher<Object, Toolbar>(Toolbar.class) {
        @Override
        public boolean matchesSafely(Toolbar toolbar) {
            return textMatcher.matches(toolbar.getTitle());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("with toolbar title: ");
            textMatcher.describeTo(description);
        }
    };
}
 
開發者ID:kevalpatel2106,項目名稱:smart-lens,代碼行數:15,代碼來源:CustomMatchers.java

示例11: withTextInputLayoutHint

import org.hamcrest.Matcher; //導入方法依賴的package包/類
public static Matcher<View> withTextInputLayoutHint(final Matcher<String> stringMatcher) {
    return new BoundedMatcher<View, TextInputLayout>(TextInputLayout.class) {
        @Override
        public void describeTo(Description description) {
            description.appendText("with hint: ");
            stringMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(TextInputLayout textInputLayout) {
            return stringMatcher.matches(textInputLayout.getHint());
        }
    };
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:15,代碼來源:CustomMatchers.java

示例12: testIsJsonLongMatcherUpdatesDescription

import org.hamcrest.Matcher; //導入方法依賴的package包/類
@Test
public void testIsJsonLongMatcherUpdatesDescription() {
	Matcher<JsonElement> matcher = aJsonLong(equalTo(23L));

	Description description = new StringDescription();

	matcher.describeTo(description);

	String expected = "a number element with a value that is <23L>";

	assertThat(description.toString(), is(expected));
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:13,代碼來源:IsJsonLongMatcherTest.java

示例13: testIsJsonMatcherUpdatesDescription

import org.hamcrest.Matcher; //導入方法依賴的package包/類
@Test
public void testIsJsonMatcherUpdatesDescription() {
	Conditions conditions = _builder.build();

	Matcher<String> stringMatcher = aJsonObjectStringWith(conditions);

	Description description = new StringDescription();

	stringMatcher.describeTo(description);

	assertThat(description.toString(), is("a JSON object where {\n}"));
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:13,代碼來源:IsJsonObjectStringMatcherTest.java

示例14: testIsJsonBooleanMatcherUpdatesDescription

import org.hamcrest.Matcher; //導入方法依賴的package包/類
@Test
public void testIsJsonBooleanMatcherUpdatesDescription() {
	Matcher<JsonElement> matcher = aJsonBoolean(false);

	Description description = new StringDescription();

	matcher.describeTo(description);

	String expected = "a boolean element with a value that is <false>";

	assertThat(description.toString(), is(expected));
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:13,代碼來源:IsJsonBooleanMatcherTest.java


注:本文中的org.hamcrest.Matcher.describeTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。