ninja -C out/Debug chrome_public_test_vr_apk && out/Debug/bin/run_chrome_public_test_vr_apk --num-retries=0 --shared-prefs-file=//chrome/android/shared_preference_files/test/vr_ddview_skipdon_setupcomplete.json --test-filter=<failing test case>
Don't touch phone while the tests are running.NOTE The message “Main Unable to find package info for org.chromium.chrome” is usually displayed when the test package is being installed and does not indicate any problem.
This directory contains all the Java-side infrastructure for running instrumentation tests for XR (VR/Virtual Reality and AR/Augmented Reality) features currently in Chrome:
These tests are integration/end-to-end tests run in the full Chromium browser on actual Android devices.
These are the files and directories that are relevant to XR instrumentation testing.
mock/
- Contains all the classes for mock implementations of XR classes.nfc_apk/
- Contains the code for the standalone APK for NFC simulation. Used by Telemetry tests, not instrumentation tests, but kept here since it uses code from util/
.rules/
- Contains all the XR-specific JUnit4 rules for handling functionality such as running tests multiple times in different activities and handling the fake VR pose tracker service.util/
- Contains utility classes with code that is used by multiple test classes and that does not make sense to include in the core test framework.//chrome/android/shared_preferences_files/test
- Contains the VrCore settings files for running VR instrumentation tests (see the “Building and Running” section for more information).//chrome/test/data/xr/e2e_test_files/
- Contains the JavaScript and HTML files for XR instrumentation tests.//third_party/gvr-android-sdk/test-apks
- Contains the VR APKs used for testing, such as VrCore. You must have DOWNLOAD_VR_TEST_APKS
set as an environment variable when you run gclient runhooks in order to actually download these from storage.//third_party/gvr-android-sdk/test-libraries
- Contains third party VR testing libraries. Currently, only has the Daydream controller test library used for sending controller events to VrCore using intents.//third_party/arcore-android-sdk/test-apks
- Contains the AR APKs used for testing, such as ArCore. You must have DOWNLOAD_VR_TEST_APKS
set as an environment variable when you run gclient runhooks in order to actually download these from storage.The AR instrumentation tests can be built with the monochrome_public_test_ar_apk
target, which will also build monochrome_public_apk
to test with.
The VR instrumentation tests can be built with the chrome_public_test_vr_apk
target, which will also build chrome_public_apk
to test with.
Both the VR and AR tests are run using the generated script in your build output directory's bin/
directory, e.g. out/foo/bin/run_chrome_public_test_vr_apk
to run the VR tests. You will likely need to pass some or all of the following arguments in order for the tests to run properly, though.
NOTE The instrumentation tests can only be run on rooted devices.
--additional-apk path/to/apk/to/install
Installs the specified APK before running the tests. No-ops if the provided APK is already installed on the device and their versions match.
For VR tests, you'll likely want to use --additional-apk third_party/gvr-android-sdk/test-apks/vr_services/vr_services_current.apk
to ensure that the VrCore version used is the one used for automated testing at whatever your current git revision is.
For AR tests, you'll likely want to use --additional-apk third_party/arcore-android-sdk/test-apks/arcore/arcore_current.apk
to ensure that the ArCore version used is the one used for automated testing at whatever your current git revision is.
NOTE Using this argument for VR on most Pixel devices will fail, as VrCore is pre-installed as a system app. This can be dealt with in the following ways:
--replace-system-package com.google.vr.vrcore,//third_party/gvr-android-sdk/test-apks/vr_services/vr_services_current.apk
instead. This will take significantly longer, as it requires rebooting, and must be done every time you run the tests.--test-filter TestClass#TestCase
Allows you to limit the set of tests run to a particular test class or subset of tests within a test class. Use of the *
wildcard is supported, e.g. --test-filter VrBrowserTransitionTest#*
will run all tests in the VrBrowserTransitionTest class.
--local-output --json-results-file output.json
Sets the test runner to generate a local results summary after running all tests and print out a file URL pointing to the summary. This allows you to view both logcat output for a particular test and its post-failure screenshot.
--num-retries <#>
Sets the test runner to retry failed tests a certain number of times. The default is 2, resulting in a max of 3 test runs. Usually used as --num-retries 0
when debugging to reduce test runtime and make flakiness more visible.
--repeat <#>
Sets the test runner to repeat the tests a certain number of times. The default is 0, resulting in only one iteration. Usually used to repeat a test many times in order to check for or reproduce flakiness.
--shared-prefs-file path/to/preference/json/file
Configures VrCore according to the provided file, e.g. changing the paired headset. The two most common files used are:
//chrome/android/shared_preference_files/test/vr_cardboard_skipdon_setupcomplete.json
This will pair the device with a Cardboard headset and disable controller emulation.//chrome/android/shared_preference_files/test/vr_ddview_skipdon_setupcomplete.json
This will pair the device with a Daydream View headset, set the DON flow to be skipped, and enable controller emulation.The test runner will automatically revert any changed settings back to their pre-test values after the test suite has completed. If for whatever reason you want to manually apply settings outside of a test, you can do so with //build/android/apply_shared_preference_file.py
.
--vr-settings-service-enabled --annotation=Restriction=VR_Settings_Service
Tells the test runner to allow the running of tests that utilize the VR settings service to dynamically change VrCore settings during a test instead of relying on whatever was set by the shared preference file that was applied. This is used as a catch-all for less standard tests, such as those that require the DON flow to be enabled or that need to switch the paired viewer mid-test.
This should only be used when --shared-prefs-file
is passed //chrome/android/shared_preference_files/test/vr_enable_vr_settings_service.json
as otherwise trying to use the service will be a NOOP.
See adding_new_tests.md.