sergio-sastre / AndroidUiTestingUtils

A set of TestRules, ActivityScenarios and utils to facilitate UI and screenshot testing under given configurations: FontSizes, Locales...
MIT License
287 stars 14 forks source link

UiModeTestRule not working with deprecated ActivityTestRule (e.g. with ndpt/android-testify screenshot testing library) #38

Closed sergio-sastre closed 1 year ago

sergio-sastre commented 1 year ago

Describe the bug UiModeTestRule works perfectly fine with ActivityScenarios. However, it seems it is not the case when it comes to the deprecated ActivityTestRule, which is used by some screenshot testing libraries like ndpt/android-testify or its predecessor shopify/android-testify.

Environment The setup in which the bug is reproducible:

Expected behavior When UiModeTestRule is used with ndpt/android-testify screenshot testing library, it should also change the UiMode to "Day" or "Night" accordingly.

Additional context Seems that the problem is due to AppCompatDelegate being not executed at the proper time. An approach without APpCompatDelegate, but using reflection (like with SystemLocaleTestRule) should work.

sergio-sastre commented 1 year ago

It seems the problem is that one has to use the test rules in ActivityTestRule with launch = false for them to take effect.

Nothing to be done here