Open sergio-sastre opened 4 months ago
@sergio-sastre Thanks for logging this issue. Do you have an example test that I can try this out with?
@DanielJette Sure! You can find an executable example here: https://github.com/sergio-sastre/Android-screenshot-testing-playground/blob/master/recyclerviewscreen/android-testify/src/androidTest/java/com/example/road/to/effective/snapshot/testing/recyclerviewscreen/android_testify/viewholder/MemoriseViewHolderTest.kt
However that uses AndroidUiTestingUtils on top of Android-Testify
I can create a simpler example if it helps. Just let me know 😊
Sure! You can find an executable example here:
Perfect!
I can create a simpler example if it helps. Just let me know 😊
No thank you. That example will do just fine.
@sergio-sastre
Describe the bug One trick I generally use to configure an Activity under different configurations (uiMode, fontSize, displaySize, locale...) is to launch an EmptyActivity with the desired configuration, and inflate the views in it with that Activity's context.
Regarding the Display Size, I basically modify the densityDpi accordingly. e.g.
However, this seems to cause a problem when verifying the screenshots with Android-testify, where I get an
UnexpectedDeviceException
because of a mismatch of the displayDensity in the device key.After some investigation, it seems the problem lies on the following code lines in the
assertSame()
method:One of them uses testContext, which is
getInstrumentation().context
, while the other one uses the Activity's context. Since what I'm doing is to launch an EmptyActivity with a context that simulates a different display size via context's configuration's densityDpi, both contexts' display size differ, and when not in record mode, theassertExpectedDevice()
throws anUnexpectedDeviceException
I think it'd make sense to pass the same context to both, likely the Activity context in this case.
This issue relates to:
Link to the corresponding issue in my library: https://github.com/sergio-sastre/AndroidUiTestingUtils/issues/104