I'm using espresso as my UI
automation test. I want to create a matcher
for ExpandableListView
, since it sometimes goes of screen and its not good practice to call onView(withText("something"))
on a view that has adapter
bound to it. Can somebody show me how to create matcher
for ExpandableListView
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I don't know if this one would be useful, but:
public static Matcher<Object> withListItemCheck(final <Type> check_value) { checkNotNull(check_value); return new BoundedMatcher<Object, <List_Item_class>>(<List_Item_class>.class) { private String m_message = ""; @Override public void describeTo(Description d) { d.appendText(m_message); } @Override public boolean matchesSafely(<List_Item_class> listItem) { m_message = "Expected " + listItem+ " and got "; if (listItem== null) { m_message += "empty"; return false; } return <assertion to check `check_value` is corresponding to `listItem` or not>; } }; }
Taken from: accessing children in custom expandablelist using android espresso
Hope it will help