diff --git a/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/ComposeListPage.kt b/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/ComposeListPage.kt index fa403fd6..b37ffeb3 100644 --- a/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/ComposeListPage.kt +++ b/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/ComposeListPage.kt @@ -32,8 +32,10 @@ object ComposeListPage : Page() { fun getContactItemByTestTag(contact: Contact): ComposeFriendListItem = lazyList.getItem(hasTestTag(getContactItemTestTagById(contact))) fun getContactItemByName(contact: Contact): ComposeFriendListItem = lazyList.getItem(hasAnyDescendant(hasText(contact.name) and hasTestTag(contactNameTestTag))) class ComposeFriendListItem : UltronComposeListItem() { - val name by lazy { getChild(hasTestTag(contactNameTestTag)) } + val name by child { hasTestTag(contactNameTestTag) } val status by lazy { getChild(hasTestTag(contactStatusTestTag)) } - val notExisted by lazy { getChild(hasTestTag("NotExistedChild")) } + val notExisted by child { hasTestTag("NotExistedChild") } } -} \ No newline at end of file +} + + diff --git a/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/FriendsListPage.kt b/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/FriendsListPage.kt index eff3d9da..c93e0749 100644 --- a/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/FriendsListPage.kt +++ b/sample-app/src/androidTest/java/com/atiurin/sampleapp/pages/FriendsListPage.kt @@ -30,7 +30,7 @@ object FriendsListPage : Page() { } class FriendRecyclerItem : UltronRecyclerViewItem() { - val name by lazy { getChild(withId(R.id.tv_name)) } + val name by child { withId(R.id.tv_name) } val status by lazy { getChild(withId(R.id.tv_status)) } val avatar by lazy { getChild(withId(R.id.avatar)) } } diff --git a/ultron-compose/src/main/java/com/atiurin/ultron/core/compose/list/UltronComposeListItem.kt b/ultron-compose/src/main/java/com/atiurin/ultron/core/compose/list/UltronComposeListItem.kt index 9afbc845..6e9f6f4c 100644 --- a/ultron-compose/src/main/java/com/atiurin/ultron/core/compose/list/UltronComposeListItem.kt +++ b/ultron-compose/src/main/java/com/atiurin/ultron/core/compose/list/UltronComposeListItem.kt @@ -68,6 +68,10 @@ open class UltronComposeListItem { */ protected constructor() + fun child(block: () -> SemanticsMatcher): Lazy = lazy { + getChild(block()) + } + fun setExecutor(ultronComposeList: UltronComposeList, itemMatcher: SemanticsMatcher) { this.executor = MatcherComposeItemExecutor(ultronComposeList, itemMatcher) } diff --git a/ultron/src/main/java/com/atiurin/ultron/core/espresso/recyclerview/UltronRecyclerViewItem.kt b/ultron/src/main/java/com/atiurin/ultron/core/espresso/recyclerview/UltronRecyclerViewItem.kt index 2cd90156..ec6560c3 100644 --- a/ultron/src/main/java/com/atiurin/ultron/core/espresso/recyclerview/UltronRecyclerViewItem.kt +++ b/ultron/src/main/java/com/atiurin/ultron/core/espresso/recyclerview/UltronRecyclerViewItem.kt @@ -26,6 +26,10 @@ open class UltronRecyclerViewItem { */ protected constructor() + fun child(block: () -> Matcher): Lazy> = lazy { + getChild(block()) + } + constructor( ultronRecyclerView: UltronRecyclerView, itemViewMatcher: Matcher,