You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
The DataBindingIdlingResource class is supposed to allow Espresso wait for the bindings to execute before proceeding with the tests. However, current implementation only handles top-level bindings of fragments (and, internally by data binding, child bindings referenced in those). However it doesn't seem to work for example for bindings that are part of the RecyclerView lists, since these views aren't direct views of fragments.
Modified implementation of method that finds bindings that works for me: I decided it's also not really required to look for all the fragments, rather entire view hierarchy. Or am I missing something?
/** * Find all bindings for views in the hierarchy*/privatefungetBindings(): List<ViewDataBinding> {
return activityTestRule.activity
?.findViewById<View>(android.R.id.content)
?.allChildren()
?.mapNotNull { view ->DataBindingUtil.getBinding<ViewDataBinding>(view) }
.orEmpty()
}
privatefun View.allChildren(): List<View> =if (thisisViewGroup) {
listOf(this) + children.map { it.allChildren() }.flatten()
} else {
listOf(this)
}
I'd issue a pull request with this but, but since I'd need to also modify the tests, which assume fragments (with only one view) I'd rather first open an issue to confirm this would be the proper approach.
I think even if it's not a problem in the sample, this solution is referenced e.g. here so it's worth making it robust for people who will copy it to their own projects.
The text was updated successfully, but these errors were encountered:
We are looking for a generic solution for this or perhaps a way to automatically add bindings to Espresso as IRs.
That would be nice. I suppose there's no ETA?
Other than that I'm curious, is there any advantage to inspecting fragments vs activity's content view, like I did? Seems like the sample in this repo missed child fragments case, and in any case both miss recycler items or bindings dynamically added to the views. Or maybe there's yet another case that I should keep in mind?
The
DataBindingIdlingResource
class is supposed to allow Espresso wait for the bindings to execute before proceeding with the tests. However, current implementation only handles top-level bindings of fragments (and, internally by data binding, child bindings referenced in those). However it doesn't seem to work for example for bindings that are part of theRecyclerView
lists, since these views aren't direct views of fragments.Modified implementation of method that finds bindings that works for me: I decided it's also not really required to look for all the fragments, rather entire view hierarchy. Or am I missing something?
I'd issue a pull request with this but, but since I'd need to also modify the tests, which assume fragments (with only one view) I'd rather first open an issue to confirm this would be the proper approach.
I think even if it's not a problem in the sample, this solution is referenced e.g. here so it's worth making it robust for people who will copy it to their own projects.
The text was updated successfully, but these errors were encountered: