Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: client/site_tests/factory_Dummy/factory_Dummy.py

Issue 2836043: Relocate library files for wider access and re-use; also associated cleanup. (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: patch typo Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 # DESCRIPTION : 6 # DESCRIPTION :
7 # 7 #
8 # This is an example factory test that does not really do anything -- 8 # This is an example factory test that does not really do anything --
9 # it displays a message in the center of the testing area, as 9 # it displays a message in the center of the testing area, as
10 # communicated by arguments to run_once(). This test makes use of the 10 # communicated by arguments to run_once(). This test makes use of the
11 # factory_test library to display its UI, and to monitor keyboard 11 # factory_ui_lib library to display its UI, and to monitor keyboard
12 # events for test-switching triggers. This test can be terminated by 12 # events for test-switching triggers. This test can be terminated by
13 # typing SHIFT-Q. 13 # typing SHIFT-Q.
14 14
15 from autotest_lib.client.bin import test
16 from autotest_lib.client.common_lib import error
17 from autotest_lib.client.common_lib import factory_test
18 15
19 import gtk 16 import gtk
20 import pango 17 import pango
21 import sys 18 import sys
22 19
20 from autotest_lib.client.bin import factory
21 from autotest_lib.client.bin import factory_ui_lib as ful
22 from autotest_lib.client.bin import test
23 from autotest_lib.client.common_lib import error
24
23 25
24 class factory_Dummy(test.test): 26 class factory_Dummy(test.test):
25 version = 1 27 version = 1
26 28
27 def key_release_callback(self, widget, event): 29 def key_release_callback(self, widget, event):
28 char = event.keyval in range(32,127) and chr(event.keyval) or None 30 char = event.keyval in range(32,127) and chr(event.keyval) or None
29 factory_test.XXX_log('key_release_callback %s(%s)' % 31 factory.log('key_release_callback %s(%s)' % (event.keyval, char))
30 (event.keyval, char)) 32 if event.keyval == self._quit_key:
31 if event.keyval == self.quit_key:
32 factory_test.XXX_log('factory_Dummy exiting...')
33 gtk.main_quit() 33 gtk.main_quit()
34 factory_test.test_switch_on_trigger(event) 34 self._ft_state.exit_on_trigger(event)
35 return True 35 return True
36 36
37 def register_callbacks(self, window): 37 def register_callbacks(self, window):
38 window.connect('key-release-event', self.key_release_callback) 38 window.connect('key-release-event', self.key_release_callback)
39 window.add_events(gtk.gdk.KEY_RELEASE_MASK) 39 window.add_events(gtk.gdk.KEY_RELEASE_MASK)
40 40
41 def run_once(self, test_widget_size=None, trigger_set=None, 41 def run_once(self,
42 result_file_path=None, quit_key=ord('Q'), msg='factory_Dummy'): 42 test_widget_size=None,
43 trigger_set=None,
44 result_file_path=None,
45 quit_key=ord('Q'),
46 msg='factory_Dummy'):
43 47
44 factory_test.XXX_log('factory_Dummy') 48 factory.log('%s run_once' % self.__class__)
45 49
46 self.quit_key = quit_key 50 self._quit_key = quit_key
47 51
48 factory_test.init(trigger_set=trigger_set, 52 self._ft_state = ful.State(
49 result_file_path=result_file_path) 53 trigger_set=trigger_set,
54 result_file_path=result_file_path)
50 55
51 label = gtk.Label(msg) 56 label = gtk.Label(msg)
52 label.modify_font(pango.FontDescription('courier new condensed 20')) 57 label.modify_font(pango.FontDescription('courier new condensed 20'))
53 label.set_alignment(0.5, 0.5) 58 label.set_alignment(0.5, 0.5)
54 label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('light green')) 59 label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('light green'))
55 60
56 test_widget = gtk.EventBox() 61 test_widget = gtk.EventBox()
57 test_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black')) 62 test_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
58 test_widget.add(label) 63 test_widget.add(label)
59 64
60 factory_test.run_test_widget( 65 self._ft_state.run_test_widget(
61 test_widget=test_widget, 66 test_widget=test_widget,
62 test_widget_size=test_widget_size, 67 test_widget_size=test_widget_size,
63 window_registration_callback=self.register_callbacks) 68 window_registration_callback=self.register_callbacks)
64 69
65 factory_test.XXX_log('exiting factory_Dummy') 70 factory.log('%s run_once finished' % self.__class__)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698