我有一个带有自定义视图的仪表板。
我想测试一旦数据可用,它是否正确显示在各种文本视图中。
我的问题是:如何选择属于层次结构的各个TextView。
例如:如何获取当前月份 > 销售额 > 值 视图
?
我只知道如何处理单个层次结构级别,但这对此处没有帮助:
onView(
allOf(withId(R.id.value),
isDescendantOfA(withId(R.id.current_month))))
层次结构如下所示:
+- RelativeLayout
|
|___+ CustomCardView (id = current_month)
| |
| |___+ CustomValueView (id = sales)
| | |
| | |___+ TextView (id = value)
| | |
| | |___+ TextView (id = unit)
| |
| |___+ CustomValueView (id = earnings)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomCardView (id = last_month)
| |
| |___+ CustomValueView (id = sales)
| | |
| | |___+ TextView (id = value)
| | |
| | |___+ TextView (id = unit)
| |
| |___+ CustomValueView (id = earnings)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomCardView (id = all_time)
|
|___+ CustomValueView (id = sales)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomValueView (id = earnings)
|
|___+ TextView (id = value)
|
|___+ TextView (id = unit)