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 test looks in "/dev/video0" for a v4l2 video capture device, | 10 # This test looks in "/dev/video0" for a v4l2 video capture device, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 self.ledfail = True | 99 self.ledfail = True |
100 self.ledstats >>= 1 | 100 self.ledstats >>= 1 |
101 if self.stage == self.led_rounds: | 101 if self.stage == self.led_rounds: |
102 self.fail = False | 102 self.fail = False |
103 gtk.main_quit() | 103 gtk.main_quit() |
104 self.stage += 1 | 104 self.stage += 1 |
105 if self.ledstats & 1: | 105 if self.ledstats & 1: |
106 self.dev.capture_mmap_start() | 106 self.dev.capture_mmap_start() |
107 self.label.hide() | 107 self.label.hide() |
108 glib.timeout_add(1000, lambda *x: self.label.show()) | 108 glib.timeout_add(1000, lambda *x: self.label.show()) |
109 | 109 return True |
110 self.ft_state.exit_on_trigger(event) | |
111 return | |
112 | 110 |
113 def register_callbacks(self, w): | 111 def register_callbacks(self, w): |
114 w.connect('key-release-event', self.key_release_callback) | 112 w.connect('key-release-event', self.key_release_callback) |
115 w.add_events(gdk.KEY_RELEASE_MASK) | 113 w.add_events(gdk.KEY_RELEASE_MASK) |
116 | 114 |
117 def run_once(self, test_widget_size=None, trigger_set=None, led_rounds=5): | 115 def run_once(self, |
| 116 led_rounds=5): |
118 '''Run the camera test | 117 '''Run the camera test |
119 | 118 |
120 Parameter | 119 Parameter |
121 led_rounds: 0 to disable the LED test, | 120 led_rounds: 0 to disable the LED test, |
122 1 to check if the LED turns on, | 121 1 to check if the LED turns on, |
123 2 or higher to have multiple random turn on/off | 122 2 or higher to have multiple random turn on/off |
124 (at least one on round and one off round is guranteed) | 123 (at least one on round and one off round is guranteed) |
125 ''' | 124 ''' |
126 factory.log('%s run_once' % self.__class__) | 125 factory.log('%s run_once' % self.__class__) |
127 | 126 |
128 self.fail = True | 127 self.fail = True |
129 self.ledfail = False | 128 self.ledfail = False |
130 self.led_rounds = led_rounds | 129 self.led_rounds = led_rounds |
131 self.ledstats = 0 | 130 self.ledstats = 0 |
132 if led_rounds == 1: | 131 if led_rounds == 1: |
133 # always on if only one round | 132 # always on if only one round |
134 self.ledstats = 1 | 133 self.ledstats = 1 |
135 elif led_rounds > 1: | 134 elif led_rounds > 1: |
136 # ensure one on round and one off round | 135 # ensure one on round and one off round |
137 self.ledstats = randrange(2 ** led_rounds - 2) + 1 | 136 self.ledstats = randrange(2 ** led_rounds - 2) + 1 |
138 self.stage = 0 | 137 self.stage = 0 |
139 | 138 |
140 self.ft_state = ful.State(trigger_set) | |
141 | |
142 self.label = label = gtk.Label(MESSAGE_STR) | 139 self.label = label = gtk.Label(MESSAGE_STR) |
143 label.modify_font(LABEL_FONT) | 140 label.modify_font(LABEL_FONT) |
144 label.modify_fg(gtk.STATE_NORMAL, gdk.color_parse('light green')) | 141 label.modify_fg(gtk.STATE_NORMAL, gdk.color_parse('light green')) |
145 | 142 |
146 test_widget = gtk.VBox() | 143 test_widget = gtk.VBox() |
147 test_widget.modify_bg(gtk.STATE_NORMAL, gdk.color_parse('black')) | 144 test_widget.modify_bg(gtk.STATE_NORMAL, gdk.color_parse('black')) |
148 test_widget.add(label) | 145 test_widget.add(label) |
149 self.test_widget = test_widget | 146 self.test_widget = test_widget |
150 | 147 |
151 self.img = None | 148 self.img = None |
(...skipping 19 matching lines...) Expand all Loading... |
171 self.pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, | 168 self.pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, |
172 width, height) | 169 width, height) |
173 self.pixels = self.pixbuf.get_pixels_array() | 170 self.pixels = self.pixbuf.get_pixels_array() |
174 self.img = gtk.image_new_from_pixbuf(self.pixbuf) | 171 self.img = gtk.image_new_from_pixbuf(self.pixbuf) |
175 self.test_widget.add(self.img) | 172 self.test_widget.add(self.img) |
176 self.img.show() | 173 self.img.show() |
177 | 174 |
178 dev.capture_mmap_prepare(PREFERRED_BUFFER_COUNT, 2) | 175 dev.capture_mmap_prepare(PREFERRED_BUFFER_COUNT, 2) |
179 dev.capture_mmap_start() | 176 dev.capture_mmap_start() |
180 | 177 |
181 self.ft_state.run_test_widget( | 178 ful.run_test_widget(self.job, test_widget, |
182 test_widget=test_widget, | |
183 test_widget_size=test_widget_size, | |
184 window_registration_callback=self.register_callbacks) | 179 window_registration_callback=self.register_callbacks) |
185 | 180 |
186 # we don't call capture_mmap_stop here, | 181 # we don't call capture_mmap_stop here, |
187 # it will be called before returning from main loop. | 182 # it will be called before returning from main loop. |
188 dev.capture_mmap_finish() | 183 dev.capture_mmap_finish() |
189 | 184 |
190 if self.fail: | 185 if self.fail: |
191 raise error.TestFail('Camera test failed by user indication\n' \ | 186 raise error.TestFail('Camera test failed by user indication\n' \ |
192 '品管人員懷疑攝影鏡頭故障,請檢修') | 187 '品管人員懷疑攝影鏡頭故障,請檢修') |
193 if self.ledfail: | 188 if self.ledfail: |
194 raise error.TestFail('Camera LED test failed\n' \ | 189 raise error.TestFail('Camera LED test failed\n' \ |
195 '攝影鏡頭 LED 測試不通過,請檢修') | 190 '攝影鏡頭 LED 測試不通過,請檢修') |
196 | 191 |
197 factory.log('%s run_once finished' % self.__class__) | 192 factory.log('%s run_once finished' % self.__class__) |
OLD | NEW |