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