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 # This is a factory test to test the LCD display. | 10 # This is a factory test to test the LCD display. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 self._fs_window = None | 103 self._fs_window = None |
104 self._current_pattern_shown = True | 104 self._current_pattern_shown = True |
105 elif event.keyval == gtk.keysyms.Tab and self._current_pattern_shown: | 105 elif event.keyval == gtk.keysyms.Tab and self._current_pattern_shown: |
106 self._status_map[pattern_name] = ful.FAILED | 106 self._status_map[pattern_name] = ful.FAILED |
107 self.goto_next_pattern() | 107 self.goto_next_pattern() |
108 elif event.keyval == gtk.keysyms.Return and self._current_pattern_shown: | 108 elif event.keyval == gtk.keysyms.Return and self._current_pattern_shown: |
109 self._status_map[pattern_name] = ful.PASSED | 109 self._status_map[pattern_name] = ful.PASSED |
110 self.goto_next_pattern() | 110 self.goto_next_pattern() |
111 elif event.keyval == ord('Q'): | 111 elif event.keyval == ord('Q'): |
112 gtk.main_quit() | 112 gtk.main_quit() |
113 else: | |
114 self._ft_state.exit_on_trigger(event) | |
115 self._test_widget.queue_draw() | 113 self._test_widget.queue_draw() |
116 return True | 114 return True |
117 | 115 |
118 def label_status_expose(self, widget, event, name=None): | 116 def label_status_expose(self, widget, event, name=None): |
119 status = self._status_map[name] | 117 status = self._status_map[name] |
120 widget.set_text(status) | 118 widget.set_text(status) |
121 widget.modify_fg(gtk.STATE_NORMAL, ful.LABEL_COLORS[status]) | 119 widget.modify_fg(gtk.STATE_NORMAL, ful.LABEL_COLORS[status]) |
122 | 120 |
123 def make_pattern_label_box(self, name): | 121 def make_pattern_label_box(self, name): |
124 | 122 |
(...skipping 15 matching lines...) Expand all Loading... |
140 eb.modify_bg(gtk.STATE_NORMAL, ful.BLACK) | 138 eb.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
141 eb.add(hbox) | 139 eb.add(hbox) |
142 return eb | 140 return eb |
143 | 141 |
144 def register_callbacks(self, window): | 142 def register_callbacks(self, window): |
145 window.connect('key-press-event', self.key_press_callback) | 143 window.connect('key-press-event', self.key_press_callback) |
146 window.add_events(gdk.KEY_PRESS_MASK) | 144 window.add_events(gdk.KEY_PRESS_MASK) |
147 window.connect('key-release-event', self.key_release_callback) | 145 window.connect('key-release-event', self.key_release_callback) |
148 window.add_events(gdk.KEY_RELEASE_MASK) | 146 window.add_events(gdk.KEY_RELEASE_MASK) |
149 | 147 |
150 def run_once(self, | 148 def run_once(self): |
151 test_widget_size=None, | |
152 trigger_set=None): | |
153 | 149 |
154 factory.log('%s run_once' % self.__class__) | 150 factory.log('%s run_once' % self.__class__) |
155 | 151 |
156 self._ft_state = ful.State(trigger_set) | |
157 | |
158 self._pattern_queue = [x for x in reversed(_PATTERN_LIST)] | 152 self._pattern_queue = [x for x in reversed(_PATTERN_LIST)] |
159 self._status_map = dict((n, ful.UNTESTED) for n, f in _PATTERN_LIST) | 153 self._status_map = dict((n, ful.UNTESTED) for n, f in _PATTERN_LIST) |
160 | 154 |
161 self._prompt_label = ful.make_label(_MESSAGE_STR, alignment=(0.5, 0.5)) | 155 self._prompt_label = ful.make_label(_MESSAGE_STR, alignment=(0.5, 0.5)) |
162 | 156 |
163 vbox = gtk.VBox() | 157 vbox = gtk.VBox() |
164 vbox.pack_start(self._prompt_label, False, False) | 158 vbox.pack_start(self._prompt_label, False, False) |
165 | 159 |
166 for name, cb_fun in _PATTERN_LIST: | 160 for name, cb_fun in _PATTERN_LIST: |
167 label_box = self.make_pattern_label_box(name) | 161 label_box = self.make_pattern_label_box(name) |
168 vbox.pack_start(label_box, False, False) | 162 vbox.pack_start(label_box, False, False) |
169 | 163 |
170 test_widget = gtk.EventBox() | 164 test_widget = gtk.EventBox() |
171 test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) | 165 test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
172 test_widget.add(vbox) | 166 test_widget.add(vbox) |
173 self._test_widget = test_widget | 167 self._test_widget = test_widget |
174 | 168 |
175 self.goto_next_pattern() | 169 self.goto_next_pattern() |
176 | 170 |
177 self._fs_window = None | 171 self._fs_window = None |
178 | 172 |
179 self._ft_state.run_test_widget( | 173 ful.run_test_widget(self.job, test_widget, |
180 test_widget=test_widget, | |
181 test_widget_size=test_widget_size, | |
182 window_registration_callback=self.register_callbacks) | 174 window_registration_callback=self.register_callbacks) |
183 | 175 |
184 failed_set = set(name for name, status in self._status_map.items() | 176 failed_set = set(name for name, status in self._status_map.items() |
185 if status is not ful.PASSED) | 177 if status is not ful.PASSED) |
186 if failed_set: | 178 if failed_set: |
187 raise error.TestFail('some patterns failed\n' \ | 179 raise error.TestFail('some patterns failed\n' \ |
188 '以下圖樣測試未通過: %s' % | 180 '以下圖樣測試未通過: %s' % |
189 ', '.join(failed_set)) | 181 ', '.join(failed_set)) |
190 | 182 |
191 factory.log('%s run_once finished' % self.__class__) | 183 factory.log('%s run_once finished' % self.__class__) |
OLD | NEW |