The open source OpenXR runtime
1# Android device tests
2
3<!--
4Copyright 2024, Collabora, Ltd.
5
6SPDX-License-Identifier: CC-BY-4.0
7-->
8
9This directory contains some tests to run on an Android device over ADB,
10primarily to verify some lifecycle handling right now.
11
12It uses [pytest][] as the test runner, which is more readable, maintainable, and
13usable than the earlier bash scripts, and gives the option for e.g. junit-style
14output for CI usage.
15
16The actual tests are in the `test_*.py` files, while `conftest.py` configures
17the pytest framework, as well as provides constants and fixtures for use in the
18tests themselves.
19
20[pytest]: https://pytest.org
21
22## Preconditions
23
24- Have `adb` in the path, and only the device under test connected. (or, have
25 environment variables set appropriately so that
26 `adb shell getprop ro.product.vendor.device` shows you the expected device.)
27- Have Python and pytest installed, either system-wide or in a `venv`. The
28 version of pytest in Debian Bookworm is suitable.
29- Have built and installed the "outOfProcessDebug" build of Monado.
30 (`./gradlew installOOPD` in root dir)
31- Have set the out-of-process runtime as active in the OpenXR Runtime Broker (if
32 applicable).
33- Have installed both Vulkan and OpenGL ES versions of the `hello_xr` sample app
34 from Khronos. (Binaries from a release are fine.)
35- If you want the tests to pass, turn on "Draw over other apps" -- but this is
36 actually a bug to require this.
37
38## Instructions
39
40Change your current working directory to this one. (Otherwise the extra
41argument you need to enable the ADB tests will not be recognized by pytest.)
42
43```sh
44cd tests/android/
45```
46
47Run the following command, or one based on it:
48
49```sh
50pytest -v --adb
51```
52
53Or, if you want junit-style output, add a variation on these two args:
54`--junit-xml=android-tests.xml -o junit_family=xunit1` for an overall command
55like:
56
57```sh
58pytest -v --adb --junit-xml=android-tests.xml -o junit_family=xunit1
59```
60
61Another useful options is `-k` which can be followed by a pattern used to
62selecet a subset of tests to run. Handy if you only want to run one or two
63tests.