当前位置: 首页>>代码示例>>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;未经允许,请勿转载。