ultron icon indicating copy to clipboard operation
ultron copied to clipboard

Recycler item child matcher optimization

Open dabrynskiy opened this issue 1 year ago • 3 comments

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!

dabrynskiy avatar Mar 18 '25 08:03 dabrynskiy

Nice request! Need some time to research it.

alex-tiurin avatar Mar 26 '25 15:03 alex-tiurin

@dabrynskiy Researched, we need this modification. Are you planing to make the PR?

alex-tiurin avatar Apr 24 '25 15:04 alex-tiurin

@dabrynskiy Researched, we need this modification. Are you planing to make the PR?

ok, i will make

dabrynskiy avatar Apr 25 '25 19:04 dabrynskiy

i will make modification after merged https://github.com/open-tool/ultron/pull/115

dabrynskiy avatar Apr 30 '25 12:04 dabrynskiy

https://github.com/open-tool/ultron/pull/115 merged.

alex-tiurin avatar Apr 30 '25 17:04 alex-tiurin

https://github.com/open-tool/ultron/pull/116

dabrynskiy avatar May 05 '25 19:05 dabrynskiy

Released https://github.com/open-tool/ultron/releases/tag/2.6.0-alpha01

alex-tiurin avatar May 26 '25 17:05 alex-tiurin