Index: client/site_tests/factory_Display/factory_Display.py |
diff --git a/client/site_tests/factory_Display/factory_Display.py b/client/site_tests/factory_Display/factory_Display.py |
index 7d460a00c604c66c9bb1ed63ab1c2b09fbf96bda..60032fe68a29ad83ca1a03f634bd47118b3be2b9 100644 |
--- a/client/site_tests/factory_Display/factory_Display.py |
+++ b/client/site_tests/factory_Display/factory_Display.py |
@@ -5,43 +5,19 @@ |
# DESCRIPTION : |
# |
-# This is an example factory test that does not really do anything -- |
-# it displays a message in the center of the testing area, as |
-# communicated by arguments to run_once(). This test makes use of the |
-# factory_test library to display its UI, and to monitor keyboard |
-# events for test-switching triggers. This test can be terminated by |
-# typing SHIFT-Q. |
+# This is a factory test to test the LCD display. |
-from autotest_lib.client.bin import test |
-from autotest_lib.client.common_lib import error |
-from autotest_lib.client.common_lib import factory_test |
import gtk |
import pango |
import os |
import sys |
+from autotest_lib.client.bin import factory |
+from autotest_lib.client.bin import factory_ui_lib as ful |
+from autotest_lib.client.bin import test |
+from autotest_lib.client.common_lib import error |
-def XXX_log(s): |
- print >> sys.stderr, 'FACTORY: ' + s |
- |
- |
-_BLACK = gtk.gdk.Color() |
-_RED = gtk.gdk.Color(0xFFFF, 0, 0) |
-_GREEN = gtk.gdk.Color(0, 0xFFFF, 0) |
-_BLUE = gtk.gdk.Color(0, 0, 0xFFFF) |
-_WHITE = gtk.gdk.Color(0xFFFF, 0xFFFF, 0xFFFF) |
- |
-_ACTIVE = 'ACTIVE' |
-_PASSED = 'PASS' |
-_FAILED = 'FAIL' |
-_UNTESTED = 'UNTESTED' |
- |
-_LABEL_COLORS = { |
- _ACTIVE: gtk.gdk.color_parse('light goldenrod'), |
- _PASSED: gtk.gdk.color_parse('pale green'), |
- _FAILED: gtk.gdk.color_parse('tomato'), |
- _UNTESTED: gtk.gdk.color_parse('dark slate grey')} |
_LABEL_STATUS_SIZE = (140, 30) |
_LABEL_STATUS_FONT = pango.FontDescription('courier new condensed 16') |
@@ -63,7 +39,7 @@ def pattern_cb_grid(widget, event, color=None): |
dr = widget.window |
xmax, ymax = dr.get_size() |
gc = gtk.gdk.GC(dr) |
- gc.set_rgb_fg_color(_BLACK) |
+ gc.set_rgb_fg_color(ful.BLACK) |
dr.draw_rectangle(gc, True, 0, 0, xmax, ymax) |
gc.set_rgb_fg_color(color) |
gc.set_line_attributes(1, |
@@ -78,11 +54,11 @@ def pattern_cb_grid(widget, event, color=None): |
_PATTERN_LIST = [ |
- ('solid red', lambda *x: pattern_cb_solid(*x, **{'color':_RED})), |
- ('solid green', lambda *x: pattern_cb_solid(*x, **{'color':_GREEN})), |
- ('solid blue', lambda *x: pattern_cb_solid(*x, **{'color':_BLUE})), |
- ('solid white', lambda *x: pattern_cb_solid(*x, **{'color':_WHITE})), |
- ('grid', lambda *x: pattern_cb_grid(*x, **{'color':_GREEN}))] |
+ ('solid red', lambda *x: pattern_cb_solid(*x, **{'color':ful.RED})), |
+ ('solid green', lambda *x: pattern_cb_solid(*x, **{'color':ful.GREEN})), |
+ ('solid blue', lambda *x: pattern_cb_solid(*x, **{'color':ful.BLUE})), |
+ ('solid white', lambda *x: pattern_cb_solid(*x, **{'color':ful.WHITE})), |
+ ('grid', lambda *x: pattern_cb_grid(*x, **{'color':ful.GREEN}))] |
class factory_Display(test.test): |
@@ -105,7 +81,7 @@ class factory_Display(test.test): |
return |
self._current_pattern = self._pattern_queue.pop() |
name, cb_fn = self._current_pattern |
- self._status_map[name] = _ACTIVE |
+ self._status_map[name] = ful.ACTIVE |
self._current_pattern_shown = False |
def key_press_callback(self, widget, event): |
@@ -121,28 +97,27 @@ class factory_Display(test.test): |
self._fs_window = None |
self._current_pattern_shown = True |
elif event.keyval == gtk.keysyms.Tab and self._current_pattern_shown: |
- self._status_map[pattern_name] = _FAILED |
+ self._status_map[pattern_name] = ful.FAILED |
self.goto_next_pattern() |
elif event.keyval == gtk.keysyms.Return and self._current_pattern_shown: |
- self._status_map[pattern_name] = _PASSED |
+ self._status_map[pattern_name] = ful.PASSED |
self.goto_next_pattern() |
elif event.keyval == ord('Q'): |
- factory_test.XXX_log('factory_Display exiting...') |
gtk.main_quit() |
else: |
- factory_test.test_switch_on_trigger(event) |
+ self._ft_state.exit_on_trigger(event) |
self._test_widget.queue_draw() |
return True |
def label_status_expose(self, widget, event, name=None): |
status = self._status_map[name] |
widget.set_text(status) |
- widget.modify_fg(gtk.STATE_NORMAL, _LABEL_COLORS[status]) |
+ widget.modify_fg(gtk.STATE_NORMAL, ful.LABEL_COLORS[status]) |
def make_pattern_label_box(self, name): |
eb = gtk.EventBox() |
- eb.modify_bg(gtk.STATE_NORMAL, _BLACK) |
- label_status = gtk.Label(_UNTESTED) |
+ eb.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
+ label_status = gtk.Label(ful.UNTESTED) |
label_status.set_size_request(*_LABEL_STATUS_SIZE) |
label_status.set_alignment(0, 0.5) |
label_status.modify_font(_LABEL_STATUS_FONT) |
@@ -170,21 +145,23 @@ class factory_Display(test.test): |
window.connect('key-release-event', self.key_release_callback) |
window.add_events(gtk.gdk.KEY_RELEASE_MASK) |
- def run_once(self, test_widget_size=None, trigger_set=None, |
+ def run_once(self, |
+ test_widget_size=None, |
+ trigger_set=None, |
result_file_path=None): |
- factory_test.XXX_log('factory_Display') |
+ factory.log('%s run_once' % self.__class__) |
xset_status = os.system('xset r off') |
- xmm_status = os.system('xmodmap -e "clear Lock"') |
- if xset_status or xmm_status: |
- raise TestFail('ERROR: disabling key repeat or caps lock') |
+ if xset_status: |
+ raise TestFail('ERROR: disabling key repeat') |
- factory_test.init(trigger_set=trigger_set, |
- result_file_path=result_file_path) |
+ self._ft_state = ful.State( |
+ trigger_set=trigger_set, |
+ result_file_path=result_file_path) |
self._pattern_queue = [x for x in reversed(_PATTERN_LIST)] |
- self._status_map = dict((n, _UNTESTED) for n, f in _PATTERN_LIST) |
+ self._status_map = dict((n, ful.UNTESTED) for n, f in _PATTERN_LIST) |
prompt_label = gtk.Label('hold SPACE to display pattern,\n' |
'TAB to fail and RETURN to pass\n') |
@@ -201,7 +178,7 @@ class factory_Display(test.test): |
vbox.pack_start(label_box, False, False) |
test_widget = gtk.EventBox() |
- test_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black')) |
+ test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
test_widget.add(vbox) |
self._test_widget = test_widget |
@@ -209,15 +186,15 @@ class factory_Display(test.test): |
self._fs_window = None |
- factory_test.run_test_widget( |
+ self._ft_state.run_test_widget( |
test_widget=test_widget, |
test_widget_size=test_widget_size, |
window_registration_callback=self.register_callbacks) |
failed_set = set(name for name, status in self._status_map.items() |
- if status is not _PASSED) |
+ if status is not ful.PASSED) |
if failed_set: |
raise error.TestFail('some patterns failed (%s)' % |
', '.join(failed_set)) |
- factory_test.XXX_log('exiting factory_Display') |
+ factory.log('%s run_once finished' % self.__class__) |