takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
649 stars 24 forks source link

POC - RNG Emulator #387

Open yschimke opened 1 month ago

yschimke commented 1 month ago

ClientMain (Client -> gRPC -> Server) spits out a similar PNG for SimplePreview, that running on an emulator does.

Quick and dirty POC for an alternative approach to https://github.com/takahirom/roborazzi/issues/176

Current Hacks

yschimke commented 1 month ago

Actually maybe the text is missing?

a.png image

emulator image

yschimke commented 1 month ago

For discussion only at the moment, happy to close, but wanted to see if it's viable.

takahirom commented 1 month ago

@yschimke Looks amazing. How can we try this? I found some main methods and test code.

Maybe like this?

./gradlew emulator-server:testDebugUnitTest

And then run the emulator-client test main() in Android Studio?

yschimke commented 1 month ago

At the moment it's clunky. I'm running the server in junit temporarily. It saves implementing all the sandbox config logic for a POC.

So run the testServer unit test method, it will print out it's started on port 8080.

Then run ClientMain. I had to turn off building the project on launch otherwise it waits for the unit test to finish which never does.

Sorry it's in such a rough state, but wanted to discuss the approach first

takahirom commented 1 month ago

I believe the main point would be to provide an interface shared with the Android Emulator. It sounds very promising. I tried using the android-emulator-webrtc, but setting it up with SSL and CORS is a bit difficult. It would be great if we could avoid these issues for users.

yschimke commented 1 month ago

@takahirom what I might try is a minimal project, outside roborazzi. One composable, one preview. Implement there and include a web page, showing android-emulator-webrtc.

This is probably a slow burner project, but wanted to see if it aligns with what you were envisioning.

takahirom commented 1 month ago

Thanks. I think there are two use cases for the RNG emulator:

Sharing an interface with the emulator isn't necessary, but it would be intuitive to use the emulator in the usual way for debugging. There may be some challenges, however. If this becomes a blocker, we can proceed without the interface.

yschimke commented 1 month ago

@takahirom I like that scope, it actually brings it inline with the POC. running within the test runner actually makes sense then.

So maybe at the start of a run, I'll print out the URL for a hosted webserver, and opening that will show you the internal progress?

takahirom commented 1 month ago

@yschimke

I'll print out the URL for a hosted webserver, and opening that will show you the internal progress?

Sounds good! So, you might run two servers, like a gRPC server and a web server, right?