我有一个有各种选项的Spinner。单击任何选项后,片段将加载到活动的FrameLayout中。 使用Espresso我选择并单击Spinner项而没有任何错误,但之后视图层次结构仅包含微调器PopupViewContainer,我无法在活动中选择任何视图。
我的测试代码如下:
onView(withId(R.id.pager)).perform(swipeLeft()).perform(swipeLeft());
onView(withId(R.id.fgs_cbx_scan_type)).perform(click());
onData(hasToString(startsWith(GreenScanType.ARRIVAL.getName()))).inAdapterView(withId(R.id.fgs_cbx_scan_type)).perform(click());
//So far so good with no errors. Then the following call fails
//because the view hierarchy does not contain the hierarchy
//of the activity anymore but just the popup of the spinner.
onView(withId(R.id.fgs_cbx_scan_type)).check(matches(withText(containsString(GreenScanType.ARRIVAL.getName()))));
我有什么遗漏或做错了吗?
答案 0 :(得分:0)
最终我还要打电话
GridLayoutManager recycleLayoutManager = new GridLayoutManager(mContext, 2,GridLayoutManager.VERTICAL, false);
recycleLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
// grid items to take 1 column
if (mList.size() % 2 == 0) {
return 1;
} else {
return (position == mList.size()-1) ? 2 : 1;
}
}
});
在onView(withText(GreenScanType.ARRIVAL.getName())).perform(click());
之后