blob: be2bf41dc3fb7c42b77b924d79b1fe06971db6a3 [file] [log] [blame]
Charlie Mooney08661912015-04-16 09:20:34 -07001# Copyright 2015 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5""" This is a module containing functions that allow the test suite to
6determine the specifics of the gesture and execute them on the touchbot.
7In essence, you use this class to go from a Test object to the robot
8actually performing the correct gesture on the pad.
9"""
10
11from threading import Thread
12
13import colorama as color
14
15import tests
16from touchbot import Touchbot
17
18
19BUFFER_SIZE = 0.1
20LEFT = BUFFER_SIZE
21RIGHT = 1.0 - BUFFER_SIZE
22TOP = BUFFER_SIZE
23BOTTOM = 1.0 - BUFFER_SIZE
24CENTER = 0.5
25
26LOCATION_COORDINATES = {
27 tests.GV.TL: (LEFT, TOP),
28 tests.GV.TR: (RIGHT, TOP),
29 tests.GV.BL: (LEFT, BOTTOM),
30 tests.GV.BR: (RIGHT, BOTTOM),
31 tests.GV.TS: (CENTER, TOP),
32 tests.GV.BS: (CENTER, BOTTOM),
33 tests.GV.LS: (LEFT, CENTER),
34 tests.GV.RS: (RIGHT, CENTER),
35 tests.GV.CENTER: (CENTER, CENTER),
36}
37
38
39def PerformCorrespondingGesture(test, variation_number, robot, device_spec):
40 variation = test.variations[variation_number]
41 fn = None
42 if test.name == tests.NOISE_STATIONARY:
43 fn = lambda: _PerformStationaryNoiseTest(variation, robot, device_spec)
44
45 if fn is None:
46 print color.Fore.RED + 'Error: Robot unable to perform gesture!'
47 return None
48
49 return Thread(target=fn)
50
51def _PerformStationaryNoiseTest(variation, robot, device_spec):
52 frequency, amplitude, waveform, location = variation
Charlie Mooneyc68f9c32015-04-16 15:23:22 -070053 robot.Tap(device_spec, LOCATION_COORDINATES[location], touch_time_s=4)