Home | History | Annotate | Download | only in firmware_TouchMTB
      1 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """Define constants for firmware touch device MTB tests."""
      6 
      7 
      8 import sys
      9 
     10 sys.path.append('../../bin/input')
     11 from linux_input import (KEY_D, KEY_M, KEY_X, KEY_Y, KEY_ENTER, KEY_SPACE,
     12                          KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT)
     13 
     14 
     15 class _ConstantError(AttributeError):
     16     """A constant error exception."""
     17     pass
     18 
     19 
     20 class _Constant(object):
     21     """This is a constant base class to ensure no rebinding of constants."""
     22     def __setattr__(self, name, value):
     23         """Check the attribute assignment. No rebinding is allowed."""
     24         if name in self.__dict__:
     25             raise _ConstantError, "Cannot rebind the constant: %s" % name
     26         self.__dict__[name] = value
     27 
     28 
     29 """Define constants classes in alphabetic order below."""
     30 
     31 
     32 class _Axis(_Constant):
     33     """Constants about two axes."""
     34     pass
     35 AXIS = _Axis()
     36 AXIS.X = 'x'
     37 AXIS.Y = 'y'
     38 AXIS.LIST = [AXIS.X, AXIS.Y]
     39 
     40 
     41 class _DeviceType(_Constant):
     42     """Constants about device types."""
     43 DEV = _DeviceType()
     44 DEV.TOUCHPAD = 'touchpad'
     45 DEV.TOUCHSCREEN = 'touchscreen'
     46 DEV.DEVICE_TYPE_LIST = list(DEV.__dict__.values())
     47 
     48 
     49 class _Fuzzy_MF(_Constant):
     50     """Constants about fuzzy membership functions."""
     51     pass
     52 MF = _Fuzzy_MF()
     53 MF.PI_FUNCTION = 'Pi_Function'
     54 MF.S_FUNCTION = 'S_Function'
     55 MF.SINGLETON_FUNCTION = 'Singleton_Function'
     56 MF.TRAPEZ_FUNCTION = 'Trapez_Function'
     57 MF.TRIANGLE_FUNCTION = 'Triangle_Function'
     58 MF.Z_FUNCTION = 'Z_Function'
     59 
     60 
     61 class _GestureVariation(_Constant):
     62     """Constants about gesture variations."""
     63     pass
     64 GV = _GestureVariation()
     65 # constants about directions
     66 GV.HORIZONTAL = 'horizontal'
     67 GV.VERTICAL = 'vertical'
     68 GV.DIAGONAL = 'diagonal'
     69 GV.LR = 'left_to_right'
     70 GV.RL = 'right_to_left'
     71 GV.TB = 'top_to_bottom'
     72 GV.BT = 'bottom_to_top'
     73 GV.CL = 'center_to_left'
     74 GV.CR = 'center_to_right'
     75 GV.CT = 'center_to_top'
     76 GV.CB = 'center_to_bottom'
     77 GV.CUR = 'center_to_upper_right'
     78 GV.CUL = 'center_to_upper_left'
     79 GV.CLR = 'center_to_lower_right'
     80 GV.CLL = 'center_to_lower_left'
     81 GV.BLTR = 'bottom_left_to_top_right'
     82 GV.BRTL = 'bottom_right_to_top_left'
     83 GV.TRBL = 'top_right_to_bottom_left'
     84 GV.TLBR = 'top_left_to_bottom_right'
     85 GV.HORIZONTAL_DIRECTIONS = [GV.HORIZONTAL, GV.LR, GV.RL, GV.CL, GV.CR]
     86 GV.VERTICAL_DIRECTIONS = [GV.VERTICAL, GV.TB, GV.BT, GV.CT, GV.CB]
     87 GV.DIAGONAL_DIRECTIONS = [GV.DIAGONAL, GV.BLTR, GV.BRTL, GV.TRBL, GV.TLBR,
     88                           GV.CUR, GV.CUL, GV.CLR, GV.CLL]
     89 GV.GESTURE_DIRECTIONS = (GV.HORIZONTAL_DIRECTIONS + GV.VERTICAL_DIRECTIONS +
     90                          GV.DIAGONAL_DIRECTIONS)
     91 # constants about locations
     92 GV.TL = 'top_left'
     93 GV.TR = 'top_right'
     94 GV.BL = 'bottom_left'
     95 GV.BR = 'bottom_right'
     96 GV.TS = 'top_side'
     97 GV.BS = 'bottom_side'
     98 GV.LS = 'left_side'
     99 GV.RS = 'right_side'
    100 GV.CENTER = 'center'
    101 GV.AROUND = 'around'
    102 GV.GESTURE_LOCATIONS = [GV.TL, GV.TR, GV.BL, GV.BR, GV.TS, GV.BS, GV.LS, GV.RS,
    103                         GV.CENTER, GV.AROUND]
    104 # constants about pinch to zoom
    105 GV.ZOOM_IN = 'zoom_in'
    106 GV.ZOOM_OUT = 'zoom_out'
    107 # constants about speed
    108 GV.SLOW = 'slow'
    109 GV.NORMAL = 'normal'
    110 GV.FAST = 'fast'
    111 GV.FULL_SPEED = 'full_speed'
    112 GV.GESTURE_SPEED = [GV.SLOW, GV.NORMAL, GV.FAST, GV.FULL_SPEED]
    113 # constants about noise frequency
    114 GV.LOW_FREQUENCY = 'low_frequency'
    115 GV.MED_FREQUENCY = 'med_frequency'
    116 GV.HIGH_FREQUENCY = 'high_frequency'
    117 # constants used in the extended frequency sweep.
    118 # Sweep from 0Hz to 1MHz at an interval of 400Hz for 2500 tests.
    119 GV.EXTENDED_FREQUENCIES = ['%dHz' % x for x in range(0, 1000000, 400)]
    120 GV.NOISE_FREQUENCY = [GV.LOW_FREQUENCY, GV.MED_FREQUENCY, GV.HIGH_FREQUENCY] + \
    121                       GV.EXTENDED_FREQUENCIES
    122 # constants about noise waveform
    123 GV.SQUARE_WAVE = 'square_wave'
    124 GV.SINE_WAVE = 'sine_wave'
    125 GV.NOISE_WAVEFORM = [GV.SQUARE_WAVE, GV.SINE_WAVE]
    126 # constants about noise amplitude
    127 GV.MAX_AMPLITUDE = 'max_amplitude'
    128 GV.HALF_AMPLITUDE = 'half_amplitude'
    129 GV.NOISE_AMPLITUDE = [GV.HALF_AMPLITUDE, GV.MAX_AMPLITUDE]
    130 # constants about metal finger sizes
    131 GV.SIZE = 'size'
    132 size_str = lambda i: GV.SIZE + str(i)
    133 GV.SIZE0 = size_str(0)
    134 GV.SIZE1 = size_str(1)
    135 GV.SIZE2 = size_str(2)
    136 GV.SIZE3 = size_str(3)
    137 GV.SIZE4 = size_str(4)
    138 GV.SIZE5 = size_str(5)
    139 GV.SIZE6 = size_str(6)
    140 GV.NUMBER_OF_SIZES = 7
    141 GV.SIZE_LIST = [size_str(i) for i in range(GV.NUMBER_OF_SIZES)]
    142 
    143 
    144 class _Mode(_Constant):
    145     """Constants about gesture playing mode."""
    146     pass
    147 MODE = _Mode()
    148 MODE.CALIBRATION = 'calibration'
    149 MODE.COMPLETE = 'complete'
    150 MODE.MANUAL = 'manual'
    151 MODE.NOISE = 'noise'
    152 MODE.QUICKSTEP = 'quickstep'
    153 MODE.REPLAY = 'replay'
    154 MODE.ROBOT = 'robot'
    155 MODE.ROBOT_SIM = 'robot_sim'
    156 # GESTURE_PLAY_MODE is a list of all attributes above
    157 MODE.GESTURE_PLAY_MODE = list(MODE.__dict__.values())
    158 
    159 
    160 class _MTB(_Constant):
    161     """Constants about MTB event format and MTB related constants."""
    162     pass
    163 MTB = _MTB()
    164 MTB.EV_TIME = 'EV_TIME'
    165 MTB.EV_TYPE = 'EV_TYPE'
    166 MTB.EV_CODE = 'EV_CODE'
    167 MTB.EV_VALUE = 'EV_VALUE'
    168 MTB.SYN_REPORT = 'SYN_REPORT'
    169 MTB.SLOT = 'slot'
    170 MTB.POINTS = 'points'
    171 
    172 
    173 class _Options(_Constant):
    174     """Constants about command line options."""
    175     pass
    176 OPTIONS = _Options()
    177 OPTIONS.DEBUG = 'debug'
    178 OPTIONS.DEVICE = 'system_device'
    179 OPTIONS.DIR = 'directory'
    180 OPTIONS.FNGENERATOR = 'function_generator'
    181 OPTIONS.HELP = 'help'
    182 OPTIONS.INDIVIDUAL = 'individual'
    183 OPTIONS.ITERATIONS = 'iterations'
    184 OPTIONS.METRICS = 'show_metrics'
    185 OPTIONS.MODE = 'mode'
    186 OPTIONS.REPLAY = 'replay'
    187 OPTIONS.RESUME = 'resume'
    188 OPTIONS.SCORES = 'scores'
    189 OPTIONS.SIMPLIFIED = 'simplified'
    190 OPTIONS.SKIP_HTML = 'skip_html'
    191 OPTIONS.TOUCHSCREEN = 'touchscreen'
    192 OPTIONS.UPLOAD = 'upload'
    193 
    194 
    195 class _Platform(_Constant):
    196     """Constants about chromebook platforms."""
    197     pass
    198 PLATFORM = _Platform()
    199 PLATFORM.ALEX = 'alex'
    200 PLATFORM.LUMPY = 'lumpy'
    201 PLATFORM.LINK = 'link'
    202 PLATFORM.LIST = [PLATFORM.ALEX, PLATFORM.LUMPY, PLATFORM.LINK]
    203 
    204 
    205 class _RobotControl(_Constant):
    206     """Constants about robot control."""
    207     pass
    208 RC = _RobotControl()
    209 RC.PAUSE_TYPE = 'pause_type'
    210 RC.PROMPT = 'finger_control_prompt'
    211 # Finger interaction per gesture
    212 # e.g., the TWO_FINGER_TRACKING gesture requires installing an extra finger
    213 #       once for all variations in the same gesture.
    214 RC.PER_GESTURE = 'per_gesture'
    215 # Finger interaction per variation
    216 # e.g., the FINGER_CROSSING gesture requires putting down and lifting up
    217 # a metal finger repeatedly per variation.
    218 RC.PER_VARIATION = 'per_variation'
    219 
    220 
    221 class _TFK(_Constant):
    222     """The Test Flow Keypress (TFK) codes for test flow"""
    223     pass
    224 TFK = _TFK()
    225 TFK.DISCARD = KEY_D
    226 TFK.EXIT = KEY_X
    227 TFK.MORE = KEY_M
    228 TFK.SAVE = KEY_SPACE
    229 TFK.SAVE2 = KEY_ENTER
    230 TFK.YES = KEY_Y
    231 TFK.UP = KEY_UP
    232 TFK.DOWN = KEY_DOWN
    233 TFK.LEFT = KEY_LEFT
    234 TFK.RIGHT = KEY_RIGHT
    235 TFK.ARROW_KEY_LIST = [TFK.UP, TFK.DOWN, TFK.LEFT, TFK.RIGHT]
    236 
    237 
    238 class _UNIT(_Constant):
    239     """Constants about units."""
    240     pass
    241 UNIT = _UNIT()
    242 UNIT.PIXEL = 'px'
    243 UNIT.MM = 'mm'
    244 
    245 
    246 class _Validator(_Constant):
    247     """Constants about validator."""
    248     pass
    249 VAL = _Validator()
    250 VAL.BEGIN = 'Begin'
    251 VAL.MIDDLE = 'Middle'
    252 VAL.END = 'End'
    253 VAL.BOTH_ENDS = 'BothEnds'
    254 VAL.WHOLE = 'Whole'
    255 # SEGMENT_LIST is a list of all attributes above
    256 VAL.SEGMENT_LIST = list(VAL.__dict__.values())
    257