diff options
author | Sylvain Pineau <sylvain.pineau@canonical.com> | 2019-10-16 18:51:49 +0200 |
---|---|---|
committer | Sylvain Pineau <sylvain.pineau@canonical.com> | 2019-10-16 18:51:49 +0200 |
commit | 2b21c124f452112a44cce4896455c1f027bfcb30 (patch) | |
tree | e60b3d20e2f4fcdfad264cec7580b246889db193 | |
parent | 5a17231d343d45da82f3062e526bbd4c62723aa5 (diff) |
units:touchscreen: New evdev tap tests (no GUI)
-rwxr-xr-x | bin/evdev_touch_test.py | 75 | ||||
-rw-r--r-- | units/touchscreen/jobs.pxu | 95 | ||||
-rw-r--r-- | units/touchscreen/packaging.pxu | 3 | ||||
-rw-r--r-- | units/touchscreen/test-plan.pxu | 20 |
4 files changed, 193 insertions, 0 deletions
diff --git a/bin/evdev_touch_test.py b/bin/evdev_touch_test.py new file mode 100755 index 0000000..5649701 --- /dev/null +++ b/bin/evdev_touch_test.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +# This file is part of Checkbox. +# +# Copyright 2019 Canonical Ltd. +# +# Checkbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. +# +# Checkbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. + +import argparse +import selectors +import time + +import evdev + +parser = argparse.ArgumentParser() +parser.add_argument("name", help='Touch device product name') +parser.add_argument("--timeout", type=int, default=10, help='timeout') +parser.add_argument( + "--xfingers", "-x", type=int, default=1, help="X-fingers tap event") +args = parser.parse_args() +start = time.time() + + +def check_timeout(): + if time.time() > start + args.timeout: + raise SystemExit("Event not detected") + + +selector = selectors.DefaultSelector() +for d in [evdev.InputDevice(path) for path in evdev.list_devices()]: + if d.name == args.name: + device = d + break +else: + raise SystemExit("Touch device not found!") +selector.register(device, selectors.EVENT_READ) + + +while True: + time.sleep(0.25) # sleep for 250 milliseconds + check_timeout() + for key, mask in selector.select(1): + dev = key.fileobj + for e in dev.read(): + tap = args.xfingers + if tap == 1: + if (e.type == 3 and e.code == 47 and e.value > 0): + raise SystemExit( + "Multitouch Event detected but Single was expected") + # type 1 is evdev.ecodes.EV_KEY + # code 330 is a BTN_TOUCH event + # value is a boolean, 1 means a PRESS, 0 a RELEASED event + if (e.type == 1 and e.code == 330 and e.value == 1): + print("SUCCESS:", e) + raise SystemExit + else: + # type 3 is evdev.ecodes.EV_ABS + # code 47 is a PRESS event + # value is the 0-indexed amount of simultaneous detected + # fingers + if (e.type == 3 and e.code == 47 and e.value == tap - 1): + print("SUCCESS:", e) + raise SystemExit + check_timeout() + else: + check_timeout() diff --git a/units/touchscreen/jobs.pxu b/units/touchscreen/jobs.pxu index de55c5d..3a8a33a 100644 --- a/units/touchscreen/jobs.pxu +++ b/units/touchscreen/jobs.pxu @@ -197,3 +197,98 @@ command: {% endif %} exit $EXIT flags: also-after-suspend-manual + +unit: template +template-resource: device +template-filter: device.category == 'TOUCHSCREEN' +template-engine: jinja2 +template-unit: job +plugin: user-interact +category_id: com.canonical.plainbox::touchscreen +id: touchscreen/evdev/single-touch-tap-{{ product_slug }} +imports: from com.canonical.plainbox import manifest +requires: manifest.has_touchscreen == 'True' +estimated_duration: 10.0 +_description: + PURPOSE: + Validate that single-touch tap is properly detected + STEPS: + 1. Commence the test + 2. Tap the screen with one finger. + VERIFICATION: + If the tap is not detected the test will time out after 10 seconds. +user: root +command: evdev_touch_test.py '{{ product }}' -x 1 +flags: also-after-suspend + +unit: template +template-resource: device +template-filter: device.category == 'TOUCHSCREEN' +template-engine: jinja2 +template-unit: job +plugin: user-interact +category_id: com.canonical.plainbox::touchscreen +id: touchscreen/evdev/2-touch-tap-{{ product_slug }} +imports: from com.canonical.plainbox import manifest +requires: manifest.has_touchscreen == 'True' +estimated_duration: 10.0 +_description: + PURPOSE: + Validate that 2-touch tap is properly detected + STEPS: + 1. Commence the test + 2. Tap the screen with 2 fingers simultaneously. + VERIFICATION: + If the tap is not detected the test will time out after 10 seconds. +user: root +command: evdev_touch_test.py '{{ product }}' -x 2 +flags: also-after-suspend +after: touchscreen/evdev/single-touch-tap-{{ product_slug }} + +unit: template +template-resource: device +template-filter: device.category == 'TOUCHSCREEN' +template-engine: jinja2 +template-unit: job +plugin: user-interact +category_id: com.canonical.plainbox::touchscreen +id: touchscreen/evdev/3-touch-tap-{{ product_slug }} +imports: from com.canonical.plainbox import manifest +requires: manifest.has_touchscreen == 'True' +estimated_duration: 10.0 +_description: + PURPOSE: + Validate that 3-touch tap is properly detected + STEPS: + 1. Commence the test + 2. Tap the screen with 34 fingers simultaneously. + VERIFICATION: + If the tap is not detected the test will time out after 10 seconds. +user: root +command: evdev_touch_test.py '{{ product }}' -x 3 +flags: also-after-suspend +after: touchscreen/evdev/2-touch-tap-{{ product_slug }} + +unit: template +template-resource: device +template-filter: device.category == 'TOUCHSCREEN' +template-engine: jinja2 +template-unit: job +plugin: user-interact +category_id: com.canonical.plainbox::touchscreen +id: touchscreen/evdev/4-touch-tap-{{ product_slug }} +imports: from com.canonical.plainbox import manifest +requires: manifest.has_touchscreen == 'True' +estimated_duration: 10.0 +_description: + PURPOSE: + Validate that 4-touch tap is properly detected + STEPS: + 1. Commence the test + 2. Tap the screen with 4 fingers simultaneously. + VERIFICATION: + If the tap is not detected the test will time out after 10 seconds. +user: root +command: evdev_touch_test.py '{{ product }}' -x 4 +flags: also-after-suspend +after: touchscreen/evdev/3-touch-tap-{{ product_slug }} diff --git a/units/touchscreen/packaging.pxu b/units/touchscreen/packaging.pxu new file mode 100644 index 0000000..9c0b9d1 --- /dev/null +++ b/units/touchscreen/packaging.pxu @@ -0,0 +1,3 @@ +unit: packaging meta-data +os-id: debian +Depends: python3-evdev diff --git a/units/touchscreen/test-plan.pxu b/units/touchscreen/test-plan.pxu index cfe9907..f53e3dd 100644 --- a/units/touchscreen/test-plan.pxu +++ b/units/touchscreen/test-plan.pxu @@ -75,3 +75,23 @@ include: after-suspend-manual-touchscreen/multitouch-zoom certification-status=blocker after-suspend-manual-touchscreen/3-touch-tap certification-status=blocker after-suspend-manual-touchscreen/4-touch-tap certification-status=blocker + +id: touchscreen-evdev +unit: test plan +_name: Touchscreen evdev tests +_description: + Touchscreen evdev tests +include: + touchscreen/evdev.* +bootstrap_include: + device + +id: after-suspend-touchscreen-evdev +unit: test plan +_name: Touchscreen evdev tests +_description: + Touchscreen evdev tests +include: + after-suspend-touchscreen/evdev.* +bootstrap_include: + device |