Skip to content
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

ManagedVirtualDevice support #320

Open
crysxd opened this issue Aug 31, 2022 · 5 comments
Open

ManagedVirtualDevice support #320

crysxd opened this issue Aug 31, 2022 · 5 comments

Comments

@crysxd
Copy link

crysxd commented Aug 31, 2022

Is there a way to support ManagedVirtualDevice introduced with AGP 7.3.0? It would be amazing to make use of this new AGP feature so we no longer need to manager our own emulators on our CI system. Ideally the invocation would look like

./gradlew pixel4aApi30ExecuteScreenshotTests

@crysxd
Copy link
Author

crysxd commented Oct 31, 2022

Still chewing on this one...the main issue is that Shot copies the files from the device after the test is run, but at this point the emulator is already gone.

I did find this SO post which describes how data is copied off the managed device. This is the same way Google pulls baseline profiles from the managed device.

@olegosipenko
Copy link
Contributor

olegosipenko commented Dec 21, 2022

There is a sample from Google demonstrating how to take sreenshots using Gradle managed device. After test run files would be saved to the build/outputs/ folder. There is only one problem that this sample uses Espresso's functionality to take screenshots, although Shot under the hood utilizes old library from Facebook, so you can not feed this screenshot to Shot to perform verification.
So, you need to modify Google's sample to use the same Facebook library to take screenshots . And as a last bit you need to copy generated screenshot from additionalTestOutput folder into the screenshots/default-screenshots folder, which Shot uses to look for screenshots. After that you can run Shot with parameter runInstrumentation = false

@chrisjenx
Copy link
Contributor

Not sure how, but looks like there's two features here:

  • Be able to configure where screenshots are saved to by the test runner, Emulators/GTD/FTL all do something slightly different but you can get files off the devices in an automated way.
  • Be able to configure where shot grabs the generated devices from, Emulator/GTD/FTL all put them in some different sub directory under your project folder.

Is the issue that we can't override where the facebook lib puts the screenshots? (I could just look but wondered if anyone knew?)

@tdrhq
Copy link

tdrhq commented Nov 22, 2023

I'm the original author of the Facebook library.

You can actually fetch the screenshots from Firebase Test Lab using the --directories-to-pull command, and process the images manually (the images are tiled, so they have to be stitched back together.)

I have an example here: https://github.com/screenshotbot/shot-example, in particular the CI config here: https://github.com/screenshotbot/shot-example/blob/main/.circleci/config.yml#L30

But this example is using Screenshotbot to store and review the images.

(PS. We're also working on an Android emulator as a service that exposes a full ADB connection unlike FTL, which means the Shot gradle rules will work without any changes. Let me know if you're interested in being an early beta tester.)

@chrisjenx
Copy link
Contributor

@tdrhq sounds good, we're currently playing with the FirebaseTestLab Gradle managed devices plugin at the moment, much easier to work with, but still hit by there painful 4 minute "Wait" before the device even starts running the tests.

Yeah hit me up with an invite!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants