下面列出了怎么用android.support.test.internal.util.Checks的API类实例代码及写法,或者点击链接到github查看源代码。
public static Matcher<View> withBGColor(final int color) {
Checks.checkNotNull(color);
return new BoundedMatcher<View, View>(View.class) {
@Override
public boolean matchesSafely(View view) {
int currentColor = ((ColorDrawable) view.getBackground()).getColor();
return color == currentColor;
}
@Override
public void describeTo(Description description) {
description.appendText("with background color: " + color);
}
};
}
public static Matcher<View> withTextColor(final int color) {
Checks.checkNotNull(color);
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public boolean matchesSafely(TextView warning) {
return color == warning.getCurrentTextColor();
}
@Override
public void describeTo(Description description) {
description.appendText("with text color: ");
}
};
}
public static Matcher<View> withTextColor(final int color) {
Checks.checkNotNull(color);
return new BoundedMatcher<View, TextView>(TextView.class) {
@Override
public boolean matchesSafely(TextView textView) {
return color == textView.getCurrentTextColor();
}
@Override
public void describeTo(Description description) {
description.appendText("Expected Color: " + color);
}
};
}