···1+# Android device tests
2+3+<!--
4+Copyright 2024, Collabora, Ltd.
5+6+SPDX-License-Identifier: CC-BY-4.0
7+-->
8+9+This directory contains some tests to run on an Android device over ADB,
10+primarily to verify some lifecycle handling right now.
11+12+It uses [pytest][] as the test runner, which is more readable, maintainable, and
13+usable than the earlier bash scripts, and gives the option for e.g. junit-style
14+output for CI usage.
15+16+The actual tests are in the `test_*.py` files, while `conftest.py` configures
17+the pytest framework, as well as provides constants and fixtures for use in the
18+tests 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+40+Change your current working directory to this one. (Otherwise the extra
41+argument you need to enable the ADB tests will not be recognized by pytest.)
42+43+```sh
44+cd tests/android/
45+```
46+47+Run the following command, or one based on it:
48+49+```sh
50+pytest -v --adb
51+```
52+53+Or, 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
55+like:
56+57+```sh
58+pytest -v --adb --junit-xml=android-tests.xml -o junit_family=xunit1
59+```
60+61+Another useful options is `-k` which can be followed by a pattern used to
62+selecet a subset of tests to run. Handy if you only want to run one or two
63+tests.