당신은 에스프레소 지원하지 않기 때문에 사용자 정의 매처 (matcher)를 만들어야합니다을 내가 사용하는 텍스트를 분파 순간
기본적으로 이러한 matchers 중 하나입니다.
운 좋게도 아주 쉽게 할 수 있습니다.
public class FontSizeMatcher extends TypeSafeMatcher<View> {
private final float expectedSize;
public FontSizeMatcher(float expectedSize) {
super(View.class);
this.expectedSize = expectedSize;
}
@Override
protected boolean matchesSafely(View target) {
if (!(target instanceof TextView)){
return false;
}
TextView targetEditText = (TextView) target;
return targetEditText.getTextSize() == expectedSize;
}
@Override
public void describeTo(Description description) {
description.appendText("with fontSize: ");
description.appendValue(expectedSize);
}
가}
그리고 지금과 같은 엔트리 포인트 작성 : 글꼴 크기이 예를 살펴
public static Matcher<View> withFontSize(final float fontSize) {
return new FontSizeMatcher(fontSize);
}
을 그리고 다음과 같이 사용 :
onView(withId(R.id.editText1)).check(matches(withFontSize(36)));
들어 너비는 &이며 비슷한 방식으로 높이를 지정할 수 있습니다.