Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 1 | # 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 |
| 6 | determine the specifics of the gesture and execute them on the touchbot. |
| 7 | In essence, you use this class to go from a Test object to the robot |
| 8 | actually performing the correct gesture on the pad. |
| 9 | """ |
| 10 | |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 11 | import math |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 12 | from threading import Thread |
| 13 | |
| 14 | import colorama as color |
| 15 | |
| 16 | import tests |
| 17 | from touchbot import Touchbot |
| 18 | |
| 19 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 20 | STANDARD_FINGERTIP = '1round_9mm' |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 21 | STANDARD_SECONDARY_FINGERTIP = '2round_9mm' |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 22 | FAT_FINGERTIP = '1round_14mm' |
| 23 | FAT_SECONDARY_FINGERTIP = '2round_14mm' |
| 24 | NOISE_TESTING_FINGERTIP = '1round_12mm' |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 25 | THREE_FINGER_FINGERTIP = 'three_fingers' |
| 26 | FOUR_FINGER_FINGERTIP = 'four_fingers' |
| 27 | FIVE_FINGER_FINGERTIP = 'five_fingers' |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 28 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 29 | BUFFER_SIZE = 0.1 |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 30 | OVERSHOOT_DISTANCE = 0.05 |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 31 | LEFT = BUFFER_SIZE |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 32 | OVER_LEFT = -OVERSHOOT_DISTANCE |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 33 | RIGHT = 1.0 - BUFFER_SIZE |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 34 | OVER_RIGHT = 1.0 + OVERSHOOT_DISTANCE |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 35 | TOP = BUFFER_SIZE |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 36 | OVER_TOP = -OVERSHOOT_DISTANCE |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 37 | BOTTOM = 1.0 - BUFFER_SIZE |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 38 | OVER_BOTTOM = 1.0 + OVERSHOOT_DISTANCE |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 39 | CENTER = 0.5 |
| 40 | |
| 41 | LOCATION_COORDINATES = { |
| 42 | tests.GV.TL: (LEFT, TOP), |
| 43 | tests.GV.TR: (RIGHT, TOP), |
| 44 | tests.GV.BL: (LEFT, BOTTOM), |
| 45 | tests.GV.BR: (RIGHT, BOTTOM), |
| 46 | tests.GV.TS: (CENTER, TOP), |
| 47 | tests.GV.BS: (CENTER, BOTTOM), |
| 48 | tests.GV.LS: (LEFT, CENTER), |
| 49 | tests.GV.RS: (RIGHT, CENTER), |
| 50 | tests.GV.CENTER: (CENTER, CENTER), |
| 51 | } |
| 52 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 53 | LINE_DIRECTION_COORDINATES = { |
| 54 | tests.GV.LR: ((LEFT, CENTER), (RIGHT, CENTER)), |
| 55 | tests.GV.RL: ((RIGHT, CENTER), (LEFT, CENTER)), |
| 56 | tests.GV.TB: ((CENTER, TOP), (CENTER, BOTTOM)), |
| 57 | tests.GV.BT: ((CENTER, BOTTOM), (CENTER, TOP)), |
| 58 | tests.GV.BLTR: ((LEFT, BOTTOM), (RIGHT, TOP)), |
| 59 | tests.GV.BRTL: ((RIGHT, BOTTOM), (LEFT, TOP)), |
| 60 | tests.GV.TRBL: ((RIGHT, TOP), (LEFT, BOTTOM)), |
| 61 | tests.GV.TLBR: ((LEFT, TOP), (RIGHT, BOTTOM)), |
| 62 | tests.GV.CL: ((CENTER, CENTER), (OVER_LEFT, CENTER)), |
| 63 | tests.GV.CR: ((CENTER, CENTER), (OVER_RIGHT, CENTER)), |
| 64 | tests.GV.CT: ((CENTER, CENTER), (CENTER, OVER_TOP)), |
| 65 | tests.GV.CB: ((CENTER, CENTER), (CENTER, OVER_BOTTOM)), |
| 66 | tests.GV.CUL: ((CENTER, CENTER), (OVER_LEFT, OVER_TOP)), |
| 67 | tests.GV.CLL: ((CENTER, CENTER), (OVER_LEFT, OVER_BOTTOM)), |
| 68 | tests.GV.CLR: ((CENTER, CENTER), (OVER_RIGHT, OVER_BOTTOM)), |
| 69 | } |
| 70 | |
Charlie Mooney | 9a17768 | 2015-06-16 15:24:36 -0700 | [diff] [blame] | 71 | STATIONARY_FINGER_LOCATION = { |
| 72 | tests.GV.LR: LOCATION_COORDINATES[tests.GV.TS], |
| 73 | tests.GV.RL: LOCATION_COORDINATES[tests.GV.BS], |
| 74 | tests.GV.TB: LOCATION_COORDINATES[tests.GV.LS], |
| 75 | tests.GV.BT: LOCATION_COORDINATES[tests.GV.RS], |
| 76 | } |
| 77 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 78 | SPEEDS = { |
| 79 | tests.GV.NORMAL: Touchbot.SPEED_MEDIUM, |
| 80 | tests.GV.SLOW: Touchbot.SPEED_SLOW, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 81 | tests.GV.FAST: Touchbot.SPEED_FAST, |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 84 | ANGLES = { |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 85 | tests.GV.HORIZONTAL: 0, |
| 86 | tests.GV.VERTICAL: 90, |
| 87 | tests.GV.DIAGONAL: 45, |
| 88 | } |
| 89 | |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 90 | ONE_FINGERTIP_TAP_TESTS = [ |
| 91 | tests.ONE_FINGER_TAP, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 92 | tests.REPEATED_TAPS, |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 93 | tests.THREE_FINGER_TAP, |
| 94 | tests.FOUR_FINGER_TAP, |
| 95 | tests.FIVE_FINGER_TAP, |
| 96 | ] |
| 97 | |
| 98 | TAP_TEST_FINGERTIPS = { |
| 99 | tests.ONE_FINGER_TAP: STANDARD_FINGERTIP, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 100 | tests.REPEATED_TAPS: STANDARD_FINGERTIP, |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 101 | tests.THREE_FINGER_TAP: THREE_FINGER_FINGERTIP, |
| 102 | tests.FOUR_FINGER_TAP: FOUR_FINGER_FINGERTIP, |
| 103 | tests.FIVE_FINGER_TAP: FIVE_FINGER_FINGERTIP, |
| 104 | } |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 105 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 106 | SINGLE_FINGER_LINE_TESTS = [ |
| 107 | tests.ONE_FINGER_TO_EDGE, |
| 108 | tests.ONE_FINGER_TRACKING, |
| 109 | tests.ONE_FINGER_TRACKING_FROM_CENTER, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 110 | tests.ONE_FINGER_SWIPE, |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 111 | ] |
| 112 | |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 113 | TWO_FINGER_LINE_TESTS = [ |
| 114 | tests.TWO_FINGER_TRACKING, |
| 115 | tests.TWO_CLOSE_FINGERS_TRACKING, |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 116 | tests.TWO_FAT_FINGERS_TRACKING, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 117 | tests.TWO_FINGER_SWIPE, |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 118 | ] |
| 119 | |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 120 | PHYSICAL_CLICK_TESTS = [ |
| 121 | tests.ONE_FINGER_PHYSICAL_CLICK, |
| 122 | tests.TWO_FINGER_PHYSICAL_CLICK, |
| 123 | ] |
| 124 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 125 | |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 126 | def _ComputePerpendicularAngle(start, end): |
| 127 | """ Compute the fingertip angle to be perpendicular to the |
| 128 | movement direction. |
| 129 | |
| 130 | The robot's X/Y axes are not in the same direction as the touch device's, |
| 131 | they are flipped. |
| 132 | |
| 133 | DUT x ----> Robot y ----> |
| 134 | y x |
| 135 | | | |
| 136 | | | |
| 137 | \/ \/ |
| 138 | |
| 139 | As a result the angle is computed in the DUT space, but then must have |
| 140 | its sign flipped before being used in any commands to the robot or |
| 141 | everything will be wrong since it's a clockwise angle instead of counter- |
| 142 | clockwise. |
| 143 | """ |
| 144 | x1, y1 = start |
| 145 | x2, y2 = end |
| 146 | dy = y2 - y1 |
| 147 | dx = x2 - x1 |
| 148 | return -1 * (math.degrees(math.atan2(y2 - y1, x2 - x1)) + 90) |
| 149 | |
| 150 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 151 | def PerformCorrespondingGesture(test, variation_number, robot, device_spec): |
| 152 | variation = test.variations[variation_number] |
| 153 | fn = None |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 154 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 155 | if test.name == tests.NOISE_STATIONARY: |
| 156 | fn = lambda: _PerformStationaryNoiseTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 157 | |
Charlie Mooney | 2107d6b | 2015-08-07 11:16:59 -0700 | [diff] [blame] | 158 | elif test.name == tests.NOISE_LINE: |
| 159 | fn = lambda: _PerformLineNoiseTest(variation, robot, device_spec) |
| 160 | |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 161 | elif test.name in ONE_FINGERTIP_TAP_TESTS: |
| 162 | fingertip = robot.fingertips[TAP_TEST_FINGERTIPS[test.name]] |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 163 | num_taps = 20 if test.name == tests.REPEATED_TAPS else 1 |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 164 | vertical_offset = 0 |
| 165 | if test.name != tests.ONE_FINGER_TAP: |
| 166 | vertical_offset = robot.LARGE_FINGERTIP_VERTICAL_OFFSET |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 167 | fn = lambda: _PerformOneFingertipTapTest( |
| 168 | variation, robot, device_spec, fingertip, |
| 169 | vertical_offset, num_taps) |
| 170 | |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 171 | elif test.name == tests.TWO_FINGER_TAP: |
| 172 | fn = lambda: _PerformTwoFingerTapTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 173 | |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 174 | elif test.name in PHYSICAL_CLICK_TESTS: |
| 175 | fingertips = [robot.fingertips[STANDARD_FINGERTIP]] |
| 176 | if test.name == tests.TWO_FINGER_PHYSICAL_CLICK: |
| 177 | fingertips.append(robot.fingertips[STANDARD_SECONDARY_FINGERTIP]) |
| 178 | fn = lambda: _PerformPhysicalClickTest(variation, robot, device_spec, |
| 179 | fingertips) |
| 180 | |
Charlie Mooney | 9426d0c | 2015-07-01 15:03:45 -0700 | [diff] [blame] | 181 | elif test.name == tests.DRUMROLL: |
| 182 | fn = lambda: _PerformDrumroll(variation, robot, device_spec) |
| 183 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 184 | elif test.name in SINGLE_FINGER_LINE_TESTS: |
| 185 | pause = 1 if test.name == tests.ONE_FINGER_TRACKING_FROM_CENTER else 0 |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 186 | is_swipe = (test.name == tests.ONE_FINGER_SWIPE) |
| 187 | fn = lambda: _PerformOneFingerLineTest(variation, robot, device_spec, |
| 188 | pause, is_swipe) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 189 | |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 190 | elif test.name in TWO_FINGER_LINE_TESTS: |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 191 | spacing = 5 |
| 192 | fingertips = [robot.fingertips[STANDARD_FINGERTIP], |
| 193 | robot.fingertips[STANDARD_SECONDARY_FINGERTIP]] |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 194 | is_swipe = (test.name == tests.TWO_FINGER_SWIPE) |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 195 | if test.name == tests.TWO_CLOSE_FINGERS_TRACKING: |
| 196 | spacing = 0 |
| 197 | elif test.name == tests.TWO_FAT_FINGERS_TRACKING: |
| 198 | spacing = 10 |
| 199 | fingertips = [robot.fingertips[FAT_FINGERTIP], |
| 200 | robot.fingertips[FAT_SECONDARY_FINGERTIP]] |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 201 | fn = lambda: _PerformTwoFingerLineTest(variation, robot, device_spec, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 202 | fingertips, spacing, is_swipe) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 203 | |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 204 | elif test.name == tests.RESTING_FINGER_PLUS_2ND_FINGER_MOVE: |
Charlie Mooney | 9a17768 | 2015-06-16 15:24:36 -0700 | [diff] [blame] | 205 | moving_fingertip = robot.fingertips[STANDARD_SECONDARY_FINGERTIP] |
| 206 | stationary_location = LOCATION_COORDINATES[tests.GV.BL] |
| 207 | fn = lambda: _PerformRestingFingerTest(variation, robot, device_spec, |
| 208 | moving_fingertip, |
| 209 | stationary_location) |
| 210 | |
| 211 | elif test.name == tests.FAT_FINGER_MOVE_WITH_RESTING_FINGER: |
| 212 | moving_fingertip = robot.fingertips[FAT_SECONDARY_FINGERTIP] |
| 213 | direction, speed = variation |
| 214 | stationary_location = STATIONARY_FINGER_LOCATION[direction] |
| 215 | fn = lambda: _PerformRestingFingerTest(variation, robot, device_spec, |
| 216 | moving_fingertip, |
| 217 | stationary_location) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 218 | |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 219 | elif test.name == tests.PINCH_TO_ZOOM: |
| 220 | fn = lambda: _PerformPinchTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 221 | |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 222 | elif test.name == tests.DRAG_THUMB_EDGE: |
| 223 | fn = lambda: _PerformThumbEdgeTest(variation, robot, device_spec) |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 224 | |
Charlie Mooney | 030267f | 2016-02-05 15:34:26 -0800 | [diff] [blame] | 225 | elif test.name == tests.SQUARE_RESOLUTION: |
| 226 | fn = lambda: _PerformSquareResolutionTest(variation, robot, device_spec) |
| 227 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 228 | if fn is None: |
Charlie Mooney | ca3fc20 | 2015-05-21 11:16:53 -0700 | [diff] [blame] | 229 | print color.Fore.RED + 'Robot unable to perform gesture! Skipping...' |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 230 | return None |
| 231 | |
| 232 | return Thread(target=fn) |
| 233 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 234 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 235 | def _PerformStationaryNoiseTest(variation, robot, device_spec): |
| 236 | frequency, amplitude, waveform, location = variation |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 237 | tap_position = LOCATION_COORDINATES[location] |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 238 | fingertip = robot.fingertips[NOISE_TESTING_FINGERTIP] |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 239 | robot.Tap(device_spec, [fingertip], tap_position, touch_time_s=4) |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 240 | |
Charlie Mooney | 2107d6b | 2015-08-07 11:16:59 -0700 | [diff] [blame] | 241 | def _PerformLineNoiseTest(variation, robot, device_spec): |
| 242 | frequency, amplitude, waveform, direction = variation |
| 243 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 244 | fingertip = robot.fingertips[NOISE_TESTING_FINGERTIP] |
| 245 | robot.Line(device_spec, [fingertip], start, end, pause_s=1, swipe=False) |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 246 | |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 247 | def _PerformOneFingertipTapTest(variation, robot, device_spec, fingertip, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 248 | vertical_offset, num_taps): |
Charlie Mooney | 1b70811 | 2015-04-28 14:46:21 -0700 | [diff] [blame] | 249 | location, = variation |
| 250 | tap_position = LOCATION_COORDINATES[location] |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 251 | robot.Tap(device_spec, [fingertip], tap_position, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 252 | vertical_offset=vertical_offset, num_taps=num_taps) |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 253 | |
| 254 | |
| 255 | def _PerformTwoFingerTapTest(variation, robot, device_spec): |
| 256 | angle, = variation |
| 257 | |
| 258 | fingertip1 = robot.fingertips[STANDARD_FINGERTIP] |
| 259 | fingertip2 = robot.fingertips[STANDARD_SECONDARY_FINGERTIP] |
| 260 | fingertips = [fingertip1, fingertip2] |
| 261 | |
| 262 | robot.Tap(device_spec, fingertips, (CENTER, CENTER), angle=ANGLES[angle]) |
Charlie Mooney | 1b70811 | 2015-04-28 14:46:21 -0700 | [diff] [blame] | 263 | |
| 264 | |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 265 | def _PerformOneFingerLineTest(variation, robot, device_spec, pause_time_s, |
| 266 | is_swipe): |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 267 | direction, speed = variation |
| 268 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 269 | fingertip = robot.fingertips[STANDARD_FINGERTIP] |
| 270 | |
| 271 | robot.PushSpeed(SPEEDS[speed]) |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 272 | robot.Line(device_spec, [fingertip], start, end, pause_s=pause_time_s, |
| 273 | swipe=is_swipe) |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 274 | robot.PopSpeed() |
| 275 | |
| 276 | |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 277 | def _PerformTwoFingerLineTest(variation, robot, device_spec, fingertips, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 278 | spacing_mm, is_swipe): |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 279 | direction, speed = variation |
| 280 | start, end = LINE_DIRECTION_COORDINATES[direction] |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 281 | angle = _ComputePerpendicularAngle(start, end) |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 282 | |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 283 | robot.PushSpeed(SPEEDS[speed]) |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 284 | robot.Line(device_spec, fingertips, start, end, fingertip_spacing=spacing_mm, |
| 285 | fingertip_angle=angle, swipe=is_swipe) |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 286 | robot.PopSpeed() |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 287 | |
| 288 | |
Charlie Mooney | 9a17768 | 2015-06-16 15:24:36 -0700 | [diff] [blame] | 289 | def _PerformRestingFingerTest(variation, robot, device_spec, moving_fingertip, |
| 290 | stationary_location): |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 291 | direction, speed = variation |
| 292 | start, end = LINE_DIRECTION_COORDINATES[direction] |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 293 | |
| 294 | stationary_fingertip = robot.fingertips[STANDARD_FINGERTIP] |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 295 | |
| 296 | robot.PushSpeed(SPEEDS[speed]) |
| 297 | robot.LineWithStationaryFinger(device_spec, stationary_fingertip, |
| 298 | moving_fingertip, start, end, |
| 299 | stationary_location) |
| 300 | robot.PopSpeed() |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 301 | |
| 302 | def _PerformPinchTest(variation, robot, device_spec): |
| 303 | direction, angle = variation |
| 304 | |
| 305 | min_spread = 15 |
| 306 | max_spread = min(device_spec.Height(), device_spec.Width(), |
| 307 | robot.MAX_FINGER_DISTANCE) |
| 308 | if direction == tests.GV.ZOOM_OUT: |
| 309 | start_distance, end_distance = max_spread, min_spread |
| 310 | else: |
| 311 | start_distance, end_distance = min_spread, max_spread |
| 312 | |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 313 | fingertips = [robot.fingertips[STANDARD_FINGERTIP], |
| 314 | robot.fingertips[STANDARD_SECONDARY_FINGERTIP]] |
| 315 | |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 316 | robot.PushSpeed(SPEEDS[tests.GV.NORMAL]) |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 317 | robot.Pinch(device_spec, fingertips, (CENTER, CENTER), ANGLES[angle], |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 318 | start_distance, end_distance) |
| 319 | robot.PopSpeed() |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 320 | |
| 321 | def _PerformThumbEdgeTest(variation, robot, device_spec): |
| 322 | fingertip_type, direction = variation |
| 323 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 324 | angle = _ComputePerpendicularAngle(start, end) |
| 325 | |
| 326 | fingertip = robot.fingertips[fingertip_type] |
| 327 | |
| 328 | robot.PushSpeed(SPEEDS[tests.GV.NORMAL]) |
| 329 | robot.Line(device_spec, [fingertip], start, end, fingertip_angle=angle) |
| 330 | robot.PopSpeed() |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 331 | |
| 332 | def _PerformPhysicalClickTest(variation, robot, device_spec, fingertips): |
| 333 | location, = variation |
| 334 | click_position = LOCATION_COORDINATES[location] |
| 335 | robot.Click(device_spec, fingertips, click_position) |
Charlie Mooney | 9426d0c | 2015-07-01 15:03:45 -0700 | [diff] [blame] | 336 | |
| 337 | def _PerformDrumroll(variation, robot, device_spec): |
| 338 | fingertips = [robot.fingertips[STANDARD_FINGERTIP], |
| 339 | robot.fingertips[STANDARD_SECONDARY_FINGERTIP]] |
| 340 | location = LOCATION_COORDINATES[tests.GV.CENTER] |
| 341 | robot.Drumroll(device_spec, fingertips, location) |
Charlie Mooney | 030267f | 2016-02-05 15:34:26 -0800 | [diff] [blame] | 342 | |
| 343 | def _PerformSquareResolutionTest(variation, robot, device_spec): |
| 344 | fingertip = robot.fingertips[STANDARD_FINGERTIP] |
| 345 | location = LOCATION_COORDINATES[tests.GV.CENTER] |
| 346 | robot.Draw45DegreeLineSegment(device_spec, [fingertip], location) |