Merge ~sylvain-pineau/plainbox-provider-checkbox:touchscreen-evdev-tests into plainbox-provider-checkbox:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 2b21c124f452112a44cce4896455c1f027bfcb30
Merged at revision: 0fd759213f2f0e9ef20e7e4cd732d4d25b663d2f
Proposed branch: ~sylvain-pineau/plainbox-provider-checkbox:touchscreen-evdev-tests
Merge into: plainbox-provider-checkbox:master
Diff against target: 221 lines (+193/-0)
4 files modified
bin/evdev_touch_test.py (+75/-0)
units/touchscreen/jobs.pxu (+95/-0)
units/touchscreen/packaging.pxu (+3/-0)
units/touchscreen/test-plan.pxu (+20/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+374228@code.launchpad.net

Description of the change

New console based tests for touchscreens

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

self-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/evdev_touch_test.py b/bin/evdev_touch_test.py
2new file mode 100755
3index 0000000..5649701
4--- /dev/null
5+++ b/bin/evdev_touch_test.py
6@@ -0,0 +1,75 @@
7+#!/usr/bin/env python3
8+# This file is part of Checkbox.
9+#
10+# Copyright 2019 Canonical Ltd.
11+#
12+# Checkbox is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License version 3,
14+# as published by the Free Software Foundation.
15+#
16+# Checkbox is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
23+
24+import argparse
25+import selectors
26+import time
27+
28+import evdev
29+
30+parser = argparse.ArgumentParser()
31+parser.add_argument("name", help='Touch device product name')
32+parser.add_argument("--timeout", type=int, default=10, help='timeout')
33+parser.add_argument(
34+ "--xfingers", "-x", type=int, default=1, help="X-fingers tap event")
35+args = parser.parse_args()
36+start = time.time()
37+
38+
39+def check_timeout():
40+ if time.time() > start + args.timeout:
41+ raise SystemExit("Event not detected")
42+
43+
44+selector = selectors.DefaultSelector()
45+for d in [evdev.InputDevice(path) for path in evdev.list_devices()]:
46+ if d.name == args.name:
47+ device = d
48+ break
49+else:
50+ raise SystemExit("Touch device not found!")
51+selector.register(device, selectors.EVENT_READ)
52+
53+
54+while True:
55+ time.sleep(0.25) # sleep for 250 milliseconds
56+ check_timeout()
57+ for key, mask in selector.select(1):
58+ dev = key.fileobj
59+ for e in dev.read():
60+ tap = args.xfingers
61+ if tap == 1:
62+ if (e.type == 3 and e.code == 47 and e.value > 0):
63+ raise SystemExit(
64+ "Multitouch Event detected but Single was expected")
65+ # type 1 is evdev.ecodes.EV_KEY
66+ # code 330 is a BTN_TOUCH event
67+ # value is a boolean, 1 means a PRESS, 0 a RELEASED event
68+ if (e.type == 1 and e.code == 330 and e.value == 1):
69+ print("SUCCESS:", e)
70+ raise SystemExit
71+ else:
72+ # type 3 is evdev.ecodes.EV_ABS
73+ # code 47 is a PRESS event
74+ # value is the 0-indexed amount of simultaneous detected
75+ # fingers
76+ if (e.type == 3 and e.code == 47 and e.value == tap - 1):
77+ print("SUCCESS:", e)
78+ raise SystemExit
79+ check_timeout()
80+ else:
81+ check_timeout()
82diff --git a/units/touchscreen/jobs.pxu b/units/touchscreen/jobs.pxu
83index de55c5d..3a8a33a 100644
84--- a/units/touchscreen/jobs.pxu
85+++ b/units/touchscreen/jobs.pxu
86@@ -197,3 +197,98 @@ command:
87 {% endif %}
88 exit $EXIT
89 flags: also-after-suspend-manual
90+
91+unit: template
92+template-resource: device
93+template-filter: device.category == 'TOUCHSCREEN'
94+template-engine: jinja2
95+template-unit: job
96+plugin: user-interact
97+category_id: com.canonical.plainbox::touchscreen
98+id: touchscreen/evdev/single-touch-tap-{{ product_slug }}
99+imports: from com.canonical.plainbox import manifest
100+requires: manifest.has_touchscreen == 'True'
101+estimated_duration: 10.0
102+_description:
103+ PURPOSE:
104+ Validate that single-touch tap is properly detected
105+ STEPS:
106+ 1. Commence the test
107+ 2. Tap the screen with one finger.
108+ VERIFICATION:
109+ If the tap is not detected the test will time out after 10 seconds.
110+user: root
111+command: evdev_touch_test.py '{{ product }}' -x 1
112+flags: also-after-suspend
113+
114+unit: template
115+template-resource: device
116+template-filter: device.category == 'TOUCHSCREEN'
117+template-engine: jinja2
118+template-unit: job
119+plugin: user-interact
120+category_id: com.canonical.plainbox::touchscreen
121+id: touchscreen/evdev/2-touch-tap-{{ product_slug }}
122+imports: from com.canonical.plainbox import manifest
123+requires: manifest.has_touchscreen == 'True'
124+estimated_duration: 10.0
125+_description:
126+ PURPOSE:
127+ Validate that 2-touch tap is properly detected
128+ STEPS:
129+ 1. Commence the test
130+ 2. Tap the screen with 2 fingers simultaneously.
131+ VERIFICATION:
132+ If the tap is not detected the test will time out after 10 seconds.
133+user: root
134+command: evdev_touch_test.py '{{ product }}' -x 2
135+flags: also-after-suspend
136+after: touchscreen/evdev/single-touch-tap-{{ product_slug }}
137+
138+unit: template
139+template-resource: device
140+template-filter: device.category == 'TOUCHSCREEN'
141+template-engine: jinja2
142+template-unit: job
143+plugin: user-interact
144+category_id: com.canonical.plainbox::touchscreen
145+id: touchscreen/evdev/3-touch-tap-{{ product_slug }}
146+imports: from com.canonical.plainbox import manifest
147+requires: manifest.has_touchscreen == 'True'
148+estimated_duration: 10.0
149+_description:
150+ PURPOSE:
151+ Validate that 3-touch tap is properly detected
152+ STEPS:
153+ 1. Commence the test
154+ 2. Tap the screen with 34 fingers simultaneously.
155+ VERIFICATION:
156+ If the tap is not detected the test will time out after 10 seconds.
157+user: root
158+command: evdev_touch_test.py '{{ product }}' -x 3
159+flags: also-after-suspend
160+after: touchscreen/evdev/2-touch-tap-{{ product_slug }}
161+
162+unit: template
163+template-resource: device
164+template-filter: device.category == 'TOUCHSCREEN'
165+template-engine: jinja2
166+template-unit: job
167+plugin: user-interact
168+category_id: com.canonical.plainbox::touchscreen
169+id: touchscreen/evdev/4-touch-tap-{{ product_slug }}
170+imports: from com.canonical.plainbox import manifest
171+requires: manifest.has_touchscreen == 'True'
172+estimated_duration: 10.0
173+_description:
174+ PURPOSE:
175+ Validate that 4-touch tap is properly detected
176+ STEPS:
177+ 1. Commence the test
178+ 2. Tap the screen with 4 fingers simultaneously.
179+ VERIFICATION:
180+ If the tap is not detected the test will time out after 10 seconds.
181+user: root
182+command: evdev_touch_test.py '{{ product }}' -x 4
183+flags: also-after-suspend
184+after: touchscreen/evdev/3-touch-tap-{{ product_slug }}
185diff --git a/units/touchscreen/packaging.pxu b/units/touchscreen/packaging.pxu
186new file mode 100644
187index 0000000..9c0b9d1
188--- /dev/null
189+++ b/units/touchscreen/packaging.pxu
190@@ -0,0 +1,3 @@
191+unit: packaging meta-data
192+os-id: debian
193+Depends: python3-evdev
194diff --git a/units/touchscreen/test-plan.pxu b/units/touchscreen/test-plan.pxu
195index cfe9907..f53e3dd 100644
196--- a/units/touchscreen/test-plan.pxu
197+++ b/units/touchscreen/test-plan.pxu
198@@ -75,3 +75,23 @@ include:
199 after-suspend-manual-touchscreen/multitouch-zoom certification-status=blocker
200 after-suspend-manual-touchscreen/3-touch-tap certification-status=blocker
201 after-suspend-manual-touchscreen/4-touch-tap certification-status=blocker
202+
203+id: touchscreen-evdev
204+unit: test plan
205+_name: Touchscreen evdev tests
206+_description:
207+ Touchscreen evdev tests
208+include:
209+ touchscreen/evdev.*
210+bootstrap_include:
211+ device
212+
213+id: after-suspend-touchscreen-evdev
214+unit: test plan
215+_name: Touchscreen evdev tests
216+_description:
217+ Touchscreen evdev tests
218+include:
219+ after-suspend-touchscreen/evdev.*
220+bootstrap_include:
221+ device

Subscribers

People subscribed via source and target branches