sergio-sastre / AndroidUiTestingUtils

A set of TestRules, ActivityScenarios and utils to facilitate UI and screenshot testing under given configurations: FontSizes, Locales...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sergio-sastre opened this issue · comments

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:

  • Device or Emulator: Emulator
  • API level: Any
  • AndroidUiTestingUtils version: any
  • Affected Component: UiModeTestRule but only when used with the deprecated ActivityTestRule
  • Buggy Configuration: UiMode

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.

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