Closed amanzan closed 2 years ago
@amanzan Thank you for the bug report.
Testify isn't currently able to capture the bottom sheet fragment on top of another fragment/activity since its internal capture mechanism is based on the view hierarchy. Basically, the bottom sheet isn't in the same view hierarchy, so it's not getting captured.
Supporting this case would be a nice addition to the next version of Testify and so I've tagged this to the 1.2 milestone.
As a workaround for testing bottom sheet fragments, I recommend that you write your test so that you focus on testing the contents of the fragment in isolation, instead of actually as being rendered in a bottom sheet. You can do this by loading the Fragment directly into a host activity and using Testify to capture that, or you can try using setScreenshotViewProvider
to instruct Testify to capture a different view hierarchy.
@DanielJette would it be possible to extend somehow ScreenshotRule, so that there's a new assertSame function which accepts currentBitmap as parameter? This way, I could take a screenshot of the entire screen and pass it
Hi @amanzan Unfortunately there's not currently a way to extend the ScreenshotRule in a meaningful way to allow for customization of the currentBitmap. However, there are plans to significantly expand the extensibility and customizability of the screenshot rule. This is tentatively scheduled to be included in the 1.2.0 release.
I have a work-in-progress branch here https://github.com/Shopify/android-testify/compare/227-extensible that demonstrates one way that Testify can allow for custom capture methods.
Cool, looking forward to it 👌 Thanks!
Hi @DanielJette would this issue also be applicable to DropdownMenu from jetpack compose? I'm trying to write a screenshot test for the "expanded" (opened) version of the dropdown and the menu doesn't appear in the screenshot: |
expected | actual |
---|---|---|
![]() |
![]() |
I wasn't sure if this was due to a timing issue with when the screenshot is taken or if it's because the dropdown is rendered in a different view hierarchy.
@jennatauro I added a DropdownMenu
test to the Sample app and I can confirm that I'm seeing the same error as you are.
Here is the Layout Inspector output:
It appears that the Dropdown is rendered in a different layer than the rest of the composition. I suspect this is likely implemented via a new Window by the compose renderer and this Window is not being captured.
You can find my changes to the Sample here https://github.com/Shopify/android-testify/pull/262
As of yet, I don't know how to resolve this issue, but it might be possible to direct Testify to capture the popup Window. Due to the limitations of Testify, it is not likely possible to capture the entire screen without also capturing the System UI. There is an issue requesting full-screen capture here.
Hi @DanielJette, I see there is a 1.2.0-beta1 version available. Would this be possible to do in that version then? If so, would you mind guiding me how to approach it?
@amanzan Unfortunately the 1.2.0-beta1 version has not been published and there are no plans to publish this version to the Shopify repository. Future updates will be published under the dev.testify
namespace (https://search.maven.org/artifact/dev.testify/plugin).
The full-screen functionality you are looking for will be published in the testify-fullscreen
library which you can find here: https://github.com/ndtp/android-testify/tree/main/Ext/Fullscreen
We're still working through a lot of details regarding the move to the new repository, so stay tuned for updates. I would anticipate this library being published in Q3 2022.
Describe the bug Trying to record the baseline screenshots for an app with a BottomSheetDialogFragment opened. The screenshot doesn't include the BottomSheetDialogFragment, only the everything that is behind it
This issue relates to:
To Reproduce Steps to reproduce the behavior:
Expected behavior The opened BottomSheetDialogFragment should be included in the screenshot
Screenshots App with BottomSheetDialogFragment opened (disregard bottom nav menu):![Screenshot_1631722353](https://user-images.githubusercontent.com/3911627/133470262-8d4db025-2c03-444d-ba56-6e4ec5ad30dc.png)
Recorded baseline screenshot:![ModalsTest_fixedSizeScreenshotCheck](https://user-images.githubusercontent.com/3911627/133470843-47f77004-70e2-4519-809b-6230cfb053ef.png)
Desktop (please complete the following information):
Target Android Device (please complete the following information):