test_conf.py revision af04554499f895a1d1c98e550558ae6118c3cde0
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 RAPID_TAPS, 172 TWO_FINGER_TRACKING, 173 TWO_FINGER_SWIPE, 174 TWO_FINGER_TAP, 175 RESTING_FINGER_PLUS_2ND_FINGER_MOVE, 176 PINCH_TO_ZOOM, 177 ONE_FINGER_PHYSICAL_CLICK, 178 TWO_FINGER_PHYSICAL_CLICK, 179 THREE_FINGER_PHYSICAL_CLICK, 180 FOUR_FINGER_PHYSICAL_CLICK, 181] 182 183robot_must_start_without_fingertips = [ 184 ONE_FINGER_PHYSICAL_CLICK, 185 TWO_FINGER_PHYSICAL_CLICK, 186 THREE_FINGER_PHYSICAL_CLICK, 187 FOUR_FINGER_PHYSICAL_CLICK, 188] 189 190def get_gesture_names_for_robot(device): 191 """Get the gesture names that a robot can do for a specified device.""" 192 return [gesture for gesture in robot_capability_list 193 if gesture in gesture_names_complete[device]] 194 195 196# Define the list of one-finger and two-finger gestures to test using the robot. 197gesture_names_robot = { 198 DEV.TOUCHPAD: get_gesture_names_for_robot(DEV.TOUCHPAD), 199 DEV.TOUCHSCREEN: get_gesture_names_for_robot(DEV.TOUCHSCREEN), 200} 201 202 203# Define the manual list which is gesture_names_complete - gesture_names_robot 204gesture_names_manual = {} 205for dev in DEV.DEVICE_TYPE_LIST: 206 complete_gesture_list = gesture_names_complete[dev] 207 manual_set = set(complete_gesture_list) - set(gesture_names_robot[dev]) 208 gesture_names_manual[dev] = [gesture for gesture in complete_gesture_list 209 if gesture in manual_set] 210 211 212# Define the gesture for pressure calibration 213gesture_names_calibration = [PRESSURE_CALIBRATION,] 214 215# Define the relative segment weights of a validator. 216# For example, LinearityMiddleValidator : LinearityBothEndsValidator = 7 : 3 217segment_weights = {VAL.BEGIN: 0.15, 218 VAL.MIDDLE: 0.7, 219 VAL.END: 0.15, 220 VAL.BOTH_ENDS: 0.15 + 0.15, 221 VAL.WHOLE: 0.15 + 0.7 + 0.15, 222} 223 224 225# Define the validator score weights 226weight_rare = 1 227weight_common = 2 228weight_critical = 3 229validator_weights = {'CountPacketsValidator': weight_common, 230 'CountTrackingIDValidator': weight_critical, 231 'DrumrollValidator': weight_rare, 232 'LinearityValidator': weight_common, 233 'NoGapValidator': weight_common, 234 'NoReversedMotionValidator': weight_common, 235 'PhysicalClickValidator': weight_critical, 236 'PinchValidator': weight_common, 237 'RangeValidator': weight_common, 238 'ReportRateValidator': weight_common, 239 'StationaryFingerValidator': weight_common, 240} 241 242 243# Define the gesture list that the user needs to perform in the test suite. 244def get_gesture_dict(): 245 """Define the dictionary for all gestures.""" 246 gesture_dict = { 247 ONE_FINGER_TRACKING: 248 Gesture( 249 name=ONE_FINGER_TRACKING, 250 variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL), 251 (GV.SLOW, GV.NORMAL), 252 ), 253 prompt='Take {2} to draw a straight, {0} line {1} using a ruler.', 254 subprompt={ 255 GV.LR: ('horizontal', 'from left to right',), 256 GV.RL: ('horizontal', 'from right to left',), 257 GV.TB: ('vertical', 'from top to bottom',), 258 GV.BT: ('vertical', 'from bottom to top',), 259 GV.BLTR: ('diagonal', 'from bottom left to top right',), 260 GV.TRBL: ('diagonal', 'from top right to bottom left',), 261 GV.SLOW: ('3 seconds',), 262 GV.NORMAL: ('1 second',), 263 }, 264 validators=( 265 CountTrackingIDValidator('== 1'), 266 LinearityValidator(linearity_criteria, finger=0, 267 segments=VAL.MIDDLE), 268 LinearityValidator(linearity_criteria, finger=0, 269 segments=VAL.BOTH_ENDS), 270 NoGapValidator(no_gap_criteria, slot=0), 271 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0, 272 segments=VAL.MIDDLE), 273 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0, 274 segments=VAL.BOTH_ENDS), 275 ReportRateValidator(report_rate_criteria), 276 ), 277 ), 278 279 ONE_FINGER_TO_EDGE: 280 Gesture( 281 name=ONE_FINGER_TO_EDGE, 282 variations=((GV.CL, GV.CR, GV.CT, GV.CB), 283 (GV.SLOW,), 284 ), 285 prompt='Take {2} to draw a striaght {0} line {1}.', 286 subprompt={ 287 GV.CL: ('horizontal', 'from the center off left edge',), 288 GV.CR: ('horizontal', 'from the center off right edge',), 289 GV.CT: ('vertical', 'from the center off top edge',), 290 GV.CB: ('vertical', 'from the center off bottom edge',), 291 GV.SLOW: ('2 seconds',), 292 }, 293 validators=( 294 CountTrackingIDValidator('== 1'), 295 LinearityValidator(linearity_criteria, finger=0, 296 segments=VAL.MIDDLE), 297 LinearityValidator(linearity_criteria, finger=0, 298 segments=VAL.BOTH_ENDS), 299 NoGapValidator(no_gap_criteria, slot=0), 300 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 301 RangeValidator(range_criteria), 302 ReportRateValidator(report_rate_criteria), 303 ), 304 ), 305 306 TWO_FINGER_TRACKING: 307 Gesture( 308 name=TWO_FINGER_TRACKING, 309 variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL), 310 (GV.SLOW, GV.NORMAL), 311 ), 312 prompt='Take {2} to draw a {0} line {1} using a ruler ' 313 'with TWO fingers at the same time.', 314 subprompt={ 315 GV.LR: ('horizontal', 'from left to right',), 316 GV.RL: ('horizontal', 'from right to left',), 317 GV.TB: ('vertical', 'from top to bottom',), 318 GV.BT: ('vertical', 'from bottom to top',), 319 GV.BLTR: ('diagonal', 'from bottom left to top right',), 320 GV.TRBL: ('diagonal', 'from top right to bottom left',), 321 GV.SLOW: ('3 seconds',), 322 GV.NORMAL: ('1 second',), 323 }, 324 validators=( 325 CountTrackingIDValidator('== 2'), 326 LinearityValidator(linearity_criteria, finger=0, 327 segments=VAL.MIDDLE), 328 LinearityValidator(linearity_criteria, finger=0, 329 segments=VAL.BOTH_ENDS), 330 LinearityValidator(linearity_criteria, finger=1, 331 segments=VAL.MIDDLE), 332 LinearityValidator(linearity_criteria, finger=1, 333 segments=VAL.BOTH_ENDS), 334 NoGapValidator(no_gap_criteria, slot=0), 335 NoGapValidator(no_gap_criteria, slot=1), 336 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 337 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 338 ReportRateValidator(report_rate_criteria), 339 ), 340 ), 341 342 FINGER_CROSSING: 343 Gesture( 344 # also covers stationary_finger_not_affected_by_2nd_moving_finger 345 name=FINGER_CROSSING, 346 variations=((GV.LR, GV.RL, GV.TB, GV.BT, GV.BLTR, GV.TRBL), 347 (GV.SLOW, GV.NORMAL), 348 ), 349 prompt='Place one stationary finger near the center of the ' 350 'touch surface, then take {2} to draw a straight line ' 351 '{0} {1} with a second finger', 352 subprompt={ 353 GV.LR: ('from left to right', 'above the stationary finger'), 354 GV.RL: ('from right to left', 'below the stationary finger'), 355 GV.TB: ('from top to bottom', 356 'on the right to the stationary finger'), 357 GV.BT: ('from bottom to top', 358 'on the left to the stationary finger'), 359 GV.BLTR: ('from the bottom left to the top right', 360 'above the stationary finger',), 361 GV.TRBL: ('from the top right to the bottom left', 362 'below the stationary finger'), 363 GV.SLOW: ('3 seconds',), 364 GV.NORMAL: ('1 second',), 365 }, 366 validators=( 367 CountTrackingIDValidator('== 2'), 368 NoGapValidator(no_gap_criteria, slot=1), 369 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 370 ReportRateValidator(report_rate_criteria, finger=1), 371 StationaryFingerValidator(stationary_finger_criteria, slot=0), 372 ), 373 ), 374 375 ONE_FINGER_SWIPE: 376 Gesture( 377 name=ONE_FINGER_SWIPE, 378 variations=(GV.BLTR, GV.TRBL), 379 prompt='Use ONE finger to quickly swipe {0}.', 380 subprompt={ 381 GV.BLTR: ('from the bottom left to the top right',), 382 GV.TRBL: ('from the top right to the bottom left',), 383 }, 384 validators=( 385 CountPacketsValidator(count_packets_criteria, slot=0), 386 CountTrackingIDValidator('== 1'), 387 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 388 ReportRateValidator(report_rate_criteria), 389 ), 390 ), 391 392 TWO_FINGER_SWIPE: 393 Gesture( 394 name=TWO_FINGER_SWIPE, 395 variations=(GV.TB, GV.BT), 396 prompt='Use TWO fingers to quickly swipe {0}.', 397 subprompt={ 398 GV.TB: ('from top to bottom',), 399 GV.BT: ('from bottom to top',), 400 }, 401 validators=( 402 CountPacketsValidator(count_packets_criteria, slot=0), 403 CountPacketsValidator(count_packets_criteria, slot=1), 404 CountTrackingIDValidator('== 2'), 405 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 406 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 407 ReportRateValidator(report_rate_criteria), 408 ), 409 ), 410 411 PINCH_TO_ZOOM: 412 Gesture( 413 name=PINCH_TO_ZOOM, 414 variations=(GV.ZOOM_IN, GV.ZOOM_OUT), 415 prompt='Using two fingers, preform a "{0}" pinch by bringing' 416 'your fingers {1}.', 417 subprompt={ 418 GV.ZOOM_IN: ('zoom in', 'farther apart'), 419 GV.ZOOM_OUT: ('zoom out', 'closer together'), 420 }, 421 validators=( 422 CountTrackingIDValidator('== 2'), 423 PinchValidator(pinch_criteria), 424 ReportRateValidator(report_rate_criteria), 425 ), 426 ), 427 428 ONE_FINGER_TAP: 429 Gesture( 430 name=ONE_FINGER_TAP, 431 variations=(GV.TL, GV.TR, GV.BL, GV.BR, GV.TS, GV.BS, GV.LS, GV.RS, 432 GV.CENTER), 433 prompt='Use one finger to tap on the {0} of the touch surface.', 434 subprompt={ 435 GV.TL: ('top left corner',), 436 GV.TR: ('top right corner',), 437 GV.BL: ('bottom left corner',), 438 GV.BR: ('bottom right corner',), 439 GV.TS: ('top edge',), 440 GV.BS: ('bottom side',), 441 GV.LS: ('left hand side',), 442 GV.RS: ('right hand side',), 443 GV.CENTER: ('center',), 444 }, 445 validators=( 446 CountTrackingIDValidator('== 1'), 447 StationaryFingerValidator(stationary_finger_criteria, slot=0), 448 ), 449 ), 450 451 TWO_FINGER_TAP: 452 Gesture( 453 name=TWO_FINGER_TAP, 454 variations=(GV.HORIZONTAL, GV.VERTICAL, GV.DIAGONAL), 455 prompt='Use two fingers aligned {0} to tap the center of the ' 456 'touch surface.', 457 subprompt={ 458 GV.HORIZONTAL: ('horizontally',), 459 GV.VERTICAL: ('vertically',), 460 GV.DIAGONAL: ('diagonally',), 461 }, 462 validators=( 463 CountTrackingIDValidator('== 2'), 464 StationaryFingerValidator(stationary_finger_criteria, slot=0), 465 StationaryFingerValidator(stationary_finger_criteria, slot=1), 466 ), 467 ), 468 469 ONE_FINGER_PHYSICAL_CLICK: 470 Gesture( 471 name=ONE_FINGER_PHYSICAL_CLICK, 472 variations=(GV.CENTER, GV.BL, GV.BS, GV.BR), 473 prompt='Use one finger to physically click the {0} of the ' 474 'touch surface.', 475 subprompt={ 476 GV.CENTER: ('center',), 477 GV.BL: ('bottom left corner',), 478 GV.BS: ('bottom side',), 479 GV.BR: ('bottom right corner',), 480 }, 481 validators=( 482 CountTrackingIDValidator('== 1'), 483 PhysicalClickValidator('== 1', fingers=1), 484 StationaryFingerValidator(stationary_finger_criteria, slot=0), 485 ), 486 ), 487 488 TWO_FINGER_PHYSICAL_CLICK: 489 Gesture( 490 name=TWO_FINGER_PHYSICAL_CLICK, 491 variations=None, 492 prompt='Use two fingers physically click the center of the ' 493 'touch surface.', 494 subprompt=None, 495 validators=( 496 CountTrackingIDValidator('== 2'), 497 PhysicalClickValidator('== 1', fingers=2), 498 StationaryFingerValidator(relaxed_stationary_finger_criteria, 499 slot=0), 500 StationaryFingerValidator(relaxed_stationary_finger_criteria, 501 slot=1), 502 ), 503 ), 504 505 THREE_FINGER_PHYSICAL_CLICK: 506 Gesture( 507 name=THREE_FINGER_PHYSICAL_CLICK, 508 variations=None, 509 prompt='Use three fingers to physically click ' 510 'the center of the touch surface.', 511 subprompt=None, 512 validators=( 513 CountTrackingIDValidator('== 3'), 514 PhysicalClickValidator('== 1', fingers=3), 515 ), 516 ), 517 518 FOUR_FINGER_PHYSICAL_CLICK: 519 Gesture( 520 name=FOUR_FINGER_PHYSICAL_CLICK, 521 variations=None, 522 prompt='Use four fingers to physically click ' 523 'the center of the touch surface.', 524 subprompt=None, 525 validators=( 526 CountTrackingIDValidator('== 4'), 527 PhysicalClickValidator('== 1', fingers=4), 528 ), 529 ), 530 531 FIVE_FINGER_PHYSICAL_CLICK: 532 Gesture( 533 name=FIVE_FINGER_PHYSICAL_CLICK, 534 variations=None, 535 prompt='Use five fingers to physically click ' 536 'the center of the touch surface.', 537 subprompt=None, 538 validators=( 539 CountTrackingIDValidator('== 5'), 540 PhysicalClickValidator('== 1', fingers=5), 541 ), 542 ), 543 544 STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS: 545 Gesture( 546 name=STATIONARY_FINGER_NOT_AFFECTED_BY_2ND_FINGER_TAPS, 547 variations=(GV.AROUND,), 548 prompt='Place your one stationary finger in the middle of the ' 549 'touch surface, and use a second finger to tap ' 550 'all around it', 551 subprompt=None, 552 validators=( 553 CountTrackingIDValidator('>= 2'), 554 StationaryFingerValidator(stationary_finger_criteria, slot=0), 555 ), 556 ), 557 558 FAT_FINGER_MOVE_WITH_RESTING_FINGER: 559 Gesture( 560 name=FAT_FINGER_MOVE_WITH_RESTING_FINGER, 561 variations=(GV.LR, GV.RL, GV.TB, GV.BT), 562 prompt='With a stationary finger on the {0} of the touch surface, ' 563 'draw a straight line with a FAT finger {1} {2} it.', 564 subprompt={ 565 GV.LR: ('center', 'from left to right', 'below'), 566 GV.RL: ('bottom edge', 'from right to left', 'above'), 567 GV.TB: ('center', 'from top to bottom', 'on the right to'), 568 GV.BT: ('center', 'from bottom to top', 'on the left to'), 569 }, 570 validators=( 571 CountTrackingIDValidator('== 2'), 572 LinearityValidator(relaxed_linearity_criteria, finger=1, 573 segments=VAL.MIDDLE), 574 LinearityValidator(relaxed_linearity_criteria, finger=1, 575 segments=VAL.BOTH_ENDS), 576 NoGapValidator(no_gap_criteria, slot=1), 577 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 578 ReportRateValidator(report_rate_criteria, finger=1), 579 StationaryFingerValidator(stationary_finger_criteria, slot=0), 580 ), 581 ), 582 583 DRAG_EDGE_THUMB: 584 Gesture( 585 name=DRAG_EDGE_THUMB, 586 variations=(GV.LR, GV.RL, GV.TB, GV.BT), 587 prompt='Drag the edge of your thumb {0} in a straight line ' 588 'across the touch surface', 589 subprompt={ 590 GV.LR: ('horizontally from left to right',), 591 GV.RL: ('horizontally from right to left',), 592 GV.TB: ('vertically from top to bottom',), 593 GV.BT: ('vertically from bottom to top',), 594 }, 595 validators=( 596 CountTrackingIDValidator('== 1'), 597 LinearityValidator(relaxed_linearity_criteria, finger=0, 598 segments=VAL.MIDDLE), 599 LinearityValidator(relaxed_linearity_criteria, finger=0, 600 segments=VAL.BOTH_ENDS), 601 NoGapValidator(no_gap_criteria, slot=0), 602 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 603 ReportRateValidator(report_rate_criteria), 604 ), 605 ), 606 607 TWO_CLOSE_FINGERS_TRACKING: 608 Gesture( 609 # TODO(josephsih): make a special two-finger pen to perform this 610 # gesture so that the finger distance remains the same every time 611 # this test is conducted. 612 name=TWO_CLOSE_FINGERS_TRACKING, 613 variations=(GV.LR, GV.TB, GV.TLBR), 614 prompt='With two fingers close together (lightly touching each ' 615 'other) in a two finger scrolling gesture, draw a {0} ' 616 'line {1}.', 617 subprompt={ 618 GV.LR: ('horizontal', 'from left to right',), 619 GV.TB: ('vertical', 'from top to bottom',), 620 GV.TLBR: ('diagonal', 'from the top left to the bottom right',), 621 }, 622 validators=( 623 CountTrackingIDValidator('== 2'), 624 LinearityValidator(relaxed_linearity_criteria, finger=0, 625 segments=VAL.MIDDLE), 626 LinearityValidator(relaxed_linearity_criteria, finger=0, 627 segments=VAL.BOTH_ENDS), 628 LinearityValidator(relaxed_linearity_criteria, finger=1, 629 segments=VAL.MIDDLE), 630 LinearityValidator(relaxed_linearity_criteria, finger=1, 631 segments=VAL.BOTH_ENDS), 632 NoGapValidator(no_gap_criteria, slot=0), 633 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 634 ReportRateValidator(report_rate_criteria), 635 ), 636 ), 637 638 RESTING_FINGER_PLUS_2ND_FINGER_MOVE: 639 Gesture( 640 name=RESTING_FINGER_PLUS_2ND_FINGER_MOVE, 641 variations=((GV.TLBR, GV.BRTL), 642 (GV.SLOW,), 643 ), 644 prompt='With a stationary finger in the bottom left corner, take ' 645 '{1} to draw a straight line {0} with a second finger.', 646 subprompt={ 647 GV.TLBR: ('from the top left to the bottom right',), 648 GV.BRTL: ('from the bottom right to the top left',), 649 GV.SLOW: ('3 seconds',), 650 }, 651 validators=( 652 CountTrackingIDValidator('== 2'), 653 LinearityValidator(relaxed_linearity_criteria, finger=1, 654 segments=VAL.MIDDLE), 655 LinearityValidator(relaxed_linearity_criteria, finger=1, 656 segments=VAL.BOTH_ENDS), 657 NoGapValidator(no_gap_criteria, slot=1), 658 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 659 ReportRateValidator(report_rate_criteria, finger=1), 660 StationaryFingerValidator(stationary_finger_criteria, slot=0), 661 ), 662 ), 663 664 TWO_FAT_FINGERS_TRACKING: 665 Gesture( 666 name=TWO_FAT_FINGERS_TRACKING, 667 variations=(GV.LR, GV.RL), 668 prompt='Use two FAT fingers separated by about 1cm to draw ' 669 'a straight line {0}.', 670 subprompt={ 671 GV.LR: ('from left to right',), 672 GV.RL: ('from right to left',), 673 }, 674 validators=( 675 CountTrackingIDValidator('== 2'), 676 LinearityValidator(relaxed_linearity_criteria, finger=0, 677 segments=VAL.MIDDLE), 678 LinearityValidator(relaxed_linearity_criteria, finger=0, 679 segments=VAL.BOTH_ENDS), 680 LinearityValidator(relaxed_linearity_criteria, finger=1, 681 segments=VAL.MIDDLE), 682 LinearityValidator(relaxed_linearity_criteria, finger=1, 683 segments=VAL.BOTH_ENDS), 684 NoGapValidator(no_gap_criteria, slot=0), 685 NoGapValidator(no_gap_criteria, slot=1), 686 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 687 NoReversedMotionValidator(no_reversed_motion_criteria, slots=1), 688 ReportRateValidator(report_rate_criteria), 689 ), 690 ), 691 692 FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS: 693 Gesture( 694 name=FIRST_FINGER_TRACKING_AND_SECOND_FINGER_TAPS, 695 variations=(GV.TLBR, GV.BRTL), 696 prompt='While drawing a straight line {0} slowly (~3 seconds), ' 697 'tap the bottom left corner with a second finger ' 698 'gently 3 times.', 699 subprompt={ 700 GV.TLBR: ('from top left to bottom right',), 701 GV.BRTL: ('from bottom right to top left',), 702 }, 703 validators=( 704 CountTrackingIDValidator('== 4'), 705 LinearityValidator(relaxed_linearity_criteria, finger=0, 706 segments=VAL.MIDDLE), 707 LinearityValidator(relaxed_linearity_criteria, finger=0, 708 segments=VAL.BOTH_ENDS), 709 NoGapValidator(no_gap_criteria, slot=0), 710 NoReversedMotionValidator(no_reversed_motion_criteria, slots=0), 711 ReportRateValidator(report_rate_criteria), 712 ), 713 ), 714 715 DRUMROLL: 716 Gesture( 717 name=DRUMROLL, 718 variations=(GV.FAST, ), 719 prompt='Use the index and middle finger of one hand to make a ' 720 '"drum roll" {0} by alternately tapping each finger ' 721 'for 5 seconds.', 722 subprompt={ 723 GV.FAST: ('as fast as possible',), 724 }, 725 validators=( 726 CountTrackingIDValidator('>= 5'), 727 DrumrollValidator(drumroll_criteria), 728 ), 729 timeout = 2000, 730 ), 731 732 RAPID_TAPS: 733 Gesture( 734 name=RAPID_TAPS, 735 variations=(GV.TL, GV.BR, GV.CENTER), 736 prompt='Tap the {0} of the touch surface 20 times quickly', 737 subprompt={ 738 GV.TL: ('top left corner',), 739 GV.TS: ('top edge',), 740 GV.TR: ('top right corner',), 741 GV.LS: ('left edge',), 742 GV.CENTER: ('center',), 743 GV.RS: ('right edge',), 744 GV.BL: ('bottom left corner',), 745 GV.BS: ('bottom edge',), 746 GV.BR: ('bottom right corner',), 747 }, 748 validators=( 749 CountTrackingIDValidator('== 20'), 750 ), 751 timeout = 2000, 752 ), 753 754 PRESSURE_CALIBRATION: 755 Gesture( 756 name=PRESSURE_CALIBRATION, 757 variations=(GV.SIZE0, GV.SIZE1, GV.SIZE2, GV.SIZE3, GV.SIZE4, 758 GV.SIZE5, GV.SIZE6, ), 759 prompt='Draw circles continuously for 5 seconds ' 760 'using the metal finger of size {0}.', 761 subprompt={ 762 GV.SIZE0: ('0 (the smallest size)',), 763 GV.SIZE1: ('1',), 764 GV.SIZE2: ('2',), 765 GV.SIZE3: ('3',), 766 GV.SIZE4: ('4',), 767 GV.SIZE5: ('5',), 768 GV.SIZE6: ('6 (the largest size)',), 769 }, 770 validators=( 771 CountTrackingIDValidator('== 1'), 772 ), 773 ), 774 } 775 return gesture_dict 776 777 778class FileName: 779 """A dummy class to hold the attributes in a test file name.""" 780 pass 781filename = FileName() 782filename.sep = '-' 783filename.ext = 'dat' 784 785 786class Gesture: 787 """A class defines the structure of Gesture.""" 788 # define the default timeout (in milli-seconds) when performing a gesture. 789 # A gesture is considered done when finger is lifted for this time interval. 790 TIMEOUT = int(1000/80*10) 791 792 def __init__(self, name=None, variations=None, prompt=None, subprompt=None, 793 validators=None, timeout=TIMEOUT): 794 self.name = name 795 self.variations = variations 796 self.prompt = prompt 797 self.subprompt = subprompt 798 self.validators = validators 799 self.timeout = timeout 800