sergio-sastre / AndroidUiTestingUtils

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

Android-Testify Compose, View and fragment rules do not handle DisplaySize properly #104

Open sergio-sastre opened 4 months ago

sergio-sastre commented 4 months ago

Describe the bug When verifying only, it fails with UnexpectedDeviceException.

This happens because testify uses different Contexts to create the customKeys for naming the destination folders: record: activity context verify: instrumentation context

Since AndroidUiTestingUtils modifies the Activity context display size, it differs from the one of the instrumentation context used when verifying and it fails.

Environment The setup in which the bug is reproducible:

Expected behavior No exception is thrown

*Possible fix We could use a the DisplaySizeTestRule internally to set the Display size. The test rule executes an adb command to change the display size of the device, and therefore it affects also the instrumentation context and not only that of the activity.

Moreover, report this in Android-Testify repo

sergio-sastre commented 4 months ago

Seems that it is a bit hacky to deal with TestRules and ComposeRule together, and the tests also become more slow... better to get it fixed in Android-Testify