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 | |
| 71 | SPEEDS = { |
| 72 | tests.GV.NORMAL: Touchbot.SPEED_MEDIUM, |
| 73 | tests.GV.SLOW: Touchbot.SPEED_SLOW, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 74 | tests.GV.FAST: Touchbot.SPEED_FAST, |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 77 | ANGLES = { |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 78 | tests.GV.HORIZONTAL: 0, |
| 79 | tests.GV.VERTICAL: 90, |
| 80 | tests.GV.DIAGONAL: 45, |
| 81 | } |
| 82 | |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 83 | ONE_FINGERTIP_TAP_TESTS = [ |
| 84 | tests.ONE_FINGER_TAP, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 85 | tests.REPEATED_TAPS, |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 86 | tests.THREE_FINGER_TAP, |
| 87 | tests.FOUR_FINGER_TAP, |
| 88 | tests.FIVE_FINGER_TAP, |
| 89 | ] |
| 90 | |
| 91 | TAP_TEST_FINGERTIPS = { |
| 92 | tests.ONE_FINGER_TAP: STANDARD_FINGERTIP, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 93 | tests.REPEATED_TAPS: STANDARD_FINGERTIP, |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 94 | tests.THREE_FINGER_TAP: THREE_FINGER_FINGERTIP, |
| 95 | tests.FOUR_FINGER_TAP: FOUR_FINGER_FINGERTIP, |
| 96 | tests.FIVE_FINGER_TAP: FIVE_FINGER_FINGERTIP, |
| 97 | } |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 98 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 99 | SINGLE_FINGER_LINE_TESTS = [ |
| 100 | tests.ONE_FINGER_TO_EDGE, |
| 101 | tests.ONE_FINGER_TRACKING, |
| 102 | tests.ONE_FINGER_TRACKING_FROM_CENTER, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 103 | tests.ONE_FINGER_SWIPE, |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 104 | ] |
| 105 | |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 106 | TWO_FINGER_LINE_TESTS = [ |
| 107 | tests.TWO_FINGER_TRACKING, |
| 108 | tests.TWO_CLOSE_FINGERS_TRACKING, |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 109 | tests.TWO_FAT_FINGERS_TRACKING, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 110 | tests.TWO_FINGER_SWIPE, |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 111 | ] |
| 112 | |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 113 | PHYSICAL_CLICK_TESTS = [ |
| 114 | tests.ONE_FINGER_PHYSICAL_CLICK, |
| 115 | tests.TWO_FINGER_PHYSICAL_CLICK, |
| 116 | ] |
| 117 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 118 | |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 119 | def _ComputePerpendicularAngle(start, end): |
| 120 | """ Compute the fingertip angle to be perpendicular to the |
| 121 | movement direction. |
| 122 | |
| 123 | The robot's X/Y axes are not in the same direction as the touch device's, |
| 124 | they are flipped. |
| 125 | |
| 126 | DUT x ----> Robot y ----> |
| 127 | y x |
| 128 | | | |
| 129 | | | |
| 130 | \/ \/ |
| 131 | |
| 132 | As a result the angle is computed in the DUT space, but then must have |
| 133 | its sign flipped before being used in any commands to the robot or |
| 134 | everything will be wrong since it's a clockwise angle instead of counter- |
| 135 | clockwise. |
| 136 | """ |
| 137 | x1, y1 = start |
| 138 | x2, y2 = end |
| 139 | dy = y2 - y1 |
| 140 | dx = x2 - x1 |
| 141 | return -1 * (math.degrees(math.atan2(y2 - y1, x2 - x1)) + 90) |
| 142 | |
| 143 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 144 | def PerformCorrespondingGesture(test, variation_number, robot, device_spec): |
| 145 | variation = test.variations[variation_number] |
| 146 | fn = None |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 147 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 148 | if test.name == tests.NOISE_STATIONARY: |
| 149 | fn = lambda: _PerformStationaryNoiseTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 150 | |
| 151 | elif test.name in ONE_FINGERTIP_TAP_TESTS: |
| 152 | fingertip = robot.fingertips[TAP_TEST_FINGERTIPS[test.name]] |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 153 | num_taps = 20 if test.name == tests.REPEATED_TAPS else 1 |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 154 | vertical_offset = 0 |
| 155 | if test.name != tests.ONE_FINGER_TAP: |
| 156 | vertical_offset = robot.LARGE_FINGERTIP_VERTICAL_OFFSET |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 157 | fn = lambda: _PerformOneFingertipTapTest( |
| 158 | variation, robot, device_spec, fingertip, |
| 159 | vertical_offset, num_taps) |
| 160 | |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 161 | elif test.name == tests.TWO_FINGER_TAP: |
| 162 | fn = lambda: _PerformTwoFingerTapTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 163 | |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 164 | elif test.name in PHYSICAL_CLICK_TESTS: |
| 165 | fingertips = [robot.fingertips[STANDARD_FINGERTIP]] |
| 166 | if test.name == tests.TWO_FINGER_PHYSICAL_CLICK: |
| 167 | fingertips.append(robot.fingertips[STANDARD_SECONDARY_FINGERTIP]) |
| 168 | fn = lambda: _PerformPhysicalClickTest(variation, robot, device_spec, |
| 169 | fingertips) |
| 170 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 171 | elif test.name in SINGLE_FINGER_LINE_TESTS: |
| 172 | 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] | 173 | is_swipe = (test.name == tests.ONE_FINGER_SWIPE) |
| 174 | fn = lambda: _PerformOneFingerLineTest(variation, robot, device_spec, |
| 175 | pause, is_swipe) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 176 | |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 177 | elif test.name in TWO_FINGER_LINE_TESTS: |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 178 | spacing = 5 |
| 179 | fingertips = [robot.fingertips[STANDARD_FINGERTIP], |
| 180 | robot.fingertips[STANDARD_SECONDARY_FINGERTIP]] |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 181 | is_swipe = (test.name == tests.TWO_FINGER_SWIPE) |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 182 | if test.name == tests.TWO_CLOSE_FINGERS_TRACKING: |
| 183 | spacing = 0 |
| 184 | elif test.name == tests.TWO_FAT_FINGERS_TRACKING: |
| 185 | spacing = 10 |
| 186 | fingertips = [robot.fingertips[FAT_FINGERTIP], |
| 187 | robot.fingertips[FAT_SECONDARY_FINGERTIP]] |
Charlie Mooney | cfb4a64 | 2015-05-07 15:33:37 -0700 | [diff] [blame] | 188 | fn = lambda: _PerformTwoFingerLineTest(variation, robot, device_spec, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 189 | fingertips, spacing, is_swipe) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 190 | |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 191 | elif test.name == tests.RESTING_FINGER_PLUS_2ND_FINGER_MOVE: |
| 192 | fn = lambda: _PerformRestingFingerTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 193 | |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 194 | elif test.name == tests.PINCH_TO_ZOOM: |
| 195 | fn = lambda: _PerformPinchTest(variation, robot, device_spec) |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 196 | |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 197 | elif test.name == tests.DRAG_THUMB_EDGE: |
| 198 | fn = lambda: _PerformThumbEdgeTest(variation, robot, device_spec) |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 199 | |
| 200 | if fn is None: |
Charlie Mooney | ca3fc20 | 2015-05-21 11:16:53 -0700 | [diff] [blame] | 201 | print color.Fore.RED + 'Robot unable to perform gesture! Skipping...' |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 202 | return None |
| 203 | |
| 204 | return Thread(target=fn) |
| 205 | |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 206 | |
Charlie Mooney | 0866191 | 2015-04-16 09:20:34 -0700 | [diff] [blame] | 207 | def _PerformStationaryNoiseTest(variation, robot, device_spec): |
| 208 | frequency, amplitude, waveform, location = variation |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 209 | tap_position = LOCATION_COORDINATES[location] |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 210 | fingertip = robot.fingertips[NOISE_TESTING_FINGERTIP] |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 211 | robot.Tap(device_spec, [fingertip], tap_position, touch_time_s=4) |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 212 | |
| 213 | |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 214 | def _PerformOneFingertipTapTest(variation, robot, device_spec, fingertip, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 215 | vertical_offset, num_taps): |
Charlie Mooney | 1b70811 | 2015-04-28 14:46:21 -0700 | [diff] [blame] | 216 | location, = variation |
| 217 | tap_position = LOCATION_COORDINATES[location] |
Charlie Mooney | 1777b37 | 2015-05-21 10:40:43 -0700 | [diff] [blame] | 218 | robot.Tap(device_spec, [fingertip], tap_position, |
Charlie Mooney | 587197f | 2015-06-05 15:35:02 -0700 | [diff] [blame] | 219 | vertical_offset=vertical_offset, num_taps=num_taps) |
Charlie Mooney | 4198adb | 2015-05-04 13:55:20 -0700 | [diff] [blame] | 220 | |
| 221 | |
| 222 | def _PerformTwoFingerTapTest(variation, robot, device_spec): |
| 223 | angle, = variation |
| 224 | |
| 225 | fingertip1 = robot.fingertips[STANDARD_FINGERTIP] |
| 226 | fingertip2 = robot.fingertips[STANDARD_SECONDARY_FINGERTIP] |
| 227 | fingertips = [fingertip1, fingertip2] |
| 228 | |
| 229 | robot.Tap(device_spec, fingertips, (CENTER, CENTER), angle=ANGLES[angle]) |
Charlie Mooney | 1b70811 | 2015-04-28 14:46:21 -0700 | [diff] [blame] | 230 | |
| 231 | |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 232 | def _PerformOneFingerLineTest(variation, robot, device_spec, pause_time_s, |
| 233 | is_swipe): |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 234 | direction, speed = variation |
| 235 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 236 | fingertip = robot.fingertips[STANDARD_FINGERTIP] |
| 237 | |
| 238 | robot.PushSpeed(SPEEDS[speed]) |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 239 | robot.Line(device_spec, [fingertip], start, end, pause_s=pause_time_s, |
| 240 | swipe=is_swipe) |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 241 | robot.PopSpeed() |
| 242 | |
| 243 | |
Charlie Mooney | 7b1fdb9 | 2015-05-08 09:22:55 -0700 | [diff] [blame] | 244 | def _PerformTwoFingerLineTest(variation, robot, device_spec, fingertips, |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 245 | spacing_mm, is_swipe): |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 246 | direction, speed = variation |
| 247 | start, end = LINE_DIRECTION_COORDINATES[direction] |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 248 | angle = _ComputePerpendicularAngle(start, end) |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 249 | |
Charlie Mooney | a337d58 | 2015-04-29 10:37:45 -0700 | [diff] [blame] | 250 | robot.PushSpeed(SPEEDS[speed]) |
Charlie Mooney | be4661e | 2015-05-20 11:46:43 -0700 | [diff] [blame] | 251 | robot.Line(device_spec, fingertips, start, end, fingertip_spacing=spacing_mm, |
| 252 | fingertip_angle=angle, swipe=is_swipe) |
Charlie Mooney | 61b4fbb | 2015-04-22 15:22:02 -0700 | [diff] [blame] | 253 | robot.PopSpeed() |
Charlie Mooney | e9fd656 | 2015-04-30 13:45:19 -0700 | [diff] [blame] | 254 | |
| 255 | |
| 256 | def _PerformRestingFingerTest(variation, robot, device_spec): |
| 257 | direction, speed = variation |
| 258 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 259 | stationary_location = LOCATION_COORDINATES[tests.GV.BL] |
| 260 | |
| 261 | stationary_fingertip = robot.fingertips[STANDARD_FINGERTIP] |
| 262 | moving_fingertip = robot.fingertips[STANDARD_SECONDARY_FINGERTIP] |
| 263 | |
| 264 | robot.PushSpeed(SPEEDS[speed]) |
| 265 | robot.LineWithStationaryFinger(device_spec, stationary_fingertip, |
| 266 | moving_fingertip, start, end, |
| 267 | stationary_location) |
| 268 | robot.PopSpeed() |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 269 | |
| 270 | def _PerformPinchTest(variation, robot, device_spec): |
| 271 | direction, angle = variation |
| 272 | |
| 273 | min_spread = 15 |
| 274 | max_spread = min(device_spec.Height(), device_spec.Width(), |
| 275 | robot.MAX_FINGER_DISTANCE) |
| 276 | if direction == tests.GV.ZOOM_OUT: |
| 277 | start_distance, end_distance = max_spread, min_spread |
| 278 | else: |
| 279 | start_distance, end_distance = min_spread, max_spread |
| 280 | |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 281 | fingertips = [robot.fingertips[STANDARD_FINGERTIP], |
| 282 | robot.fingertips[STANDARD_SECONDARY_FINGERTIP]] |
| 283 | |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 284 | robot.PushSpeed(SPEEDS[tests.GV.NORMAL]) |
Charlie Mooney | 058aa5f | 2015-05-06 12:55:48 -0700 | [diff] [blame] | 285 | robot.Pinch(device_spec, fingertips, (CENTER, CENTER), ANGLES[angle], |
Charlie Mooney | 5065bcb | 2015-05-04 13:18:09 -0700 | [diff] [blame] | 286 | start_distance, end_distance) |
| 287 | robot.PopSpeed() |
Charlie Mooney | c56c860 | 2015-05-07 15:15:40 -0700 | [diff] [blame] | 288 | |
| 289 | def _PerformThumbEdgeTest(variation, robot, device_spec): |
| 290 | fingertip_type, direction = variation |
| 291 | start, end = LINE_DIRECTION_COORDINATES[direction] |
| 292 | angle = _ComputePerpendicularAngle(start, end) |
| 293 | |
| 294 | fingertip = robot.fingertips[fingertip_type] |
| 295 | |
| 296 | robot.PushSpeed(SPEEDS[tests.GV.NORMAL]) |
| 297 | robot.Line(device_spec, [fingertip], start, end, fingertip_angle=angle) |
| 298 | robot.PopSpeed() |
Charlie Mooney | a5a5d3e | 2015-06-11 13:48:01 -0700 | [diff] [blame] | 299 | |
| 300 | def _PerformPhysicalClickTest(variation, robot, device_spec, fingertips): |
| 301 | location, = variation |
| 302 | click_position = LOCATION_COORDINATES[location] |
| 303 | robot.Click(device_spec, fingertips, click_position) |