BottomNavigationItemView
实现ItemView
具有该setChecked()
方法的接口。
我试图用 Espresso 断言检查了一个 itemView,但我得到了同样的错误,无论我的预期值是什么,isChecked()
或者isNotChecked()
.
我的测试:
ViewInteraction buttonHome = onView(
allOf(withId(R.id.bottomHome),
childAtPosition(
childAtPosition(
withId(R.id.bottom_navigation),
0),
0),
isDisplayed()));
buttonHome.check(matches(isNotChecked()));
错误信息
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'with checkbox state: is <true>' doesn't match the selected view.
Expected: with checkbox state: is <true>
Got: "BottomNavigationItemView{id=2131493015, res-name=bottomHome, visibility=VISIBLE, width=360, height=168, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}"
我怎么能断言 aBottomNavigationItemView
是当前选定的项目BottomNavigationView
?