| OLD | NEW |
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 | 7 |
| 8 # DESCRIPTION : | 8 # DESCRIPTION : |
| 9 # | 9 # |
| 10 # Intended for use during manufacturing to validate that the touchpad | 10 # Intended for use during manufacturing to validate that the touchpad |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 _X_OF_OFFSET = 486 + _F_RADIUS + 2 | 48 _X_OF_OFFSET = 486 + _F_RADIUS + 2 |
| 49 _Y_OF_OFFSET = 54 + _F_RADIUS + 2 | 49 _Y_OF_OFFSET = 54 + _F_RADIUS + 2 |
| 50 | 50 |
| 51 _X_TFL_OFFSET = 459 + _F_RADIUS + 2 | 51 _X_TFL_OFFSET = 459 + _F_RADIUS + 2 |
| 52 _X_TFR_OFFSET = 513 + _F_RADIUS + 2 | 52 _X_TFR_OFFSET = 513 + _F_RADIUS + 2 |
| 53 _Y_TF_OFFSET = 117 + _F_RADIUS + 2 | 53 _Y_TF_OFFSET = 117 + _F_RADIUS + 2 |
| 54 | 54 |
| 55 | 55 |
| 56 class TouchpadTest: | 56 class TouchpadTest: |
| 57 | 57 |
| 58 def __init__(self, tp_image, drawing_area, ft_state): | 58 def __init__(self, tp_image, drawing_area): |
| 59 self._tp_image = tp_image | 59 self._tp_image = tp_image |
| 60 self._drawing_area = drawing_area | 60 self._drawing_area = drawing_area |
| 61 self._ft_state = ft_state | |
| 62 self._motion_grid = {} | 61 self._motion_grid = {} |
| 63 for x in range(_X_SEGMENTS): | 62 for x in range(_X_SEGMENTS): |
| 64 for y in range(_Y_SEGMENTS): | 63 for y in range(_Y_SEGMENTS): |
| 65 self._motion_grid['%d,%d' % (x, y)] = False | 64 self._motion_grid['%d,%d' % (x, y)] = False |
| 66 self._scroll_array = {} | 65 self._scroll_array = {} |
| 67 for y in range(_Y_SEGMENTS): | 66 for y in range(_Y_SEGMENTS): |
| 68 self._scroll_array[y] = False | 67 self._scroll_array[y] = False |
| 69 self._l_click = False | 68 self._l_click = False |
| 70 self._r_click = False | 69 self._r_click = False |
| 71 self._of_z_rad = 0 | 70 self._of_z_rad = 0 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 if self._l_click and not self._r_click: | 184 if self._l_click and not self._r_click: |
| 186 context.set_source_rgba(*ful.RGBA_YELLOW_OVERLAY) | 185 context.set_source_rgba(*ful.RGBA_YELLOW_OVERLAY) |
| 187 | 186 |
| 188 context.arc(_X_TFL_OFFSET, _Y_TF_OFFSET, self._tf_z_rad, 0.0, 2.0 * pi) | 187 context.arc(_X_TFL_OFFSET, _Y_TF_OFFSET, self._tf_z_rad, 0.0, 2.0 * pi) |
| 189 context.fill() | 188 context.fill() |
| 190 context.arc(_X_TFR_OFFSET, _Y_TF_OFFSET, self._tf_z_rad, 0.0, 2.0 * pi) | 189 context.arc(_X_TFR_OFFSET, _Y_TF_OFFSET, self._tf_z_rad, 0.0, 2.0 * pi) |
| 191 context.fill() | 190 context.fill() |
| 192 | 191 |
| 193 return True | 192 return True |
| 194 | 193 |
| 195 def key_press_event(self, widget, event): | |
| 196 self._ft_state.exit_on_trigger(event) | |
| 197 return True | |
| 198 | |
| 199 def button_press_event(self, widget, event): | 194 def button_press_event(self, widget, event): |
| 200 factory.log('button_press_event %d,%d' % (event.x, event.y)) | 195 factory.log('button_press_event %d,%d' % (event.x, event.y)) |
| 201 return True | 196 return True |
| 202 | 197 |
| 203 def button_release_event(self, widget, event): | 198 def button_release_event(self, widget, event): |
| 204 factory.log('button_release_event %d,%d' % (event.x, event.y)) | 199 factory.log('button_release_event %d,%d' % (event.x, event.y)) |
| 205 return True | 200 return True |
| 206 | 201 |
| 207 def motion_event(self, widget, event): | 202 def motion_event(self, widget, event): |
| 208 factory.log('motion_event %d,%d' % (event.x, event.y)) | 203 factory.log('motion_event %d,%d' % (event.x, event.y)) |
| 209 return True | 204 return True |
| 210 | 205 |
| 211 def register_callbacks(self, window): | |
| 212 window.connect('key-press-event', self.key_press_event) | |
| 213 window.add_events(gdk.KEY_PRESS_MASK) | |
| 214 | |
| 215 | 206 |
| 216 class SynClient: | 207 class SynClient: |
| 217 | 208 |
| 218 def __init__(self, test): | 209 def __init__(self, test): |
| 219 self._test = test | 210 self._test = test |
| 220 proc = subprocess.Popen(_SYNCLIENT_SETTINGS_CMDLINE.split(), | 211 proc = subprocess.Popen(_SYNCLIENT_SETTINGS_CMDLINE.split(), |
| 221 stdout=subprocess.PIPE) | 212 stdout=subprocess.PIPE) |
| 222 settings_data = proc.stdout.readlines() | 213 settings_data = proc.stdout.readlines() |
| 223 settings = {} | 214 settings = {} |
| 224 for line in settings_data: | 215 for line in settings_data: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 def quit(self): | 247 def quit(self): |
| 257 factory.log('killing SynClient ...') | 248 factory.log('killing SynClient ...') |
| 258 self._proc.kill() | 249 self._proc.kill() |
| 259 factory.log('dead') | 250 factory.log('dead') |
| 260 | 251 |
| 261 | 252 |
| 262 class factory_Touchpad(test.test): | 253 class factory_Touchpad(test.test): |
| 263 version = 1 | 254 version = 1 |
| 264 preserve_srcdir = True | 255 preserve_srcdir = True |
| 265 | 256 |
| 266 def run_once(self, | 257 def run_once(self): |
| 267 test_widget_size=None, | |
| 268 trigger_set=None): | |
| 269 | 258 |
| 270 factory.log('%s run_once' % self.__class__) | 259 factory.log('%s run_once' % self.__class__) |
| 271 | 260 |
| 272 ft_state = ful.State(trigger_set) | |
| 273 | |
| 274 os.chdir(self.srcdir) | 261 os.chdir(self.srcdir) |
| 275 tp_image = cairo.ImageSurface.create_from_png('touchpad.png') | 262 tp_image = cairo.ImageSurface.create_from_png('touchpad.png') |
| 276 image_size = (tp_image.get_width(), tp_image.get_height()) | 263 image_size = (tp_image.get_width(), tp_image.get_height()) |
| 277 | 264 |
| 278 drawing_area = gtk.DrawingArea() | 265 drawing_area = gtk.DrawingArea() |
| 279 | 266 |
| 280 test = TouchpadTest(tp_image, drawing_area, ft_state) | 267 test = TouchpadTest(tp_image, drawing_area) |
| 281 | 268 |
| 282 drawing_area.set_size_request(*image_size) | 269 drawing_area.set_size_request(*image_size) |
| 283 drawing_area.connect('expose_event', test.expose_event) | 270 drawing_area.connect('expose_event', test.expose_event) |
| 284 drawing_area.connect('button-press-event', test.button_press_event) | 271 drawing_area.connect('button-press-event', test.button_press_event) |
| 285 drawing_area.connect('button-release-event', test.button_release_event) | 272 drawing_area.connect('button-release-event', test.button_release_event) |
| 286 drawing_area.connect('motion-notify-event', test.motion_event) | 273 drawing_area.connect('motion-notify-event', test.motion_event) |
| 287 drawing_area.add_events(gdk.EXPOSURE_MASK | | 274 drawing_area.add_events(gdk.EXPOSURE_MASK | |
| 288 gdk.BUTTON_PRESS_MASK | | 275 gdk.BUTTON_PRESS_MASK | |
| 289 gdk.BUTTON_RELEASE_MASK | | 276 gdk.BUTTON_RELEASE_MASK | |
| 290 gdk.POINTER_MOTION_MASK) | 277 gdk.POINTER_MOTION_MASK) |
| 291 | 278 |
| 292 countdown_widget, countdown_label = ful.make_countdown_widget() | 279 countdown_widget, countdown_label = ful.make_countdown_widget() |
| 293 gobject.timeout_add(1000, test.timer_event, countdown_label) | 280 gobject.timeout_add(1000, test.timer_event, countdown_label) |
| 294 | 281 |
| 295 test_widget = gtk.VBox() | 282 test_widget = gtk.VBox() |
| 296 test_widget.set_spacing(20) | 283 test_widget.set_spacing(20) |
| 297 test_widget.pack_start(drawing_area, False, False) | 284 test_widget.pack_start(drawing_area, False, False) |
| 298 test_widget.pack_start(countdown_widget, False, False) | 285 test_widget.pack_start(countdown_widget, False, False) |
| 299 | 286 |
| 300 synclient = SynClient(test) | 287 synclient = SynClient(test) |
| 301 | 288 |
| 302 ft_state.run_test_widget( | 289 ful.run_test_widget(self.job, test_widget, |
| 303 test_widget=test_widget, | |
| 304 test_widget_size=test_widget_size, | |
| 305 window_registration_callback=test.register_callbacks, | |
| 306 cleanup_callback=synclient.quit) | 290 cleanup_callback=synclient.quit) |
| 307 | 291 |
| 308 missing = test.calc_missing_string() | 292 missing = test.calc_missing_string() |
| 309 if missing: | 293 if missing: |
| 310 raise error.TestFail(missing) | 294 raise error.TestFail(missing) |
| 311 | 295 |
| 312 factory.log('%s run_once finished' % self.__class__) | 296 factory.log('%s run_once finished' % self.__class__) |
| OLD | NEW |