Skip to content

Working on Android Render Tests

Bart Louwers edited this page Mar 15, 2024 · 5 revisions

This is an guide that shows how to run and work on the Android render tests.

You can filter the tests to run by passing a flag to the file platform/android/src/test/render_test_runner.cpp:

std::vector<std::string> arguments = {..., "-f", "background-color/literal"};

Try running the androidRenderTest.app target.

Once the application quits, use the Device Explorer to navigate to /data/data/org.maplibre.render_test_runner/files.

image

Double click android-render-test-runner-style.html. Right click on the opened tab and select Open In > Browser. You should see that a single render test passed.

image

Alternatively to download (and open) the results from the command line, use:

adb shell "run-as org.maplibre.render_test_runner cat files/metrics/android-render-test-runner-style.html" > android-render-test-runner-style.html && open android-render-test-runner-style.html

Now let's edit metrics/integration/render-tests/background-color/literal/style.json, change this line:

        "background-color": "red"

to

        "background-color": "yellow"

We need to make sure that the new data.zip with the data for the render tests is installed on the device. You can use the following commands:

tar chf render-test/android/app/src/main/assets/data.zip --format=zip --files-from=render-test/android/app/src/main/assets/to_zip.txt
adb push render-test/android/app/src/main/assets/data.zip /data/local/tmp/data.zip
adb shell chmod 777 /data/local/tmp/data.zip
adb shell "run-as org.maplibre.render_test_runner unzip -o /data/local/tmp/data.zip -d files"

Rerun the render test app and reload the Device Explorer. When you re-open the HTML file with the results you should now see a failing test:

image

Now download the actual.png in metrics/integration/render-tests/background-color/literal with the Device Explorer. Replace the corresponding expected.png on your local file system. Upload the new render test data again and run the test app once more.

image

Of we don't want to commit this change. But know you can add and debug Android render tests.