test_conf.py revision 3f245993196c7cead8716ff09633a6ad49e8b006
1# -*- coding: utf-8 -*-
2#
3# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""This configuration file defines the gestures to perform."""
8
9from firmware_constants import DEV, GV, RC, VAL
10from validators import (CountPacketsValidator,
11                        CountTrackingIDValidator,
12                        DrumrollValidator,
13                        LinearityValidator,
14                        NoGapValidator,
15                        NoLevelJumpValidator,
16                        NoReversedMotionValidator,
17                        PhysicalClickValidator,
18                        PinchValidator,
19                        RangeValidator,
20                        ReportRateValidator,
21                        StationaryFingerValidator,
22)
23
24
25# Define which score aggregator is to be used. A score aggregator collects
26# the scores from every tests and calculates the final score for the touch
27# firmware test suite.
28score_aggregator = 'fuzzy.average'
29
30
31# Define some common criteria
32count_packets_criteria = '>= 3, ~ -3'
33drumroll_criteria = '<= 2.0'
34# linearity_criteria is used for strictly straight line drawn with a ruler.
35linearity_criteria = '<= 0.8, ~ +2.4'
36# relaxed_linearity_criteria is used for lines drawn with thumb edge or
37# fat fingers which are allowed to be curvy to some extent.
38relaxed_linearity_criteria = '<= 1.5, ~ +3.0'
39no_gap_criteria = '<= 1.8, ~ +1.0'
40no_level_jump_criteria = '<= 10, ~ +30'
41no_reversed_motion_criteria = '<= 5, ~ +30'
42pinch_criteria = '>= 200, ~ -100'
43range_criteria = '<= 0.05, ~ +0.05'
44report_rate_criteria = '>= 60'
45stationary_finger_criteria = '<= 20, ~ +20'
46relaxed_stationary_finger_criteria = '<= 100, ~ +100'
47
48
49# Define filenames and paths
50docroot = '/tmp'
51report_basename = 'touch_firmware_report'
52html_ext = '.html'
53ENVIRONMENT_REPORT_HTML_NAME = 'REPORT_HTML_NAME'
54log_root_dir = '/var/tmp/touch_firmware_test'
55fw_prefix = 'fw_'
56
57
58# Define parameters for GUI
59score_colors = ((0.9, 'blue'), (0.8, 'orange'), (0.0, 'red'))
60num_chars_per_row = 28
61
62
63# Define the path to find the robot gestures library path
64robot_lib_path = '/usr/local/lib*'
65python_package = 'python*'
66gestures_sub_path = 'site-packages/gestures'
67
68
69# Define the gesture names
70ONE_FINGER_TRACKING = 'one_finger_tracking'
71ONE_FINGER_TO_EDGE = 'one_finger_to_edge'
72TWO_FINGER_TRACKING = 'two_finger_tracking'
73FINGER_CROSSING = 'finger_crossing'
74ONE_FINGER_SWIPE = 'one_finger_swipe'
75TWO_FINGER_SWIPE = 'two_finger_swipe'
76PINCH_TO_ZOOM = 'pinch_to_zoom'
77ONE_FINGER_TAP = 'one_finger_tap'
78TWO_FINGER_TAP = 'two_finger_tap'
79ONE_FINGER_PHYSICAL_CLICK = 'one_finger_physical_click'
80TWO_FINGER_PHYSICAL_CLICK = 'two_fingers_physical_click'
81THREE_FINGER_PHYSICAL_CLICK = 'three_fingers_physical_click'
82FOUR_FINGER_PHYSICAL_CLICK = 'four_fingers_physical_click'
83FIVE_FINGER_PHYSICAL_CLICK = 'five_fingers_physical_click'
84STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS = \
85        'stationary_finger_not_affected_by_2nd_finger_taps'
86FAT_FINGER_MOVE_WITH_RESTING_FINGER = 'fat_finger_move_with_resting_finger'
87DRAG_EDGE_THUMB = 'drag_edge_thumb'
88TWO_CLOSE_FINGERS_TRACKING = 'two_close_fingers_tracking'
89RESTING_FINGER_PLUS_2ND_FINGER_MOVE = 'resting_finger_plus_2nd_finger_move'
90TWO_FAT_FINGERS_TRACKING = 'two_fat_fingers_tracking'
91FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS = \
92        'first_finger_tracking_and_second_finger_taps'
93DRUMROLL = 'drumroll'
94RAPID_TAPS = 'rapid_taps_20'
95
96
97# Define the complete list
98gesture_names_complete = {
99    DEV.TOUCHPAD: [
100        ONE_FINGER_TRACKING,
101        ONE_FINGER_TO_EDGE,
102        TWO_FINGER_TRACKING,
103        FINGER_CROSSING,
104        ONE_FINGER_SWIPE,
105        TWO_FINGER_SWIPE,
106        PINCH_TO_ZOOM,
107        ONE_FINGER_TAP,
108        TWO_FINGER_TAP,
109        ONE_FINGER_PHYSICAL_CLICK,
110        TWO_FINGER_PHYSICAL_CLICK,
111        THREE_FINGER_PHYSICAL_CLICK,
112        FOUR_FINGER_PHYSICAL_CLICK,
113        FIVE_FINGER_PHYSICAL_CLICK,
114        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
115        FAT_FINGER_MOVE_WITH_RESTING_FINGER,
116        DRAG_EDGE_THUMB,
117        TWO_CLOSE_FINGERS_TRACKING,
118        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
119        TWO_FAT_FINGERS_TRACKING,
120        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
121        DRUMROLL,
122        RAPID_TAPS,
123    ],
124    DEV.TOUCHSCREEN: [
125        ONE_FINGER_TRACKING,
126        ONE_FINGER_TO_EDGE,
127        TWO_FINGER_TRACKING,
128        FINGER_CROSSING,
129        ONE_FINGER_SWIPE,
130        TWO_FINGER_SWIPE,
131        PINCH_TO_ZOOM,
132        ONE_FINGER_TAP,
133        TWO_FINGER_TAP,
134        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
135        FAT_FINGER_MOVE_WITH_RESTING_FINGER,
136        DRAG_EDGE_THUMB,
137        TWO_CLOSE_FINGERS_TRACKING,
138        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
139        TWO_FAT_FINGERS_TRACKING,
140        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
141        DRUMROLL,
142        RAPID_TAPS,
143    ],
144}
145
146
147# Define what gestures the robot can perform.
148# This also defines the order for the robot to perform the gestures.
149# Basically, two-fingers gestures follow one-finger gestures.
150robot_capability_list = [
151    ONE_FINGER_TRACKING,
152    ONE_FINGER_TO_EDGE,
153    ONE_FINGER_SWIPE,
154    ONE_FINGER_TAP,
155    ONE_FINGER_PHYSICAL_CLICK,
156    RAPID_TAPS,
157    TWO_FINGER_TRACKING,
158    TWO_FINGER_SWIPE,
159    TWO_FINGER_TAP,
160    TWO_FINGER_PHYSICAL_CLICK,
161]
162
163
164def get_gesture_names_for_robot(device):
165    """Get the gesture names that a robot can do for a specified device."""
166    return [gesture for gesture in robot_capability_list
167                    if gesture in gesture_names_complete[device]]
168
169
170# Define the list of one-finger and two-finger gestures to test using the robot.
171gesture_names_robot = {
172    DEV.TOUCHPAD: get_gesture_names_for_robot(DEV.TOUCHPAD),
173    DEV.TOUCHSCREEN: get_gesture_names_for_robot(DEV.TOUCHSCREEN),
174}
175
176
177# Define the gestures to test using the robot with finger interaction.
178gesture_names_robot_interaction = {
179    DEV.TOUCHPAD: gesture_names_robot[DEV.TOUCHPAD] + [
180        FINGER_CROSSING,
181        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
182        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
183    ],
184    DEV.TOUCHSCREEN: gesture_names_robot[DEV.TOUCHSCREEN] + [
185        FINGER_CROSSING,
186        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
187        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
188    ],
189}
190
191
192# Define the manual list which is gesture_names_complete - gesture_names_robot
193gesture_names_manual = {}
194for dev in DEV.DEVICE_TYPE_LIST:
195    gesture_names_manual[dev] = list(set(gesture_names_complete[dev]) -
196                                     set(gesture_names_robot[dev]))
197
198
199# Define those gestures that the robot needs to pause so the user
200# could adjust the robot or do finger interaction.
201msg_step1 = 'Step 1: Place a metal finger on the %s of the touch surface now.'
202msg_step2 = 'Step 2: Press SPACE when ready.'
203msg_step3 = 'Step 3: Remember to lift the metal finger when robot has finished!'
204gesture_names_robot_pause = {
205    TWO_FINGER_TRACKING: {
206        RC.PAUSE_TYPE: RC.PER_GESTURE,
207        RC.PROMPT: (
208            'Gesture: %s' % TWO_FINGER_TRACKING,
209            'Step 1: Install two fingers for the robot now.',
210            msg_step2,
211            '',
212        )
213    },
214
215    FINGER_CROSSING: {
216        RC.PAUSE_TYPE: RC.PER_VARIATION,
217        RC.PROMPT: (
218            'Gesture: %s' % FINGER_CROSSING,
219            msg_step1 % 'center',
220            msg_step2,
221            msg_step3,
222        )
223    },
224
225    STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS: {
226        RC.PAUSE_TYPE: RC.PER_VARIATION,
227        RC.PROMPT: (
228            'Gesture: %s' % STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
229            msg_step1 % 'center',
230            msg_step2,
231            msg_step3,
232        )
233    },
234
235    RESTING_FINGER_PLUS_2ND_FINGER_MOVE: {
236        RC.PAUSE_TYPE: RC.PER_VARIATION,
237        RC.PROMPT: (
238            'Gesture: %s' % RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
239            msg_step1 % 'bottom left corner',
240            msg_step2,
241            msg_step3,
242        )
243    },
244}
245
246
247# Define the relative segment weights of a validator.
248# For example, LinearityMiddleValidator : LinearityBothEndsValidator = 7 : 3
249segment_weights = {VAL.BEGIN: 0.15,
250                   VAL.MIDDLE: 0.7,
251                   VAL.END: 0.15,
252                   VAL.BOTH_ENDS: 0.15 + 0.15,
253                   VAL.WHOLE: 0.15 + 0.7 + 0.15,
254}
255
256
257# Define the validator score weights
258weight_rare = 1
259weight_common = 2
260weight_critical = 3
261validator_weights = {'CountPacketsValidator': weight_common,
262                     'CountTrackingIDValidator': weight_critical,
263                     'DrumrollValidator': weight_rare,
264                     'LinearityValidator': weight_common,
265                     'NoGapValidator': weight_common,
266                     'NoLevelJumpValidator': weight_rare,
267                     'NoReversedMotionValidator': weight_common,
268                     'PhysicalClickValidator': weight_critical,
269                     'PinchValidator': weight_common,
270                     'RangeValidator': weight_common,
271                     'ReportRateValidator': weight_common,
272                     'StationaryFingerValidator': weight_common,
273}
274
275
276# Define the gesture list that the user needs to perform in the test suite.
277def get_gesture_dict():
278    """Define the dictionary for all gestures."""
279    gesture_dict = {
280        ONE_FINGER_TRACKING:
281        Gesture(
282            name=ONE_FINGER_TRACKING,
283            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
284                        (GV.SLOW, GV.NORMAL),
285            ),
286            prompt='Take {2} to draw a straight, {0} line {1} using a ruler.',
287            subprompt={
288                GV.LR: ('horizontal', 'from left to right',),
289                GV.RL: ('horizontal', 'from right to left',),
290                GV.TB: ('vertical', 'from top to bottom',),
291                GV.BT: ('vertical', 'from bottom to top',),
292                GV.BLTR: ('diagonal', 'from bottom left to top right',),
293                GV.TRBL: ('diagonal', 'from top right to bottom left',),
294                GV.SLOW: ('3 seconds',),
295                GV.NORMAL: ('1 second',),
296            },
297            validators=(
298                CountTrackingIDValidator('== 1'),
299                LinearityValidator(linearity_criteria, slot=0,
300                                   segments=VAL.MIDDLE),
301                LinearityValidator(linearity_criteria, slot=0,
302                                   segments=VAL.BOTH_ENDS),
303                NoGapValidator(no_gap_criteria, slot=0),
304                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0,
305                                          segments=VAL.MIDDLE),
306                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0,
307                                          segments=VAL.BOTH_ENDS),
308                ReportRateValidator(report_rate_criteria),
309            ),
310        ),
311
312        ONE_FINGER_TO_EDGE:
313        Gesture(
314            name=ONE_FINGER_TO_EDGE,
315            variations=((GV.CL, GV.CR, GV.CT, GV.CB),
316                        (GV.SLOW,),
317            ),
318            prompt='Take {2} to draw a striaght {0} line {1}.',
319            subprompt={
320                GV.CL: ('horizontal', 'from the center off left edge',),
321                GV.CR: ('horizontal', 'from the center off right edge',),
322                GV.CT: ('vertical', 'from the center  off top edge',),
323                GV.CB: ('vertical', 'from the center off bottom edge',),
324                GV.SLOW: ('2 seconds',),
325            },
326            validators=(
327                CountTrackingIDValidator('== 1'),
328                LinearityValidator(linearity_criteria, slot=0,
329                                   segments=VAL.MIDDLE),
330                LinearityValidator(linearity_criteria, slot=0,
331                                   segments=VAL.BOTH_ENDS),
332                NoGapValidator(no_gap_criteria, slot=0),
333                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
334                RangeValidator(range_criteria),
335                ReportRateValidator(report_rate_criteria),
336            ),
337        ),
338
339        TWO_FINGER_TRACKING:
340        Gesture(
341            name=TWO_FINGER_TRACKING,
342            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
343                        (GV.SLOW, GV.NORMAL),
344            ),
345            prompt='Take {2} to draw a {0} line {1} using a ruler '
346                   'with TWO fingers at the same time.',
347            subprompt={
348                GV.LR: ('horizontal', 'from left to right',),
349                GV.RL: ('horizontal', 'from right to left',),
350                GV.TB: ('vertical', 'from top to bottom',),
351                GV.BT: ('vertical', 'from bottom to top',),
352                GV.BLTR: ('diagonal', 'from bottom left to top right',),
353                GV.TRBL: ('diagonal', 'from top right to bottom left',),
354                GV.SLOW: ('3 seconds',),
355                GV.NORMAL: ('1 second',),
356            },
357            validators=(
358                CountTrackingIDValidator('== 2'),
359                LinearityValidator(linearity_criteria, slot=0,
360                                   segments=VAL.MIDDLE),
361                LinearityValidator(linearity_criteria, slot=0,
362                                   segments=VAL.BOTH_ENDS),
363                LinearityValidator(linearity_criteria, slot=1,
364                                   segments=VAL.MIDDLE),
365                LinearityValidator(linearity_criteria, slot=1,
366                                   segments=VAL.BOTH_ENDS),
367                NoGapValidator(no_gap_criteria, slot=0),
368                NoGapValidator(no_gap_criteria, slot=1),
369                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
370                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
371                ReportRateValidator(report_rate_criteria),
372            ),
373        ),
374
375        FINGER_CROSSING:
376        Gesture(
377            # also covers stationary_finger_not_affected_by_2nd_moving_finger
378            name=FINGER_CROSSING,
379            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
380                        (GV.SLOW, GV.NORMAL),
381            ),
382            prompt='Place one stationary finger near the center of the '
383                   'touch surface, then take {2} to draw a straight line '
384                   '{0} {1} with a second finger',
385            subprompt={
386                GV.LR: ('from left to right', 'above the stationary finger'),
387                GV.RL: ('from right to left', 'below the stationary finger'),
388                GV.TB: ('from top to bottom',
389                        'on the right to the stationary finger'),
390                GV.BT: ('from bottom to top',
391                        'on the left to the stationary finger'),
392                GV.BLTR: ('from the bottom left to the top right',
393                          'above the stationary finger',),
394                GV.TRBL: ('from the top right to the bottom left',
395                          'below the stationary finger'),
396                GV.SLOW: ('3 seconds',),
397                GV.NORMAL: ('1 second',),
398            },
399            validators=(
400                CountTrackingIDValidator('== 2'),
401                NoGapValidator(no_gap_criteria, slot=1),
402                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
403                ReportRateValidator(report_rate_criteria),
404                StationaryFingerValidator(stationary_finger_criteria, slot=0),
405            ),
406        ),
407
408        ONE_FINGER_SWIPE:
409        Gesture(
410            name=ONE_FINGER_SWIPE,
411            variations=(GV.BLTR, GV.TRBL),
412            prompt='Use ONE finger to quickly swipe {0}.',
413            subprompt={
414                GV.BLTR: ('from the bottom left to the top right',),
415                GV.TRBL: ('from the top right to the bottom left',),
416            },
417            validators=(
418                CountPacketsValidator(count_packets_criteria, slot=0),
419                CountTrackingIDValidator('== 1'),
420                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
421                ReportRateValidator(report_rate_criteria),
422            ),
423        ),
424
425        TWO_FINGER_SWIPE:
426        Gesture(
427            name=TWO_FINGER_SWIPE,
428            variations=(GV.TB, GV.BT),
429            prompt='Use TWO fingers to quickly swipe {0}.',
430            subprompt={
431                GV.TB: ('from top to bottom',),
432                GV.BT: ('from bottom to top',),
433            },
434            validators=(
435                CountPacketsValidator(count_packets_criteria, slot=0),
436                CountPacketsValidator(count_packets_criteria, slot=1),
437                CountTrackingIDValidator('== 2'),
438                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
439                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
440                ReportRateValidator(report_rate_criteria),
441            ),
442        ),
443
444        PINCH_TO_ZOOM:
445        Gesture(
446            name=PINCH_TO_ZOOM,
447            variations=(GV.ZOOM_IN, GV.ZOOM_OUT),
448            prompt='Using two fingers, preform a "{0}" pinch by bringing'
449                   'your fingers {1}.',
450            subprompt={
451                GV.ZOOM_IN: ('zoom in', 'farther apart'),
452                GV.ZOOM_OUT: ('zoom out', 'closer together'),
453            },
454            validators=(
455                CountTrackingIDValidator('== 2'),
456                PinchValidator(pinch_criteria),
457                ReportRateValidator(report_rate_criteria),
458            ),
459        ),
460
461        ONE_FINGER_TAP:
462        Gesture(
463            name=ONE_FINGER_TAP,
464            variations=(GV.TL, GV.TR, GV.BL, GV.BR, GV.TS, GV.BS, GV.LS, GV.RS,
465                        GV.CENTER),
466            prompt='Use one finger to tap on the {0} of the touch surface.',
467            subprompt={
468                GV.TL: ('top left corner',),
469                GV.TR: ('top right corner',),
470                GV.BL: ('bottom left corner',),
471                GV.BR: ('bottom right corner',),
472                GV.TS: ('top edge',),
473                GV.BS: ('bottom side',),
474                GV.LS: ('left hand side',),
475                GV.RS: ('right hand side',),
476                GV.CENTER: ('center',),
477            },
478            validators=(
479                CountTrackingIDValidator('== 1'),
480                PhysicalClickValidator('== 0', fingers=1),
481                PhysicalClickValidator('== 0', fingers=2),
482                ReportRateValidator(report_rate_criteria),
483                StationaryFingerValidator(stationary_finger_criteria, slot=0),
484            ),
485        ),
486
487        TWO_FINGER_TAP:
488        Gesture(
489            name=TWO_FINGER_TAP,
490            variations=(GV.HORIZONTAL, GV.VERTICAL, GV.DIAGONAL),
491            prompt='Use two fingers aligned {0} to tap the center of the '
492                   'touch surface.',
493            subprompt={
494                GV.HORIZONTAL: ('horizontally',),
495                GV.VERTICAL: ('vertically',),
496                GV.DIAGONAL: ('diagonally',),
497            },
498            validators=(
499                CountTrackingIDValidator('== 2'),
500                PhysicalClickValidator('== 0', fingers=1),
501                PhysicalClickValidator('== 0', fingers=2),
502                ReportRateValidator(report_rate_criteria),
503                StationaryFingerValidator(stationary_finger_criteria, slot=0),
504                StationaryFingerValidator(stationary_finger_criteria, slot=1),
505            ),
506        ),
507
508        ONE_FINGER_PHYSICAL_CLICK:
509        Gesture(
510            name=ONE_FINGER_PHYSICAL_CLICK,
511            variations=(GV.CENTER, GV.BL, GV.BS, GV.BR),
512            prompt='Use one finger to physically click the {0} of the '
513                   'touch surface.',
514            subprompt={
515                GV.CENTER: ('center',),
516                GV.BL: ('bottom left corner',),
517                GV.BS: ('bottom side',),
518                GV.BR: ('bottom right corner',),
519            },
520            validators=(
521                CountTrackingIDValidator('== 1'),
522                PhysicalClickValidator('== 1', fingers=1),
523                ReportRateValidator(report_rate_criteria),
524                StationaryFingerValidator(stationary_finger_criteria, slot=0),
525            ),
526        ),
527
528        TWO_FINGER_PHYSICAL_CLICK:
529        Gesture(
530            name=TWO_FINGER_PHYSICAL_CLICK,
531            variations=None,
532            prompt='Use two fingers physically click the center of the '
533                   'touch surface.',
534            subprompt=None,
535            validators=(
536                CountTrackingIDValidator('== 2'),
537                PhysicalClickValidator('== 1', fingers=2),
538                ReportRateValidator(report_rate_criteria),
539                StationaryFingerValidator(relaxed_stationary_finger_criteria,
540                                          slot=0),
541                StationaryFingerValidator(relaxed_stationary_finger_criteria,
542                                          slot=1),
543            ),
544        ),
545
546        THREE_FINGER_PHYSICAL_CLICK:
547        Gesture(
548            name=THREE_FINGER_PHYSICAL_CLICK,
549            variations=None,
550            prompt='Use three fingers to physically click '
551                   'the center of the touch surface.',
552            subprompt=None,
553            validators=(
554                CountTrackingIDValidator('== 3'),
555                PhysicalClickValidator('== 1', fingers=3),
556                ReportRateValidator(report_rate_criteria),
557            ),
558        ),
559
560        FOUR_FINGER_PHYSICAL_CLICK:
561        Gesture(
562            name=FOUR_FINGER_PHYSICAL_CLICK,
563            variations=None,
564            prompt='Use four fingers to physically click '
565                   'the center of the touch surface.',
566            subprompt=None,
567            validators=(
568                CountTrackingIDValidator('== 4'),
569                PhysicalClickValidator('== 1', fingers=4),
570                ReportRateValidator(report_rate_criteria),
571            ),
572        ),
573
574        FIVE_FINGER_PHYSICAL_CLICK:
575        Gesture(
576            name=FIVE_FINGER_PHYSICAL_CLICK,
577            variations=None,
578            prompt='Use five fingers to physically click '
579                   'the center of the touch surface.',
580            subprompt=None,
581            validators=(
582                CountTrackingIDValidator('== 5'),
583                PhysicalClickValidator('== 1', fingers=5),
584                ReportRateValidator(report_rate_criteria),
585            ),
586        ),
587
588        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS:
589        Gesture(
590            name=STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
591            variations=(GV.AROUND,),
592            prompt='Place your one stationary finger in the middle of the '
593                   'touch surface, and use a second finger to tap '
594                   'all around it',
595            subprompt=None,
596            validators=(
597                CountTrackingIDValidator('>= 2'),
598                ReportRateValidator(report_rate_criteria),
599                StationaryFingerValidator(stationary_finger_criteria, slot=0),
600            ),
601        ),
602
603        FAT_FINGER_MOVE_WITH_RESTING_FINGER:
604        Gesture(
605            name=FAT_FINGER_MOVE_WITH_RESTING_FINGER,
606            variations=(GV.LR, GV.RL, GV.TB, GV.BT),
607            prompt='With a stationary finger on the {0} of the touch surface, '
608                   'draw a straight line with a FAT finger {1} {2} it.',
609            subprompt={
610                GV.LR: ('center', 'from left to right', 'below'),
611                GV.RL: ('bottom edge', 'from right to left', 'above'),
612                GV.TB: ('center', 'from top to bottom', 'on the right to'),
613                GV.BT: ('center', 'from bottom to top', 'on the left to'),
614            },
615            validators=(
616                CountTrackingIDValidator('== 2'),
617                LinearityValidator(relaxed_linearity_criteria, slot=1,
618                                   segments=VAL.MIDDLE),
619                LinearityValidator(relaxed_linearity_criteria, slot=1,
620                                   segments=VAL.BOTH_ENDS),
621                NoGapValidator(no_gap_criteria, slot=1),
622                NoLevelJumpValidator(no_level_jump_criteria, slots=[1,]),
623                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
624                ReportRateValidator(report_rate_criteria),
625                StationaryFingerValidator(stationary_finger_criteria, slot=0),
626            ),
627        ),
628
629        DRAG_EDGE_THUMB:
630        Gesture(
631            name=DRAG_EDGE_THUMB,
632            variations=(GV.LR, GV.RL, GV.TB, GV.BT),
633            prompt='Drag the edge of your thumb {0} in a straight line '
634                   'across the touch surface',
635            subprompt={
636                GV.LR: ('horizontally from left to right',),
637                GV.RL: ('horizontally from right to left',),
638                GV.TB: ('vertically from top to bottom',),
639                GV.BT: ('vertically from bottom to top',),
640            },
641            validators=(
642                CountTrackingIDValidator('== 1'),
643                LinearityValidator(relaxed_linearity_criteria, slot=0,
644                                   segments=VAL.MIDDLE),
645                LinearityValidator(relaxed_linearity_criteria, slot=0,
646                                   segments=VAL.BOTH_ENDS),
647                NoGapValidator(no_gap_criteria, slot=0),
648                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
649                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
650                ReportRateValidator(report_rate_criteria),
651            ),
652        ),
653
654        TWO_CLOSE_FINGERS_TRACKING:
655        Gesture(
656            # TODO(josephsih): make a special two-finger pen to perform this
657            # gesture so that the finger distance remains the same every time
658            # this test is conducted.
659            name=TWO_CLOSE_FINGERS_TRACKING,
660            variations=(GV.LR, GV.TB, GV.TLBR),
661            prompt='With two fingers close together (lightly touching each '
662                   'other) in a two finger scrolling gesture, draw a {0} '
663                   'line {1}.',
664            subprompt={
665                GV.LR: ('horizontal', 'from left to right',),
666                GV.TB: ('vertical', 'from top to bottom',),
667                GV.TLBR: ('diagonal', 'from the top left to the bottom right',),
668            },
669            validators=(
670                CountTrackingIDValidator('== 2'),
671                LinearityValidator(relaxed_linearity_criteria, slot=0,
672                                   segments=VAL.MIDDLE),
673                LinearityValidator(relaxed_linearity_criteria, slot=0,
674                                   segments=VAL.BOTH_ENDS),
675                LinearityValidator(relaxed_linearity_criteria, slot=1,
676                                   segments=VAL.MIDDLE),
677                LinearityValidator(relaxed_linearity_criteria, slot=1,
678                                   segments=VAL.BOTH_ENDS),
679                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
680                NoGapValidator(no_gap_criteria, slot=0),
681                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
682                ReportRateValidator(report_rate_criteria),
683            ),
684        ),
685
686        RESTING_FINGER_PLUS_2ND_FINGER_MOVE:
687        Gesture(
688            name=RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
689            variations=((GV.TLBR, GV.BRTL),
690                        (GV.SLOW,),
691            ),
692            prompt='With a stationary finger in the bottom left corner, take '
693                   '{1} to draw a straight line {0} with a second finger.',
694            subprompt={
695                GV.TLBR: ('from the top left to the bottom right',),
696                GV.BRTL: ('from the bottom right to the top left',),
697                GV.SLOW: ('3 seconds',),
698            },
699            validators=(
700                CountTrackingIDValidator('== 2'),
701                LinearityValidator(relaxed_linearity_criteria, slot=1,
702                                   segments=VAL.MIDDLE),
703                LinearityValidator(relaxed_linearity_criteria, slot=1,
704                                   segments=VAL.BOTH_ENDS),
705                NoGapValidator(no_gap_criteria, slot=1),
706                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
707                ReportRateValidator(report_rate_criteria),
708                StationaryFingerValidator(stationary_finger_criteria, slot=0),
709            ),
710        ),
711
712        TWO_FAT_FINGERS_TRACKING:
713        Gesture(
714            name=TWO_FAT_FINGERS_TRACKING,
715            variations=(GV.LR, GV.RL),
716            prompt='Use two FAT fingers separated by about 1cm to draw '
717                   'a straight line {0}.',
718            subprompt={
719                GV.LR: ('from left to right',),
720                GV.RL: ('from right to left',),
721            },
722            validators=(
723                CountTrackingIDValidator('== 2'),
724                LinearityValidator(relaxed_linearity_criteria, slot=0,
725                                   segments=VAL.MIDDLE),
726                LinearityValidator(relaxed_linearity_criteria, slot=0,
727                                   segments=VAL.BOTH_ENDS),
728                LinearityValidator(relaxed_linearity_criteria, slot=1,
729                                   segments=VAL.MIDDLE),
730                LinearityValidator(relaxed_linearity_criteria, slot=1,
731                                   segments=VAL.BOTH_ENDS),
732                NoGapValidator(no_gap_criteria, slot=0),
733                NoGapValidator(no_gap_criteria, slot=1),
734                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
735                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
736                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
737                ReportRateValidator(report_rate_criteria),
738            ),
739        ),
740
741        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS:
742        Gesture(
743            name=FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
744            variations=(GV.TLBR, GV.BRTL),
745            prompt='While drawing a straight line {0} slowly (~3 seconds), '
746                   'tap the bottom left corner with a second finger '
747                   'gently 3 times.',
748            subprompt={
749                GV.TLBR: ('from top left to bottom right',),
750                GV.BRTL: ('from bottom right to top left',),
751            },
752            validators=(
753                CountTrackingIDValidator('== 4'),
754                LinearityValidator(relaxed_linearity_criteria, slot=1,
755                                   segments=VAL.MIDDLE),
756                LinearityValidator(relaxed_linearity_criteria, slot=1,
757                                   segments=VAL.BOTH_ENDS),
758                NoGapValidator(no_gap_criteria, slot=0),
759                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
760                ReportRateValidator(report_rate_criteria),
761            ),
762        ),
763
764        DRUMROLL:
765        Gesture(
766            name=DRUMROLL,
767            variations=(GV.FAST, ),
768            prompt='Use the index and middle finger of one hand to make a '
769                   '"drum roll" {0} by alternately tapping each finger '
770                   'for 5 seconds.',
771            subprompt={
772                GV.FAST: ('as fast as possible',),
773            },
774            validators=(
775                CountTrackingIDValidator('>= 5'),
776                DrumrollValidator(drumroll_criteria),
777            ),
778            timeout = 2000,
779        ),
780
781        RAPID_TAPS:
782        Gesture(
783            name=RAPID_TAPS,
784            variations=(GV.TL, GV.BR, GV.CENTER),
785            prompt='Tap the {0} of the touch surface 20 times quickly',
786            subprompt={
787                GV.TL: ('top left corner',),
788                GV.TS: ('top edge',),
789                GV.TR: ('top right corner',),
790                GV.LS: ('left edge',),
791                GV.CENTER: ('center',),
792                GV.RS: ('right edge',),
793                GV.BL: ('bottom left corner',),
794                GV.BS: ('bottom edge',),
795                GV.BR: ('bottom right corner',),
796            },
797            validators=(
798                CountTrackingIDValidator('== 20'),
799            ),
800            timeout = 2000,
801        ),
802    }
803    return gesture_dict
804
805
806class FileName:
807    """A dummy class to hold the attributes in a test file name."""
808    pass
809filename = FileName()
810filename.sep = '-'
811filename.ext = 'dat'
812
813
814class Gesture:
815    """A class defines the structure of Gesture."""
816    # define the default timeout (in milli-seconds) when performing a gesture.
817    # A gesture is considered done when finger is lifted for this time interval.
818    TIMEOUT = int(1000/80*10)
819
820    def __init__(self, name=None, variations=None, prompt=None, subprompt=None,
821                 validators=None, timeout=TIMEOUT):
822        self.name = name
823        self.variations = variations
824        self.prompt = prompt
825        self.subprompt = subprompt
826        self.validators = validators
827        self.timeout = timeout
828