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