android / android-test

An extensive framework for testing Android apps
https://android.github.io/android-test
Apache License 2.0
1.14k stars 307 forks source link

Espresso:- IdlingResources must support Databinding #317

Open jongerrish opened 5 years ago

jongerrish commented 5 years ago

DataBinding uses different approach to schedule an update, it uses Choreographer.postFrameCallback. So updates are not posted into looper queue and Espresso will not wait for them.

See: https://stackoverflow.com/questions/40703567/how-do-i-make-espresso-wait-until-data-binding-has-updated-the-view-with-the-dat

brettchabot commented 5 years ago

Perhaps this should be reworded as 'DataBinding' requires a custom IdlingResource? Since there is a IR sample for DataBinding that seems to work.

Both @slinzner and I looked into this and didn't think it was feasible for Espresso to use Choreographer as an idling resource

thrlr123 commented 4 years ago

My espresso tests were working fine before I updated to AS 3.6 with

viewBinding {
        enabled = true
    }

Now, when I do something like this it is not working:

public static void tapCard(String PageName) throws Throwable {
        Lets.performAndTakeSS(On.LocationsListDetails.CARDS_RECYCLER_VIEW, RecyclerViewActions.scrollTo(hasDescendant(EspressoMatchers.withText(EspressoMatchers.endsWith(PageName)))));
        Lets.performAndTakeSS(On.LocationsListDetails.CARDS_RECYCLER_VIEW, RecyclerViewActions.actionOnItem(hasDescendant(EspressoMatchers.withText(EspressoMatchers.endsWith(PageName))), click()));
    }

Am I supposed to change anything to work with viewbinding? Seeing this issue especially with Fragments.

https://github.com/android/testing-samples/issues/314

seadowg commented 3 months ago

Just to clarify, View binding doesn't have this problem right?