Using AutoDriver to Record Inputs
AutoDriver is a VrApi layer that, when enabled, records user headset, controller, and hand tracking inputs, as well as tracking data. These recorded inputs can then be played back so applications can reuse them for automated testing where user input is required.
Important
AutoDriverX does not currently support OpenXR.When creating a test that requires a sequence of user inputs, AutoDriver can be used to both:
- Initially define and record those inputs.
- Automatically play back those inputs during end-to-end (E2E) testing.
This topic covers how to create an AutoDriver recording that you can use in your E2E test. AutoDriver is built into the OS, so there is no need to install anything to use it. When the appropriate system properties are set, AutoDriver will automatically begin recording or playing back immediately when the target app starts up. The following sections cover how to create and play back an AutoDriver recording using either batch files (recommended) or manually.
Create a Recording Using the Batch Files
The easiest way to create an AutoDriver recording is to use the
batch files provided on our Downloads page. The batch files contain more detailed parameter documentation, but basic usage is as described in the following sections.
Set up the Environment Variables Before running the script, you need to make sure the Meta Quest is connected to the computer via adb
and set the following variables. In particular, TEST_CLASS
and TEST_ACTIVITY
need to be set properly or else the script won’t be able to start up your app for recording.
# Choose any name that you want.
$env:TEST_NAME='MyFirstRecording'
# The class and activity names must match those in the app you want to record in.
$env:TEST_CLASS='com.oculus.PackageName’
$env:TEST_ACTIVITY='com.oculus.MainActivity’
# This is how long your recording session will last.
$env:TEST_SECONDS='45'
Run the RecordAutoDriverInputs.bat
script. The script will launch the target app in record mode. Put on the headset and pick up the controllers when prompted and start entering the inputs you want recorded. After $TEST_SECONDS
have elapsed, the recording will stop and the app will be closed. The script will then tell you where you can find the outputs, in the current run directory:
===== Outputs: MyFirstRecording =====
Your user inputs were saved here: MyFirstRecording.autodriver
Complete logcat saved here: MyFirstRecording.logcat.txt
The *.autodriver
file is the file that you will use to play back these inputs during a test. The logcat captures can also be useful if you are writing a regression test that will examine the logcat output for correctness.
Play Back AutoDriver Recording Before creating an E2E test from your newly created AutoDriver recording, you should first sanity check it by playing it back. It’s particularly convenient to run the playback script right after you’ve run the recording script because it uses the same environment variables you set up during the record stage. Run the PlaybackAutoDriverInputs.bat
script and put on the headset to sanity check that the recording was captured properly.
If the new *.autodriver
file passes your sanity check, save it. You will need it when you create your E2E test. Use the playback AutoDriver recording commands during the setup of your test to ensure that your AutoDriver recording will start when your test app starts up.
Create a Recording Manually
We recommend that you use the batch files described above to create your AutoDriver recordings. However, for completeness, this section describes the manual steps you could use to capture and play back an AutoDriver recording. Note that it does not include the commands to capture the logcat output, which is something the above scripts will do for you automatically.
Set Up Environment Variables
# Choose any name that you want.
$env:TEST_NAME='MyFirstRecording'
# The class and activity names must match those in the app you want to record in.
$env:TEST_CLASS='com.oculus.PackageName’
$env:TEST_ACTIVITY='com.oculus.MainActivity’
Record Your Inputs
# Set AutoDriver properties.
adb.exe shell setprop debug.oculus.vrapilayers AutoDriver
adb.exe shell setprop debug.oculus.autoDriverApp $env:TEST_CLASS
adb.exe shell setprop debug.oculus.autoDriverMode Record
# Launch the app.
adb.exe shell am start -S $env:TEST_CLASS/$env:TEST_ACTIVITY
# End the app when you are finished.
adb.exe shell am broadcast -a com.oculus.vrapilayers.AutoDriver.SHUTDOWN
adb.exe shell am force-stop $env:TEST_CLASS
# Fetch your new autodriver file.
adb.exe pull /sdcard/Android/data/$env:TEST_CLASS/AutoDriver/default.autodriver "./$env:TEST_NAME.autodriver"
Play Back AutoDriver Recording
When using an AutoDriver recording in an E2E test, use these commands during test setup:
# Copy the autodriver recording to the device.
adb.exe push "$env:TEST_NAME.autodriver" /sdcard/Android/data/$env:TEST_CLASS/AutoDriver/default.autodriver
# Set AutoDriver properties.
adb.exe shell setprop debug.oculus.vrapilayers AutoDriver
adb.exe shell setprop debug.oculus.autoDriverApp $env:TEST_CLASS
adb.exe shell setprop debug.oculus.autoDriverMode Playback
adb.exe shell setprop debug.oculus.autoDriverPlaybackHeadMode HeadLocked
# Launch the app.
adb.exe shell am start -S $env:TEST_CLASS/$env:TEST_ACTIVITY
# End the app when you are finished.
adb.exe shell am force-stop $env:TEST_CLASS