-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Android screenshot tests 2 #2809
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
Draft
richardTingle
wants to merge
101
commits into
jMonkeyEngine:master
Choose a base branch
from
richardTingle:android-screenshot-tests-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
b766025
Make the screenshot tests run in an off frame buffer and correct gamm…
richardTingle 97dc3c2
Make the definition of "the same" a bit more flexible to avoid instab…
richardTingle 4b84b7b
Restore gamma correction
richardTingle 602d25f
Set the colourspace for the off renderTexture
richardTingle 2a428bc
Set the Srgb for the off renderTexture
richardTingle 59164b3
Rebake minor visual changes for off frame buffer
richardTingle ec05b0d
Rearrange for submodule screenshot structure
richardTingle 625c35b
Add in dependencies for android
richardTingle e215ab4
Bring it closer to the android initialiser project
richardTingle 93d159e
Temporarily use non local android jme
richardTingle 77f8178
Simple screenshot test
richardTingle 036ab76
Wait for emulator
richardTingle e0cad2a
Dont save a snapshot, use mesa
richardTingle 9787b0b
Make the emulator logs less likely to hang
richardTingle dbf0b9c
Bit closer to the android-emulator-runner docs
richardTingle 9f36591
Add logging in test
richardTingle 0780c16
Try a more modern pixel copy
richardTingle b5ef700
Capture logcat
richardTingle e897546
Only get my applications logcat
richardTingle a938fea
Pull logs inside app step
richardTingle 808be1c
Prevent snapshots (which are erroring)
richardTingle 3b02dfc
Actually grab the logcat
richardTingle f6c13e4
Use the actual location of the file
richardTingle 6b65fbb
Save file to public directory
richardTingle 96173d6
The whole logcat isn't too long
richardTingle a0ca84e
Pull image from quoted location
richardTingle cf235a3
Whole log cat actually a bit much to put in github logs
richardTingle d5cdeaa
Use latch to wait explicitly for write to complete
richardTingle c35e44c
Clean up the test code
richardTingle a475397
Go back to scoped storage as permissions do not allow downloads folder
richardTingle b9d850c
Pull file from within test
richardTingle b0ed44d
Use explicit file location
richardTingle 70f7c08
Revert "Use explicit file location"
richardTingle 14368e6
Revert "Pull file from within test"
richardTingle 76d288c
Avoid auto unistall (which means I can't get the file)
richardTingle 5edfa73
Try to get JME to render into the test
richardTingle 44f5e07
Fresh emulator every time
richardTingle 7ed17c5
Take the screenshot from the glSurfaceView
richardTingle f0eff53
Move the screenshot framework to a shared environment
richardTingle 36f5a99
Extract out one of the tests ready for reuse
richardTingle 456e572
Merge remote-tracking branch 'official/master' into android-screensho…
richardTingle 1e85933
Start introducing shared android screenshot functionality
richardTingle a2ff9bf
Allow for test scenarios to be booted to both android and desktop
richardTingle 05096e8
Start splitting out android specific elements
richardTingle c23638a
Introduce androidx-storage to save the report persistently
richardTingle 566b074
Change from BufferedImage to JME Image for android compatibility
richardTingle add9b04
Work towards allowing android to write a proto report
richardTingle 925ecf4
Hook in workflow for android screenshots
richardTingle 3ad9d8d
Hook in workflow for android screenshots
richardTingle f001e54
Clean up ExtentReportExtensionJunit4
richardTingle 09dbf79
Avoid reuse of AssetManager (as we are registering random folders)
richardTingle 7017297
Give gradle more heap for build (specifically for the android build)
richardTingle 5331aa3
Remove redundant request to write to external storage
richardTingle 38df11e
Run the adb pulls even if the gradle step fails
richardTingle 4eff799
Add the upgrade step for the report
richardTingle 3ac08d8
Use more modern android for jackson support
richardTingle 3abe9ba
Use x86_64 android
richardTingle 5d209f4
Use x86_64 android
richardTingle 33ac90f
Even more modern android
richardTingle a9cca06
Try 35 as docs only go up to 35
richardTingle b7e1de8
Remove the matrix as we only run one
richardTingle aa2ac55
Install test services before running test
richardTingle 4c4a80e
Debug error codes
richardTingle b1d2ef3
Create report directory before pulling to it
richardTingle 8d7a7f6
Format the android screenshot tests readme
richardTingle 1c4992f
Error if upgrade of report fails
richardTingle bd58967
Correct upgrade code to access the files with absolute paths
richardTingle 05bf72f
Try to trap the error code better
richardTingle 69f52e3
One giant line of doom
richardTingle b73e668
One giant line of doom 2
richardTingle 665c36d
Just say -1 for a fail
richardTingle 98aba20
Ensure report has a title
richardTingle 7130677
Reinstate deserialisation constructor
richardTingle b53ed0c
Migrate all tests to be android & desktop tests
richardTingle b8a2cca
Ensure that we get a single test report
richardTingle 73f8577
Run the whole thing in a single shell
richardTingle 64ec98e
Include logcat
richardTingle a6542c8
Increase ram for emulator
richardTingle 9f586f3
Allow app to have large heap
richardTingle 08970e0
Even larger heap
richardTingle 059f579
Remove some of the more memory intensive tests
richardTingle c5fae11
Remove some more of the more memory intensive tests
richardTingle 7b0c650
Correct the calculateImageFilePrefix so it is flexible to thread dept…
richardTingle b8dc5bc
Remove more memory intensive tests
richardTingle 0c0e209
Try for a wider device
richardTingle 84a1254
Try to find available profiles
richardTingle 6b3e00e
Try to find available profiles
richardTingle abd96e9
Initialise the reference images
richardTingle 802669c
Load references images from resources (to make android happy)
richardTingle 342cd25
Correct colours are ints, not bytes (as unsigned)
richardTingle 89289eb
Use consistent pixel comparison
richardTingle da37de2
Log pixel errors
richardTingle ed163cd
Fix inverted "very similar" test
richardTingle d3f4b14
Set android tests to only run on push
richardTingle ba125f9
Restore android harness as it was
richardTingle 2fc6913
Self review
richardTingle 135a007
Single subshell to avoid EOF issues
richardTingle 64fca29
Avoid richard actually being contacted by the message
richardTingle 4147b76
Merge remote-tracking branch 'official/master' into android-screensho…
richardTingle 758a225
Wrap whole shell in a >
richardTingle f1a9d83
Natives moved out of project
richardTingle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Android Screenshot Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - v3.7 | ||
| - v3.6 | ||
| - v3.5 | ||
| - v3.4 | ||
| - v3.3 | ||
| - ios-2024_2 | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Enable KVM | ||
| run: | | ||
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
| sudo udevadm control --reload-rules | ||
| sudo udevadm trigger --name-match=kvm | ||
|
|
||
| - name: Gradle cache | ||
| uses: gradle/actions/setup-gradle@v5 | ||
|
|
||
| - name: AVD cache | ||
| uses: actions/cache@v5 | ||
| id: avd-cache | ||
| with: | ||
| path: | | ||
| ~/.android/avd/* | ||
| ~/.android/adb* | ||
| key: avd-35 | ||
| - name: Run Android Screenshot Test | ||
| uses: reactivecircus/android-emulator-runner@v2 | ||
| with: | ||
| api-level: 35 | ||
| avd-name: test_avd | ||
| target: google_apis | ||
| arch: x86_64 | ||
| force-avd-creation: true | ||
| ram-size: 4096M | ||
| heap-size: 2048M | ||
| profile: pixel_tablet | ||
| emulator-options: -no-window -gpu mesa -noaudio -no-boot-anim -camera-back none -no-snapshot -no-snapshot-save -no-snapshot-load | ||
| disable-animations: false | ||
| script: > | ||
| curl -L https://maven.google.com/androidx/test/services/test-services/1.6.0/test-services-1.6.0.apk --output test-services-1.6.0.apk; | ||
| adb install -r -g test-services-1.6.0.apk; | ||
| adb uninstall org.jmonkeyengine.screenshottests.android || true; | ||
| ./gradlew :jme3-screenshot-tests:jme3-screenshot-tests-android:connectedDebugAndroidTest; | ||
| exit_code=$?; | ||
| mkdir -p logcat; | ||
| adb logcat -d > logcat/logcat_full.txt || true; | ||
| adb logcat -d | grep org.jmonkeyengine.screenshottests.android > logcat/logcat.txt || true; | ||
| mkdir -p report; | ||
| adb pull /storage/emulated/0/googletest/test_outputfiles/report report/protoReport || true; | ||
| adb pull /storage/emulated/0/googletest/test_outputfiles/changed-images report/changed-images || true; | ||
| ./gradlew :jme3-screenshot-tests:jme3-screenshot-tests-proto-report:upgradeProtoReport --args="$(pwd)/report/protoReport $(pwd)/report/extentReport" || true; | ||
| echo "GRADLE_EXIT_CODE=$exit_code" >> $GITHUB_ENV; | ||
| exit $exit_code | ||
| - name: Upload logcat | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: android-logcat | ||
| path: logcat | ||
| - name: Upload Screenshot | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: android-screenshot-report | ||
| path: report | ||
| if-no-files-found: error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
jme3-screenshot-tests/jme3-screenshot-tests-android/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| plugins { | ||
| id "io.github.0ffz.github-packages" version "1.2.1" // Plugin for anonymous inclusion of artifacts hosted in github package registry | ||
| } | ||
|
|
||
| apply plugin: 'com.android.application' | ||
|
|
||
| android { | ||
| namespace "org.jmonkeyengine.screenshottests.android" | ||
| compileSdk 36 | ||
|
|
||
| defaultConfig { | ||
| applicationId "org.jmonkeyengine.screenshottests.android" | ||
| minSdk 28 | ||
| targetSdk 36 | ||
| versionCode 1 | ||
| versionName "1.0" | ||
|
|
||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| minifyEnabled false | ||
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
| } | ||
| } | ||
| configurations.all { | ||
| exclude group:"org.jmonkeyengine",module:"jme3-desktop" | ||
| } | ||
|
|
||
| packagingOptions { | ||
| jniLibs { | ||
| useLegacyPackaging = true | ||
| } | ||
| resources { | ||
| merges += "META-INF/LICENSE.md" | ||
| merges += "META-INF/LICENSE-notice.md" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation libs.androidxAppcompat | ||
| implementation libs.googleMaterial | ||
| implementation libs.androidxConstraintlayout | ||
|
|
||
| implementation project(":jme3-android") | ||
| implementation libs.jme3.android.natives | ||
|
|
||
| implementation libs.androidx.test.core | ||
| implementation libs.androidx.test.ext.junit | ||
| implementation libs.androidx.test.rules | ||
| implementation libs.androidx.test.espresso.core | ||
| implementation libs.androidx.fragment.testing | ||
| implementation libs.jackson | ||
| debugImplementation libs.androidx.fragment.testing.manifest | ||
| androidTestImplementation libs.androidx.fragment.testing.manifest | ||
| debugImplementation libs.androidx.storage | ||
|
|
||
| implementation project(':jme3-screenshot-tests:jme3-screenshot-tests-shared') | ||
| implementation project(':jme3-screenshot-tests:jme3-screenshot-tests-proto-report') | ||
|
|
||
| implementation project(':jme3-testdata') | ||
|
|
||
| // Allows the test to communicate with the orchestrator storage | ||
| androidTestImplementation libs.androidx.test.services | ||
| debugImplementation libs.androidx.test.services | ||
| } |
21 changes: 21 additions & 0 deletions
21
jme3-screenshot-tests/jme3-screenshot-tests-android/proguard-rules.pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Add project specific ProGuard rules here. | ||
| # You can control the set of applied configuration files using the | ||
| # proguardFiles setting in build.gradle. | ||
| # | ||
| # For more details, see | ||
| # http://developer.android.com/guide/developing/tools/proguard.html | ||
|
|
||
| # If your project uses WebView with JS, uncomment the following | ||
| # and specify the fully qualified class name to the JavaScript interface | ||
| # class: | ||
| #-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| # public *; | ||
| #} | ||
|
|
||
| # Uncomment this to preserve the line number information for | ||
| # debugging stack traces. | ||
| #-keepattributes SourceFile,LineNumberTable | ||
|
|
||
| # If you keep the line number information, uncomment this to | ||
| # hide the original source file name. | ||
| #-renamesourcefileattribute SourceFile |
45 changes: 45 additions & 0 deletions
45
jme3-screenshot-tests/jme3-screenshot-tests-android/readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # JMonkeyEngine Android Screenshot Tests | ||
|
|
||
| This project contains screenshot tests specifically for Android. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| To run these tests and collect the results, you need to install the Android Test Services APK on your device/emulator. This service allows the tests to write files (like screenshots and reports) to a persistent location that can be accessed via ADB. | ||
|
|
||
| 1. Download the Test Services APK: [test-services-1.6.0.apk](https://maven.google.com/androidx/test/services/test-services/1.6.0/test-services-1.6.0.apk) | ||
| 2. Install it with necessary permissions: | ||
| ```bash | ||
| adb install -r -g test-services-1.6.0.apk | ||
| ``` | ||
|
|
||
| ## Collecting Test Results | ||
|
|
||
| The tests are configured to use `androidx.test.services.storage.TestStorage` to save output files. After running the tests, you can pull the entire report folder (which includes the captured images and the proto-report JSON) using the following command: | ||
|
|
||
| ```bash | ||
| adb pull /storage/emulated/0/googletest/test_outputfiles/report/ | ||
| ``` | ||
|
|
||
| Individual files can also be pulled if needed: | ||
| ```bash | ||
| adb pull /storage/emulated/0/googletest/test_outputfiles/report/screenshotProtoReport.json | ||
| ``` | ||
|
|
||
| ## Generating Extent Reports | ||
|
|
||
| The raw report is saved in a "proto-report" format (`screenshotProtoReport.json`). To convert this into a human-readable Extent Report (HTML), use the `upgradeProtoReport` Gradle task located in the `jme3-screenshot-tests-proto-report` module. | ||
|
|
||
| ### Usage | ||
|
|
||
| Run the task and provide the input directory (where the pulled report is) and the desired output directory: | ||
|
|
||
| ```bash | ||
| ./gradlew :jme3-screenshot-tests:jme3-screenshot-tests-proto-report:upgradeProtoReport --args="path/to/pulled/report path/to/output/extent-report" | ||
| ``` | ||
|
|
||
| ## How it Works | ||
|
|
||
| 1. **Capture**: When tests run on Android, `ExtentReportExtensionJunit4` captures test status, logs, and screenshots. | ||
| 2. **Storage**: Screenshots are saved as PNG files and test metadata is collected into a `ProtoReport` object. | ||
| 3. **Persistence**: At the end of each test, the report metadata is serialized to `screenshotProtoReport.json` and saved to the device's persistent storage via `TestStorage`. | ||
| 4. **Post-Processing**: Once pulled from the device, the `UpgradeProtoReportToExtentReport` tool processes the JSON and images to create a standalone HTML report with embedded screenshots. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.