使用"hasBackground"进行浓缩咖啡测试 [英] Espresso test with “hasBackground”
问题描述
如何用布局背景的颜色进行浓咖啡测试?当前使用 hasBackground():
How can I make a espresso test with the color of the layout background? Currently use hasBackground():
onView(withId(R.id.backgroundColor)).check(matches(hasBackground(Color.parseColor("#FF55ff77"))));
但是会发生错误:
android.support.test.espresso.base.DefaultFailureHandler $ AssertionFailedWithCauseError:'具有可绘制ID为-11141257的背景'与所选视图不匹配.
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'has background with drawable ID: -11141257' doesn't match the selected view.
预期:具有可绘制ID:-11141257的背景
Expected: has background with drawable ID: -11141257
Got:"LinearLayout {id = 2130968576,res-name = backgroundColor,可见性= VISIBLE,宽度= 996,高度= 1088,has-focus = false,has-focusable = false,has-window-focus = true, is-clickable = false,is-enabled = true,is-focused = false,is-focusable = false,is-layout-requested = false,is-selected = false,layout-params = android.widget.LinearLayout $ LayoutParams @ e55f6e7,tag = null,root-is-layout-requested = false,has-input-connection = false,x = 42.0,y = 601.0,child-count = 2}"
Got: "LinearLayout{id=2130968576, res-name=backgroundColor, visibility=VISIBLE, width=996, height=1088, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@e55f6e7, tag=null, root-is-layout-requested=false, has-input-connection=false, x=42.0, y=601.0, child-count=2}"
我该如何比较?