-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Robolectric Emulator(Roborazzi Emulator) #176
Comments
I want to know more :) I guess it takes a screenshot on idle and displays it on the UI? |
Could that be useful to run the tests on multiple devices/configurations? Something like what Test Harness does for compose. I mean without having to create multiple classes with annotations like |
Probably for debugging purposes if you can see what is displayed before the screenshot is taken, and you give an option to “stop/sleep” for x seconds |
Thank you for your feedback. I think it will be useful for debugging. Here's what I'm thinking: @Test
fun emulator() {
onView(ViewMatchers.isRoot())
.roboNativeGraphicsEmulator()
} |
Thinking carefully, this makes sense not only for Roborazzi tests but also for Robolectric UI tests with RNG. Sometimes they fail and I resort to run them on the emulator (shared test pattern) to see why they fail. This is definitely sth that would help debugging such tests without the need to making them “shared” between instrumentation & unit tests |
@jeprubio I've just written a blog post about that: Moreover, you can also achieve that by using an ActivityScenario (which is compatible with Robolectric), launching an EmptyActivity whose context has the desired configuration, and inflating your View in it. That has the extra advantage of allowing you to set a custom xml theme and use pseudolocales, which are not supported via Robolectric qualifiers. |
@sergio-sastre Thanks! That's really helpful. I did know and use the cumulative qualifiers annotations but I didn't know about These days I'm a bit busy with my new home but this week I'll find a moment to read more in detail all that article, I'm sure I'll learn from that. Thanks a lot! |
What about if instead of running it's own UI, it exposed the same hooks that Android Emulators do for returning images, and processing input. Would be pretty useful tool for interactive compose previews, similar to the Android Studio previews, but based on a more open approach. A good base to build features like a VS Code preview support. (possibly relevent? - https://github.com/google/android-emulator-webrtc) |
I've realized that we can create an emulator using Robolectric Native Graphics. This is just a demo, but it works. I'm wondering if there are any use cases for this.
screencast.2023-10-08.14-49-52.mp4
The text was updated successfully, but these errors were encountered: