fork
Configure Feed
Select the types of activity you want to include in your feed.
The open source OpenXR runtime
fork
Configure Feed
Select the types of activity you want to include in your feed.
1#!/usr/bin/env python3
2# Copyright 2024, Collabora, Ltd.
3#
4# SPDX-License-Identifier: BSL-1.0
5#
6# Author: Rylie Pavlik <rylie.pavlik@collabora.com>
7"""
8Tests of app lifecycle behavior (app pause/resume and switch).
9
10See README.md in this directory for requirements and running instructions.
11"""
12
13import time
14
15import pytest
16from conftest import helloxr_gles_activity, helloxr_vulkan_activity, helloxr_gles_pkg
17
18# Ignore missing docstrings:
19# flake8: noqa: D103
20
21skipif_not_adb = pytest.mark.skipif(
22 "not config.getoption('adb')", reason="--adb not passed to pytest"
23)
24
25# All the tests in this module require a device and ADB.
26pytestmark = [pytest.mark.adb, skipif_not_adb]
27
28
29def test_launch_and_back(adb):
30 # Launch activity
31 adb.start_activity(helloxr_gles_activity)
32 time.sleep(2)
33
34 # Press "Back"
35 adb.send_key("KEYCODE_BACK")
36
37 time.sleep(5)
38
39 adb.check_for_crash()
40
41
42def test_home_and_resume(adb):
43
44 # Launch activity
45 adb.start_activity(helloxr_gles_activity)
46 time.sleep(2)
47
48 # Press "Home"
49 adb.send_key("KEYCODE_HOME")
50 time.sleep(1)
51
52 # Press "App Switch"
53 adb.send_key("KEYCODE_APP_SWITCH")
54 time.sleep(1)
55
56 # Tap "somewhat middle" to re-select recent app
57 adb.send_tap(400, 400)
58
59 time.sleep(5)
60
61 adb.check_for_crash()
62
63
64def test_home_and_start(adb):
65
66 # Launch activity
67 adb.start_activity(helloxr_gles_activity)
68 time.sleep(2)
69
70 # Press "Home"
71 adb.send_key("KEYCODE_HOME")
72 time.sleep(2)
73
74 # Launch activity again
75 adb.start_activity(helloxr_gles_activity)
76
77 time.sleep(5)
78
79 adb.check_for_crash()
80
81
82def test_launch_second(adb):
83
84 # Launch A
85 adb.start_activity(helloxr_gles_activity)
86 time.sleep(2)
87
88 # Launch B
89 adb.start_activity(helloxr_vulkan_activity)
90
91 time.sleep(5)
92
93 adb.check_for_crash()
94
95
96def test_home_and_launch_second(adb):
97
98 # Launch A
99 adb.start_activity(helloxr_gles_activity)
100 time.sleep(2)
101
102 # Press "Home"
103 adb.send_key("KEYCODE_HOME")
104 time.sleep(2)
105
106 # Launch B
107 adb.start_activity(helloxr_vulkan_activity)
108
109 time.sleep(5)
110
111 adb.check_for_crash()
112
113
114def test_launch_a_b_a(adb):
115
116 # Launch A
117 adb.start_activity(helloxr_gles_activity)
118 time.sleep(2)
119
120 # Launch B
121 adb.start_activity(helloxr_vulkan_activity)
122 time.sleep(2)
123
124 # Launch A (again)
125 adb.start_activity(helloxr_gles_activity)
126
127 time.sleep(5)
128
129 adb.check_for_crash()