本文整理汇总了Java中com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher类的典型用法代码示例。如果您正苦于以下问题:Java BoundedMatcher类的具体用法?Java BoundedMatcher怎么用?Java BoundedMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundedMatcher类属于com.google.android.apps.common.testing.ui.espresso.matcher包,在下文中一共展示了BoundedMatcher类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editTextWithText
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> editTextWithText(final int resId) {
return new BoundedMatcher<View, EditText>(EditText.class) {
@Override
protected boolean matchesSafely(EditText editText) {
String text = editText.getResources().getString(resId);
if (text == null) return false;
return text.equals(editText.getText().toString());
}
@Override
public void describeTo(Description description) {
description.appendText("has content text with resource id ");
description.appendValue(resId);
}
};
}
示例2: withItemContent
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Creates a matcher against the text stored in R.id.item_content. This text is roughly
* "item: $row_number".
*/
@SuppressWarnings("rawtypes")
public static Matcher<Object> withItemContent(final Matcher<String> itemTextMatcher) {
// use preconditions to fail fast when a test is creating an invalid matcher.
checkNotNull(itemTextMatcher);
return new BoundedMatcher<Object, Map>(Map.class) {
@Override
public boolean matchesSafely(Map map) {
return hasEntry(equalTo("STR"), itemTextMatcher).matches(map);
}
@Override
public void describeTo(Description description) {
description.appendText("with item content: ");
itemTextMatcher.describeTo(description);
}
};
}
示例3: withItemSize
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Creates a matcher against the text stored in R.id.item_size. This text is the size of the text
* printed in R.id.item_content.
*/
@SuppressWarnings("rawtypes")
public static Matcher<Object> withItemSize(final Matcher<Integer> itemSizeMatcher) {
// use preconditions to fail fast when a test is creating an invalid matcher.
checkNotNull(itemSizeMatcher);
return new BoundedMatcher<Object, Map>(Map.class) {
@Override
public boolean matchesSafely(Map map) {
return hasEntry(equalTo("LEN"), itemSizeMatcher).matches(map);
}
@Override
public void describeTo(Description description) {
description.appendText("with item size: ");
itemSizeMatcher.describeTo(description);
}
};
}
示例4: emptyEditText
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> emptyEditText() {
return new BoundedMatcher<View, EditText>(EditText.class) {
@Override
protected boolean matchesSafely(EditText editText) {
return "".equals(editText.getText().toString());
}
@Override
public void describeTo(Description description) {
description.appendText("empty EditText");
}
};
}
示例5: isOpen
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that verifies that the drawer is open. Matches only when the drawer is fully
* open. Use {@link #isClosed()} instead of {@code not(isOpen())} when you wish to check that the
* drawer is fully closed.
*/
public static Matcher<View> isOpen() {
return new BoundedMatcher<View, DrawerLayout>(DrawerLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("is drawer open");
}
@Override
public boolean matchesSafely(DrawerLayout drawer) {
return drawer.isDrawerOpen(GravityCompat.START);
}
};
}
示例6: isClosed
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* Returns a matcher that verifies that the drawer is closed. Matches only when the drawer is
* fully closed. Use {@link #isOpen()} instead of {@code not(isClosed()))} when you wish to check
* that the drawer is fully open.
*/
public static Matcher<View> isClosed() {
return new BoundedMatcher<View, DrawerLayout>(DrawerLayout.class) {
@Override
public void describeTo(Description description) {
description.appendText("is drawer closed");
}
@Override
public boolean matchesSafely(DrawerLayout drawer) {
return !drawer.isDrawerVisible(GravityCompat.START);
}
};
}
示例7: withFloatLabelHint
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
/**
* @param floatLabelHint
* @return View Matcher for the child EditText
*/
public static Matcher<View> withFloatLabelHint(final String floatLabelHint) {
return new BoundedMatcher<View, EditText>(EditText.class) {
@Override
public void describeTo(Description description) {
description.appendText("has floatlabel hint ");
description.appendValue(floatLabelHint);
if (null != floatLabelHint) {
description.appendText("[");
description.appendText(floatLabelHint);
description.appendText("]");
}
if (null != floatLabelHint) {
description.appendText(" value: ");
description.appendText(floatLabelHint);
}
}
@Override
protected boolean matchesSafely(EditText editText) {
if (!(editText instanceof EditText)) {
return false;
}
String hint = ((EditText) editText).getHint().toString();
return floatLabelHint.equals(hint);
}
};
}
示例8: withChildCount
import com.google.android.apps.common.testing.ui.espresso.matcher.BoundedMatcher; //导入依赖的package包/类
public static Matcher<View> withChildCount(final Matcher<Integer> numberMatcher) {
return new BoundedMatcher<View, ViewGroup>(ViewGroup.class) {
@Override
protected boolean matchesSafely(ViewGroup viewGroup) {
return numberMatcher.matches(viewGroup.getChildCount());
}
@Override
public void describeTo(Description description) {
description.appendText("number of child views ");
numberMatcher.describeTo(description);
}
};
}