Recycler item child matcher optimization
Ultron 2.5.4 I have test with duration more than 2 minutes I created alternative matcher for child of recycler view item and it speed up the test 4 times, duration now = 26 seconds
code that can be optimized in Ultron:
com.atiurin.ultron.core.espresso.recyclerview.UltronRecyclerViewItem().getChild(childMatcher: Matcher<View>): Matcher<View> --> RecyclerViewItemMatchingExecutor(ultronRecyclerView, itemViewMatcher).getItemChildMatcher(childMatcher: Matcher<View>): Matcher<View>
My speed up alternative matcher, for example/research optimization:
`fun UltronRecyclerViewItem.childAlternative(childMatcher: Matcher): Lazy<Matcher> = lazy {
val itemMatcher = this.getMatcher()
object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description?) {
description?.appendText("$itemMatcher, child matcher: $childMatcher")
}
override fun matchesSafely(item: View?): Boolean {
return if (childMatcher.matches(item)) {
// clear cached view in itemMatcher object property
val itemView = itemMatcher.javaClass.getDeclaredField("itemView")
itemView.isAccessible = true
itemView.set(itemMatcher, null)
// is descendant of matched recycler item?
isDescendantOfA(itemMatcher).matches(item)
} else false
}
} }`
Thanks!
Nice request! Need some time to research it.
@dabrynskiy Researched, we need this modification. Are you planing to make the PR?
i will make modification after merged https://github.com/open-tool/ultron/pull/115
https://github.com/open-tool/ultron/pull/115 merged.
https://github.com/open-tool/ultron/pull/116
Released https://github.com/open-tool/ultron/releases/tag/2.6.0-alpha01