test_conf.py revision 039967354df47f89616776832ec2a9dd9fea9efb
16d1862363c88c183b0ed7740fca876342cf0474bStephen Hines# -*- coding: utf-8 -*-
268cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov#
368cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
468cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Use of this source code is governed by a BSD-style license that can be
568cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# found in the LICENSE file.
668cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov
768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov"""This configuration file defines the gestures to perform."""
868cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov
968cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanovimport validators
1068cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov
1168cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanovfrom firmware_constants import DEV, GV, RC, VAL
1268cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanovfrom validators import (CountPacketsValidator,
1368cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        CountTrackingIDValidator,
1468cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        DrumrollValidator,
15799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar                        LinearityValidator,
1668cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        NoGapValidator,
1768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        NoLevelJumpValidator,
1868cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        NoReversedMotionValidator,
1968cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        PhysicalClickValidator,
2068cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        PinchValidator,
2168cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                        RangeValidator,
226a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                        ReportRateValidator,
236d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                        StationaryFingerValidator,
2468cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov)
252d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
2743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# Define which score aggregator is to be used. A score aggregator collects
2843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# the scores from every tests and calculates the final score for the touch
2943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# firmware test suite.
3043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanovscore_aggregator = 'fuzzy.average'
3168cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov
32799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar
33799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar# Define some common criteria
34799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar#
3568cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Notes about show_spec_v2 below:
3668cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Some of the following criteria may need to be determined at run time.
3768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Use lambda to do lazy evaluation because the show_spec_v2 may not be
3868cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# assigned its value yet when this module is imported.
3968cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanovcount_packets_criteria = '>= 3, ~ -3'
402d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesdrumroll_criteria = '<= 2.0'
412d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# linearity_criteria is used for strictly straight line drawn with a ruler.
422d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hineslinearity_criteria = '<= 0.8, ~ +2.4'
432d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# relaxed_linearity_criteria is used for lines drawn with thumb edge or
442d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# fat fingers which are allowed to be curvy to some extent.
452d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesrelaxed_linearity_criteria = '<= 1.5, ~ +3.0'
462d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesno_gap_criteria = '<= 1.8, ~ +1.0'
472d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesno_level_jump_criteria = '<= 10, ~ +30'
482d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesno_reversed_motion_criteria = '<= 5, ~ +30'
492d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinespinch_criteria = '>= 200, ~ -100'
502d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesrange_criteria = '<= 0.05, ~ +0.05'
512d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesmin_report_rate = 60
522d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesreport_rate_criteria = '>= %d' % min_report_rate
532d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesstationary_finger_criteria = (lambda: '<= 1.25, ~ +1.25'
542d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                              if validators.show_spec_v2 else '<= 20, ~ +20')
552d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesrelaxed_stationary_finger_criteria = '<= 100, ~ +100'
562d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
572d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
582d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define filenames and paths
592d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesdocroot = '/tmp'
602d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesreport_basename = 'touch_firmware_report'
612d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hineshtml_ext = '.html'
622d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesENVIRONMENT_REPORT_HTML_NAME = 'REPORT_HTML_NAME'
632d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hineslog_root_dir = '/var/tmp/touch_firmware_test'
642d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesfw_prefix = 'fw_'
65799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar
662d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
67799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar# Define parameters for GUI
68799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainarscore_colors = ((0.9, 'blue'), (0.8, 'orange'), (0.0, 'red'))
692d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesnum_chars_per_row = 28
70799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar
712d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
722d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the path to find the robot gestures library path
732d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesrobot_lib_path = '/usr/local/lib*'
742d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinespython_package = 'python*'
752d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesgestures_sub_path = 'site-packages/gestures'
762d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
776d1862363c88c183b0ed7740fca876342cf0474bStephen Hines
786a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines# Define the gesture names
796a211c5814e25d6745a5058cc0e499e5235d3821Stephen HinesONE_FINGER_TRACKING = 'one_finger_tracking'
806a211c5814e25d6745a5058cc0e499e5235d3821Stephen HinesONE_FINGER_TO_EDGE = 'one_finger_to_edge'
812d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_FINGER_TRACKING = 'two_finger_tracking'
822d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesFINGER_CROSSING = 'finger_crossing'
832d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesONE_FINGER_SWIPE = 'one_finger_swipe'
842d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_FINGER_SWIPE = 'two_finger_swipe'
852d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesPINCH_TO_ZOOM = 'pinch_to_zoom'
862d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesONE_FINGER_TAP = 'one_finger_tap'
872d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_FINGER_TAP = 'two_finger_tap'
882d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesONE_FINGER_PHYSICAL_CLICK = 'one_finger_physical_click'
892d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_FINGER_PHYSICAL_CLICK = 'two_fingers_physical_click'
902d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTHREE_FINGER_PHYSICAL_CLICK = 'three_fingers_physical_click'
912d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesFOUR_FINGER_PHYSICAL_CLICK = 'four_fingers_physical_click'
922d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesFIVE_FINGER_PHYSICAL_CLICK = 'five_fingers_physical_click'
932d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesSTATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS = \
942d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        'stationary_finger_not_affected_by_2nd_finger_taps'
952d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesFAT_FINGER_MOVE_WITH_RESTING_FINGER = 'fat_finger_move_with_resting_finger'
962d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesDRAG_EDGE_THUMB = 'drag_edge_thumb'
972d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_CLOSE_FINGERS_TRACKING = 'two_close_fingers_tracking'
982d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesRESTING_FINGER_PLUS_2ND_FINGER_MOVE = 'resting_finger_plus_2nd_finger_move'
992d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesTWO_FAT_FINGERS_TRACKING = 'two_fat_fingers_tracking'
1002d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesFIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS = \
1012d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        'first_finger_tracking_and_second_finger_taps'
1022d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesDRUMROLL = 'drumroll'
1032d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen HinesRAPID_TAPS = 'rapid_taps_20'
1042d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# This following gesture is for pressure calibration.
10543e62df906327f6ffa492edb933af1195143d149Timur IskhodzhanovPRESSURE_CALIBRATION = 'pressure_calibration'
10668cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov
10768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# This denotes the list of the numbers of fingers for physical click tests.
108a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov# It corresponds to ONE/TWO/THREE/FOUR/FIVE_FINGER_PHYSICAL_CLICK defined above.
10968cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanovfingers_physical_click = [1, 2, 3, 4, 5]
1102d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
1112d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
11268cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Define the complete list
11343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanovgesture_names_complete = {
11468cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov    DEV.TOUCHPAD: [
11568cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        ONE_FINGER_TRACKING,
116a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        ONE_FINGER_TO_EDGE,
11768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        TWO_FINGER_TRACKING,
1182d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FINGER_CROSSING,
1192d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        ONE_FINGER_SWIPE,
12068cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        TWO_FINGER_SWIPE,
12143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        PINCH_TO_ZOOM,
12268cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        ONE_FINGER_TAP,
12368cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        TWO_FINGER_TAP,
124a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        ONE_FINGER_PHYSICAL_CLICK,
12568cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        TWO_FINGER_PHYSICAL_CLICK,
1262d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        THREE_FINGER_PHYSICAL_CLICK,
1272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FOUR_FINGER_PHYSICAL_CLICK,
12843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        FIVE_FINGER_PHYSICAL_CLICK,
129c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
130c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        FAT_FINGER_MOVE_WITH_RESTING_FINGER,
131c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        DRAG_EDGE_THUMB,
132a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        TWO_CLOSE_FINGERS_TRACKING,
133c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
1342d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        TWO_FAT_FINGERS_TRACKING,
1352d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
136c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        DRUMROLL,
137c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        RAPID_TAPS,
138c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov    ],
139c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov    DEV.TOUCHSCREEN: [
140a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        ONE_FINGER_TRACKING,
141c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        ONE_FINGER_TO_EDGE,
1422d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        TWO_FINGER_TRACKING,
1432d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FINGER_CROSSING,
144c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        ONE_FINGER_SWIPE,
14543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        TWO_FINGER_SWIPE,
14643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        PINCH_TO_ZOOM,
14743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        ONE_FINGER_TAP,
148a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        TWO_FINGER_TAP,
14943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
1502d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FAT_FINGER_MOVE_WITH_RESTING_FINGER,
1512d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        DRAG_EDGE_THUMB,
15243e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        TWO_CLOSE_FINGERS_TRACKING,
15343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
15443e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        TWO_FAT_FINGERS_TRACKING,
15543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
156a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov        DRUMROLL,
15743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        RAPID_TAPS,
1582d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    ],
1592d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}
16043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
16143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
16243e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# Define what gestures the robot can perform.
16343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# This also defines the order for the robot to perform the gestures.
164a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov# Basically, two-fingers gestures follow one-finger gestures.
16543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanovrobot_capability_list = [
1662d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    ONE_FINGER_TRACKING,
1672d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    ONE_FINGER_TO_EDGE,
16843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    ONE_FINGER_SWIPE,
16943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    ONE_FINGER_TAP,
17043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    ONE_FINGER_PHYSICAL_CLICK,
17143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    RAPID_TAPS,
172a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov    TWO_FINGER_TRACKING,
17343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    TWO_FINGER_SWIPE,
1742d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    TWO_FINGER_TAP,
1752d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    TWO_FINGER_PHYSICAL_CLICK,
17643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov]
17743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
17843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
17943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanovdef get_gesture_names_for_robot(device):
18043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    """Get the gesture names that a robot can do for a specified device."""
181a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov    return [gesture for gesture in robot_capability_list
18243e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                    if gesture in gesture_names_complete[device]]
1832d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
1842d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
18543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov# Define the list of one-finger and two-finger gestures to test using the robot.
18643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanovgesture_names_robot = {
18743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    DEV.TOUCHPAD: get_gesture_names_for_robot(DEV.TOUCHPAD),
18843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov    DEV.TOUCHSCREEN: get_gesture_names_for_robot(DEV.TOUCHSCREEN),
18943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov}
190a8b8e964d7b94cae465df77642465901b1b3079dTimur Iskhodzhanov
19143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
1922d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the gestures to test using the robot with finger interaction.
1932d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesgesture_names_robot_interaction = {
19468cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov    DEV.TOUCHPAD: gesture_names_robot[DEV.TOUCHPAD] + [
19568cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov        FINGER_CROSSING,
19643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
1972d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
1982d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    ],
199c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov    DEV.TOUCHSCREEN: gesture_names_robot[DEV.TOUCHSCREEN] + [
200c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        FINGER_CROSSING,
201c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
202c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
203c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov    ],
204c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov}
205c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov
2066a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines
207c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov# Define the manual list which is gesture_names_complete - gesture_names_robot
2082d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesgesture_names_manual = {}
2096a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hinesfor dev in DEV.DEVICE_TYPE_LIST:
2102d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    complete_gesture_list = gesture_names_complete[dev]
2112d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    manual_set = set(complete_gesture_list) - set(gesture_names_robot[dev])
212799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar    gesture_names_manual[dev] = [gesture for gesture in complete_gesture_list
213c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov                                 if gesture in manual_set]
214c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov
215def895b9ed81b37a99660a2ddfc2c45d229000a4Timur Iskhodzhanov
2162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the gesture for pressure calibration
2172d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesgesture_names_calibration = [PRESSURE_CALIBRATION,]
218c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov
219c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov
22068cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov# Define those gestures that the robot needs to pause so the user
221799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar# could adjust the robot or do finger interaction.
222799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainarmsg_step1 = 'Step 1: Place a metal finger on the %s of the touch surface now.'
223799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainarmsg_step2 = 'Step 2: Press SPACE when ready.'
224799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainarmsg_step3 = 'Step 3: Remember to lift the metal finger when robot has finished!'
2252d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesgesture_names_robot_pause = {
2262d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    TWO_FINGER_TRACKING: {
2272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PAUSE_TYPE: RC.PER_GESTURE,
2282d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PROMPT: (
2292d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            'Gesture: %s' % TWO_FINGER_TRACKING,
2302d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            'Step 1: Install two fingers for the robot now.',
2312d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            msg_step2,
2322d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            '',
2332d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        )
2342d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    },
2352d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2362d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    FINGER_CROSSING: {
2372d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PAUSE_TYPE: RC.PER_VARIATION,
2382d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PROMPT: (
2392d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            'Gesture: %s' % FINGER_CROSSING,
2402d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            msg_step1 % 'center',
2416d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            msg_step2,
2426d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            msg_step3,
2436d1862363c88c183b0ed7740fca876342cf0474bStephen Hines        )
2446d1862363c88c183b0ed7740fca876342cf0474bStephen Hines    },
2456d1862363c88c183b0ed7740fca876342cf0474bStephen Hines
2466d1862363c88c183b0ed7740fca876342cf0474bStephen Hines    STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS: {
2476d1862363c88c183b0ed7740fca876342cf0474bStephen Hines        RC.PAUSE_TYPE: RC.PER_VARIATION,
2486d1862363c88c183b0ed7740fca876342cf0474bStephen Hines        RC.PROMPT: (
2496d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            'Gesture: %s' % STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
2506d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            msg_step1 % 'center',
2516d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            msg_step2,
2526d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            msg_step3,
2536d1862363c88c183b0ed7740fca876342cf0474bStephen Hines        )
2546d1862363c88c183b0ed7740fca876342cf0474bStephen Hines    },
2552d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2562d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    RESTING_FINGER_PLUS_2ND_FINGER_MOVE: {
2572d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PAUSE_TYPE: RC.PER_VARIATION,
2582d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        RC.PROMPT: (
259799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar            'Gesture: %s' % RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
260799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar            msg_step1 % 'bottom left corner',
261799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar            msg_step2,
2622d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            msg_step3,
2632d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        )
2642d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    },
2652d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}
2662d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2672d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2682d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the relative segment weights of a validator.
2692d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# For example, LinearityMiddleValidator : LinearityBothEndsValidator = 7 : 3
2702d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinessegment_weights = {VAL.BEGIN: 0.15,
2712d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                   VAL.MIDDLE: 0.7,
2722d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                   VAL.END: 0.15,
2732d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                   VAL.BOTH_ENDS: 0.15 + 0.15,
2746d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                   VAL.WHOLE: 0.15 + 0.7 + 0.15,
2756d1862363c88c183b0ed7740fca876342cf0474bStephen Hines}
2766d1862363c88c183b0ed7740fca876342cf0474bStephen Hines
2772d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2782d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the validator score weights
2792d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesweight_rare = 1
2802d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesweight_common = 2
2812d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesweight_critical = 3
2822d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesvalidator_weights = {'CountPacketsValidator': weight_common,
2832d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'CountTrackingIDValidator': weight_critical,
2842d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'DrumrollValidator': weight_rare,
2852d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'LinearityValidator': weight_common,
2862d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'NoGapValidator': weight_common,
2872d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'NoLevelJumpValidator': weight_rare,
2882d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'NoReversedMotionValidator': weight_common,
2892d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'PhysicalClickValidator': weight_critical,
2902d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'PinchValidator': weight_common,
2912d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'RangeValidator': weight_common,
2922d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'ReportRateValidator': weight_common,
2932d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                     'StationaryFingerValidator': weight_common,
2942d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}
2952d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2962d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
2972d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines# Define the gesture list that the user needs to perform in the test suite.
2982d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesdef get_gesture_dict():
2992d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    """Define the dictionary for all gestures."""
3002d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    gesture_dict = {
3012d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        ONE_FINGER_TRACKING:
302c11fa095b344c1423ba76822d5bde122b1676223Timur Iskhodzhanov        Gesture(
30386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            name=ONE_FINGER_TRACKING,
30486277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
305799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar                        (GV.SLOW, GV.NORMAL),
30686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            ),
30786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            prompt='Take {2} to draw a straight, {0} line {1} using a ruler.',
30886277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            subprompt={
30986277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.LR: ('horizontal', 'from left to right',),
3106a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                GV.RL: ('horizontal', 'from right to left',),
31186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.TB: ('vertical', 'from top to bottom',),
31286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.BT: ('vertical', 'from bottom to top',),
313cdce50bda3603770cc4ef80cbb613c78b8e47a17Pirama Arumuga Nainar                GV.BLTR: ('diagonal', 'from bottom left to top right',),
314799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar                GV.TRBL: ('diagonal', 'from top right to bottom left',),
31586277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.SLOW: ('3 seconds',),
31686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.NORMAL: ('1 second',),
31786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            },
318c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            validators=(
31986277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                CountTrackingIDValidator('== 1'),
32086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                LinearityValidator(linearity_criteria, slot=0,
32186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                                   segments=VAL.MIDDLE),
32286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                LinearityValidator(linearity_criteria, slot=0,
32386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                                   segments=VAL.BOTH_ENDS),
324799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar                NoGapValidator(no_gap_criteria, slot=0),
32586277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0,
32686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                                          segments=VAL.MIDDLE),
32786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0,
32886277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                                          segments=VAL.BOTH_ENDS),
32986277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                ReportRateValidator(report_rate_criteria),
33086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            ),
33186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines        ),
33286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines
3337c9150579ed0278492f51cc8434b1d63a44b9bd1Pirama Arumuga Nainar        ONE_FINGER_TO_EDGE:
3347c9150579ed0278492f51cc8434b1d63a44b9bd1Pirama Arumuga Nainar        Gesture(
33586277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            name=ONE_FINGER_TO_EDGE,
33686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            variations=((GV.CL, GV.CR, GV.CT, GV.CB),
33786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                        (GV.SLOW,),
338c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            ),
33986277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            prompt='Take {2} to draw a striaght {0} line {1}.',
34086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines            subprompt={
34186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.CL: ('horizontal', 'from the center off left edge',),
34286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.CR: ('horizontal', 'from the center off right edge',),
34386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.CT: ('vertical', 'from the center  off top edge',),
34486277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.CB: ('vertical', 'from the center off bottom edge',),
34586277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                GV.SLOW: ('2 seconds',),
346c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            },
347c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            validators=(
348c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar                CountTrackingIDValidator('== 1'),
3496a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                LinearityValidator(linearity_criteria, slot=0,
35068cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                                   segments=VAL.MIDDLE),
35168cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                LinearityValidator(linearity_criteria, slot=0,
35243e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                                   segments=VAL.BOTH_ENDS),
35343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                NoGapValidator(no_gap_criteria, slot=0),
354c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
35543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                RangeValidator(range_criteria),
35643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                ReportRateValidator(report_rate_criteria),
35743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            ),
358c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar        ),
35943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov
36043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        TWO_FINGER_TRACKING:
36143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov        Gesture(
362c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            name=TWO_FINGER_TRACKING,
36343e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
36443e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                        (GV.SLOW, GV.NORMAL),
36543e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            ),
36643e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            prompt='Take {2} to draw a {0} line {1} using a ruler '
367c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar                   'with TWO fingers at the same time.',
36843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            subprompt={
36943e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                GV.LR: ('horizontal', 'from left to right',),
37043e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                GV.RL: ('horizontal', 'from right to left',),
37143e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov                GV.TB: ('vertical', 'from top to bottom',),
3722d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.BT: ('vertical', 'from bottom to top',),
3732d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.BLTR: ('diagonal', 'from bottom left to top right',),
3742d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.TRBL: ('diagonal', 'from top right to bottom left',),
3752d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.SLOW: ('3 seconds',),
3762d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.NORMAL: ('1 second',),
37743e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            },
37843e62df906327f6ffa492edb933af1195143d149Timur Iskhodzhanov            validators=(
37968cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov                CountTrackingIDValidator('== 2'),
3802d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                LinearityValidator(linearity_criteria, slot=0,
3812d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                                   segments=VAL.MIDDLE),
3826d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                LinearityValidator(linearity_criteria, slot=0,
3836d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                                   segments=VAL.BOTH_ENDS),
3846d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                LinearityValidator(linearity_criteria, slot=1,
3856d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                                   segments=VAL.MIDDLE),
3866d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                LinearityValidator(linearity_criteria, slot=1,
3876d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                                   segments=VAL.BOTH_ENDS),
3886d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                NoGapValidator(no_gap_criteria, slot=0),
3896d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                NoGapValidator(no_gap_criteria, slot=1),
3906d1862363c88c183b0ed7740fca876342cf0474bStephen Hines                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
3912d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
3922d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                ReportRateValidator(report_rate_criteria),
3932d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            ),
3942d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        ),
3952d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
3962d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        FINGER_CROSSING:
3972d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines        Gesture(
3982d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            # also covers stationary_finger_not_affected_by_2nd_moving_finger
3992d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            name=FINGER_CROSSING,
4002d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL),
4012d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                        (GV.SLOW, GV.NORMAL),
402cdce50bda3603770cc4ef80cbb613c78b8e47a17Pirama Arumuga Nainar            ),
403c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar            prompt='Place one stationary finger near the center of the '
4042d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                   'touch surface, then take {2} to draw a straight line '
4052d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                   '{0} {1} with a second finger',
4062d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            subprompt={
4072d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.LR: ('from left to right', 'above the stationary finger'),
4082d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.RL: ('from right to left', 'below the stationary finger'),
409cdce50bda3603770cc4ef80cbb613c78b8e47a17Pirama Arumuga Nainar                GV.TB: ('from top to bottom',
410c58a43648cd6121c51a2e795a28e2ef90d7813e6Pirama Arumuga Nainar                        'on the right to the stationary finger'),
411cdce50bda3603770cc4ef80cbb613c78b8e47a17Pirama Arumuga Nainar                GV.BT: ('from bottom to top',
412cdce50bda3603770cc4ef80cbb613c78b8e47a17Pirama Arumuga Nainar                        'on the left to the stationary finger'),
4132d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.BLTR: ('from the bottom left to the top right',
4142d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                          'above the stationary finger',),
4152d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.TRBL: ('from the top right to the bottom left',
4166a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                          'below the stationary finger'),
4176a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                GV.SLOW: ('3 seconds',),
4182d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                GV.NORMAL: ('1 second',),
4192d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines            },
4206d1862363c88c183b0ed7740fca876342cf0474bStephen Hines            validators=(
4212d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                CountTrackingIDValidator('== 2'),
4222d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines                NoGapValidator(no_gap_criteria, slot=1),
4236a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
4246a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                ReportRateValidator(report_rate_criteria),
4256a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                StationaryFingerValidator(stationary_finger_criteria, slot=0),
4266a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines            ),
4276a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines        ),
4286a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines
4296a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines        ONE_FINGER_SWIPE:
4306a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines        Gesture(
4316a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines            name=ONE_FINGER_SWIPE,
4326a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines            variations=(GV.BLTR, GV.TRBL),
4336a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines            prompt='Use ONE finger to quickly swipe {0}.',
4346a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines            subprompt={
4356a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                GV.BLTR: ('from the bottom left to the top right',),
4366a211c5814e25d6745a5058cc0e499e5235d3821Stephen Hines                GV.TRBL: ('from the top right to the bottom left',),
43768cd60c77470fd6e0f86bad1e4c68796d516cc06Timur Iskhodzhanov            },
438            validators=(
439                CountPacketsValidator(count_packets_criteria, slot=0),
440                CountTrackingIDValidator('== 1'),
441                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
442                ReportRateValidator(report_rate_criteria),
443            ),
444        ),
445
446        TWO_FINGER_SWIPE:
447        Gesture(
448            name=TWO_FINGER_SWIPE,
449            variations=(GV.TB, GV.BT),
450            prompt='Use TWO fingers to quickly swipe {0}.',
451            subprompt={
452                GV.TB: ('from top to bottom',),
453                GV.BT: ('from bottom to top',),
454            },
455            validators=(
456                CountPacketsValidator(count_packets_criteria, slot=0),
457                CountPacketsValidator(count_packets_criteria, slot=1),
458                CountTrackingIDValidator('== 2'),
459                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
460                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
461                ReportRateValidator(report_rate_criteria),
462            ),
463        ),
464
465        PINCH_TO_ZOOM:
466        Gesture(
467            name=PINCH_TO_ZOOM,
468            variations=(GV.ZOOM_IN, GV.ZOOM_OUT),
469            prompt='Using two fingers, preform a "{0}" pinch by bringing'
470                   'your fingers {1}.',
471            subprompt={
472                GV.ZOOM_IN: ('zoom in', 'farther apart'),
473                GV.ZOOM_OUT: ('zoom out', 'closer together'),
474            },
475            validators=(
476                CountTrackingIDValidator('== 2'),
477                PinchValidator(pinch_criteria),
478                ReportRateValidator(report_rate_criteria),
479            ),
480        ),
481
482        ONE_FINGER_TAP:
483        Gesture(
484            name=ONE_FINGER_TAP,
485            variations=(GV.TL, GV.TR, GV.BL, GV.BR, GV.TS, GV.BS, GV.LS, GV.RS,
486                        GV.CENTER),
487            prompt='Use one finger to tap on the {0} of the touch surface.',
488            subprompt={
489                GV.TL: ('top left corner',),
490                GV.TR: ('top right corner',),
491                GV.BL: ('bottom left corner',),
492                GV.BR: ('bottom right corner',),
493                GV.TS: ('top edge',),
494                GV.BS: ('bottom side',),
495                GV.LS: ('left hand side',),
496                GV.RS: ('right hand side',),
497                GV.CENTER: ('center',),
498            },
499            validators=(
500                CountTrackingIDValidator('== 1'),
501                ReportRateValidator(report_rate_criteria),
502                StationaryFingerValidator(stationary_finger_criteria, slot=0),
503            ),
504        ),
505
506        TWO_FINGER_TAP:
507        Gesture(
508            name=TWO_FINGER_TAP,
509            variations=(GV.HORIZONTAL, GV.VERTICAL, GV.DIAGONAL),
510            prompt='Use two fingers aligned {0} to tap the center of the '
511                   'touch surface.',
512            subprompt={
513                GV.HORIZONTAL: ('horizontally',),
514                GV.VERTICAL: ('vertically',),
515                GV.DIAGONAL: ('diagonally',),
516            },
517            validators=(
518                CountTrackingIDValidator('== 2'),
519                ReportRateValidator(report_rate_criteria),
520                StationaryFingerValidator(stationary_finger_criteria, slot=0),
521                StationaryFingerValidator(stationary_finger_criteria, slot=1),
522            ),
523        ),
524
525        ONE_FINGER_PHYSICAL_CLICK:
526        Gesture(
527            name=ONE_FINGER_PHYSICAL_CLICK,
528            variations=(GV.CENTER, GV.BL, GV.BS, GV.BR),
529            prompt='Use one finger to physically click the {0} of the '
530                   'touch surface.',
531            subprompt={
532                GV.CENTER: ('center',),
533                GV.BL: ('bottom left corner',),
534                GV.BS: ('bottom side',),
535                GV.BR: ('bottom right corner',),
536            },
537            validators=(
538                CountTrackingIDValidator('== 1'),
539                PhysicalClickValidator('== 1', fingers=1),
540                ReportRateValidator(report_rate_criteria),
541                StationaryFingerValidator(stationary_finger_criteria, slot=0),
542            ),
543        ),
544
545        TWO_FINGER_PHYSICAL_CLICK:
546        Gesture(
547            name=TWO_FINGER_PHYSICAL_CLICK,
548            variations=None,
549            prompt='Use two fingers physically click the center of the '
550                   'touch surface.',
551            subprompt=None,
552            validators=(
553                CountTrackingIDValidator('== 2'),
554                PhysicalClickValidator('== 1', fingers=2),
555                ReportRateValidator(report_rate_criteria),
556                StationaryFingerValidator(relaxed_stationary_finger_criteria,
557                                          slot=0),
558                StationaryFingerValidator(relaxed_stationary_finger_criteria,
559                                          slot=1),
560            ),
561        ),
562
563        THREE_FINGER_PHYSICAL_CLICK:
564        Gesture(
565            name=THREE_FINGER_PHYSICAL_CLICK,
566            variations=None,
567            prompt='Use three fingers to physically click '
568                   'the center of the touch surface.',
569            subprompt=None,
570            validators=(
571                CountTrackingIDValidator('== 3'),
572                PhysicalClickValidator('== 1', fingers=3),
573                ReportRateValidator(report_rate_criteria),
574            ),
575        ),
576
577        FOUR_FINGER_PHYSICAL_CLICK:
578        Gesture(
579            name=FOUR_FINGER_PHYSICAL_CLICK,
580            variations=None,
581            prompt='Use four fingers to physically click '
582                   'the center of the touch surface.',
583            subprompt=None,
584            validators=(
585                CountTrackingIDValidator('== 4'),
586                PhysicalClickValidator('== 1', fingers=4),
587                ReportRateValidator(report_rate_criteria),
588            ),
589        ),
590
591        FIVE_FINGER_PHYSICAL_CLICK:
592        Gesture(
593            name=FIVE_FINGER_PHYSICAL_CLICK,
594            variations=None,
595            prompt='Use five fingers to physically click '
596                   'the center of the touch surface.',
597            subprompt=None,
598            validators=(
599                CountTrackingIDValidator('== 5'),
600                PhysicalClickValidator('== 1', fingers=5),
601                ReportRateValidator(report_rate_criteria),
602            ),
603        ),
604
605        STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS:
606        Gesture(
607            name=STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS,
608            variations=(GV.AROUND,),
609            prompt='Place your one stationary finger in the middle of the '
610                   'touch surface, and use a second finger to tap '
611                   'all around it',
612            subprompt=None,
613            validators=(
614                CountTrackingIDValidator('>= 2'),
615                ReportRateValidator(report_rate_criteria),
616                StationaryFingerValidator(stationary_finger_criteria, slot=0),
617            ),
618        ),
619
620        FAT_FINGER_MOVE_WITH_RESTING_FINGER:
621        Gesture(
622            name=FAT_FINGER_MOVE_WITH_RESTING_FINGER,
623            variations=(GV.LR, GV.RL, GV.TB, GV.BT),
624            prompt='With a stationary finger on the {0} of the touch surface, '
625                   'draw a straight line with a FAT finger {1} {2} it.',
626            subprompt={
627                GV.LR: ('center', 'from left to right', 'below'),
628                GV.RL: ('bottom edge', 'from right to left', 'above'),
629                GV.TB: ('center', 'from top to bottom', 'on the right to'),
630                GV.BT: ('center', 'from bottom to top', 'on the left to'),
631            },
632            validators=(
633                CountTrackingIDValidator('== 2'),
634                LinearityValidator(relaxed_linearity_criteria, slot=1,
635                                   segments=VAL.MIDDLE),
636                LinearityValidator(relaxed_linearity_criteria, slot=1,
637                                   segments=VAL.BOTH_ENDS),
638                NoGapValidator(no_gap_criteria, slot=1),
639                NoLevelJumpValidator(no_level_jump_criteria, slots=[1,]),
640                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
641                ReportRateValidator(report_rate_criteria),
642                StationaryFingerValidator(stationary_finger_criteria, slot=0),
643            ),
644        ),
645
646        DRAG_EDGE_THUMB:
647        Gesture(
648            name=DRAG_EDGE_THUMB,
649            variations=(GV.LR, GV.RL, GV.TB, GV.BT),
650            prompt='Drag the edge of your thumb {0} in a straight line '
651                   'across the touch surface',
652            subprompt={
653                GV.LR: ('horizontally from left to right',),
654                GV.RL: ('horizontally from right to left',),
655                GV.TB: ('vertically from top to bottom',),
656                GV.BT: ('vertically from bottom to top',),
657            },
658            validators=(
659                CountTrackingIDValidator('== 1'),
660                LinearityValidator(relaxed_linearity_criteria, slot=0,
661                                   segments=VAL.MIDDLE),
662                LinearityValidator(relaxed_linearity_criteria, slot=0,
663                                   segments=VAL.BOTH_ENDS),
664                NoGapValidator(no_gap_criteria, slot=0),
665                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
666                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
667                ReportRateValidator(report_rate_criteria),
668            ),
669        ),
670
671        TWO_CLOSE_FINGERS_TRACKING:
672        Gesture(
673            # TODO(josephsih): make a special two-finger pen to perform this
674            # gesture so that the finger distance remains the same every time
675            # this test is conducted.
676            name=TWO_CLOSE_FINGERS_TRACKING,
677            variations=(GV.LR, GV.TB, GV.TLBR),
678            prompt='With two fingers close together (lightly touching each '
679                   'other) in a two finger scrolling gesture, draw a {0} '
680                   'line {1}.',
681            subprompt={
682                GV.LR: ('horizontal', 'from left to right',),
683                GV.TB: ('vertical', 'from top to bottom',),
684                GV.TLBR: ('diagonal', 'from the top left to the bottom right',),
685            },
686            validators=(
687                CountTrackingIDValidator('== 2'),
688                LinearityValidator(relaxed_linearity_criteria, slot=0,
689                                   segments=VAL.MIDDLE),
690                LinearityValidator(relaxed_linearity_criteria, slot=0,
691                                   segments=VAL.BOTH_ENDS),
692                LinearityValidator(relaxed_linearity_criteria, slot=1,
693                                   segments=VAL.MIDDLE),
694                LinearityValidator(relaxed_linearity_criteria, slot=1,
695                                   segments=VAL.BOTH_ENDS),
696                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
697                NoGapValidator(no_gap_criteria, slot=0),
698                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
699                ReportRateValidator(report_rate_criteria),
700            ),
701        ),
702
703        RESTING_FINGER_PLUS_2ND_FINGER_MOVE:
704        Gesture(
705            name=RESTING_FINGER_PLUS_2ND_FINGER_MOVE,
706            variations=((GV.TLBR, GV.BRTL),
707                        (GV.SLOW,),
708            ),
709            prompt='With a stationary finger in the bottom left corner, take '
710                   '{1} to draw a straight line {0} with a second finger.',
711            subprompt={
712                GV.TLBR: ('from the top left to the bottom right',),
713                GV.BRTL: ('from the bottom right to the top left',),
714                GV.SLOW: ('3 seconds',),
715            },
716            validators=(
717                CountTrackingIDValidator('== 2'),
718                LinearityValidator(relaxed_linearity_criteria, slot=1,
719                                   segments=VAL.MIDDLE),
720                LinearityValidator(relaxed_linearity_criteria, slot=1,
721                                   segments=VAL.BOTH_ENDS),
722                NoGapValidator(no_gap_criteria, slot=1),
723                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
724                ReportRateValidator(report_rate_criteria),
725                StationaryFingerValidator(stationary_finger_criteria, slot=0),
726            ),
727        ),
728
729        TWO_FAT_FINGERS_TRACKING:
730        Gesture(
731            name=TWO_FAT_FINGERS_TRACKING,
732            variations=(GV.LR, GV.RL),
733            prompt='Use two FAT fingers separated by about 1cm to draw '
734                   'a straight line {0}.',
735            subprompt={
736                GV.LR: ('from left to right',),
737                GV.RL: ('from right to left',),
738            },
739            validators=(
740                CountTrackingIDValidator('== 2'),
741                LinearityValidator(relaxed_linearity_criteria, slot=0,
742                                   segments=VAL.MIDDLE),
743                LinearityValidator(relaxed_linearity_criteria, slot=0,
744                                   segments=VAL.BOTH_ENDS),
745                LinearityValidator(relaxed_linearity_criteria, slot=1,
746                                   segments=VAL.MIDDLE),
747                LinearityValidator(relaxed_linearity_criteria, slot=1,
748                                   segments=VAL.BOTH_ENDS),
749                NoGapValidator(no_gap_criteria, slot=0),
750                NoGapValidator(no_gap_criteria, slot=1),
751                NoLevelJumpValidator(no_level_jump_criteria, slots=[0,]),
752                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
753                NoReversedMotionValidator(no_reversed_motion_criteria, slots=1),
754                ReportRateValidator(report_rate_criteria),
755            ),
756        ),
757
758        FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS:
759        Gesture(
760            name=FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS,
761            variations=(GV.TLBR, GV.BRTL),
762            prompt='While drawing a straight line {0} slowly (~3 seconds), '
763                   'tap the bottom left corner with a second finger '
764                   'gently 3 times.',
765            subprompt={
766                GV.TLBR: ('from top left to bottom right',),
767                GV.BRTL: ('from bottom right to top left',),
768            },
769            validators=(
770                CountTrackingIDValidator('== 4'),
771                LinearityValidator(relaxed_linearity_criteria, slot=1,
772                                   segments=VAL.MIDDLE),
773                LinearityValidator(relaxed_linearity_criteria, slot=1,
774                                   segments=VAL.BOTH_ENDS),
775                NoGapValidator(no_gap_criteria, slot=0),
776                NoReversedMotionValidator(no_reversed_motion_criteria, slots=0),
777                ReportRateValidator(report_rate_criteria),
778            ),
779        ),
780
781        DRUMROLL:
782        Gesture(
783            name=DRUMROLL,
784            variations=(GV.FAST, ),
785            prompt='Use the index and middle finger of one hand to make a '
786                   '"drum roll" {0} by alternately tapping each finger '
787                   'for 5 seconds.',
788            subprompt={
789                GV.FAST: ('as fast as possible',),
790            },
791            validators=(
792                CountTrackingIDValidator('>= 5'),
793                DrumrollValidator(drumroll_criteria),
794            ),
795            timeout = 2000,
796        ),
797
798        RAPID_TAPS:
799        Gesture(
800            name=RAPID_TAPS,
801            variations=(GV.TL, GV.BR, GV.CENTER),
802            prompt='Tap the {0} of the touch surface 20 times quickly',
803            subprompt={
804                GV.TL: ('top left corner',),
805                GV.TS: ('top edge',),
806                GV.TR: ('top right corner',),
807                GV.LS: ('left edge',),
808                GV.CENTER: ('center',),
809                GV.RS: ('right edge',),
810                GV.BL: ('bottom left corner',),
811                GV.BS: ('bottom edge',),
812                GV.BR: ('bottom right corner',),
813            },
814            validators=(
815                CountTrackingIDValidator('== 20'),
816            ),
817            timeout = 2000,
818        ),
819
820        PRESSURE_CALIBRATION:
821        Gesture(
822            name=PRESSURE_CALIBRATION,
823            variations=(GV.SIZE0, GV.SIZE1, GV.SIZE2, GV.SIZE3, GV.SIZE4,
824                        GV.SIZE5, GV.SIZE6, ),
825            prompt='Draw circles continuously for 5 seconds '
826                   'using the metal finger of size {0}.',
827            subprompt={
828                GV.SIZE0: ('0 (the smallest size)',),
829                GV.SIZE1: ('1',),
830                GV.SIZE2: ('2',),
831                GV.SIZE3: ('3',),
832                GV.SIZE4: ('4',),
833                GV.SIZE5: ('5',),
834                GV.SIZE6: ('6 (the largest size)',),
835            },
836            validators=(
837                CountTrackingIDValidator('== 1'),
838            ),
839        ),
840    }
841    return gesture_dict
842
843
844class FileName:
845    """A dummy class to hold the attributes in a test file name."""
846    pass
847filename = FileName()
848filename.sep = '-'
849filename.ext = 'dat'
850
851
852class Gesture:
853    """A class defines the structure of Gesture."""
854    # define the default timeout (in milli-seconds) when performing a gesture.
855    # A gesture is considered done when finger is lifted for this time interval.
856    TIMEOUT = int(1000/80*10)
857
858    def __init__(self, name=None, variations=None, prompt=None, subprompt=None,
859                 validators=None, timeout=TIMEOUT):
860        self.name = name
861        self.variations = variations
862        self.prompt = prompt
863        self.subprompt = subprompt
864        self.validators = validators
865        self.timeout = timeout
866