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 all keyboard | 10 # Intended for use during manufacturing to validate that all keyboard |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 def register_callbacks(self, window): | 121 def register_callbacks(self, window): |
122 window.connect('key-press-event', self.key_press_event) | 122 window.connect('key-press-event', self.key_press_event) |
123 window.connect('key-release-event', self.key_release_event) | 123 window.connect('key-release-event', self.key_release_event) |
124 window.add_events(gdk.KEY_PRESS_MASK | gdk.KEY_RELEASE_MASK) | 124 window.add_events(gdk.KEY_PRESS_MASK | gdk.KEY_RELEASE_MASK) |
125 | 125 |
126 | 126 |
127 class factory_Keyboard(test.test): | 127 class factory_Keyboard(test.test): |
128 version = 1 | 128 version = 1 |
129 preserve_srcdir = True | 129 preserve_srcdir = True |
130 | 130 |
131 def get_layout_from_vpd(self): | |
132 """ vpd should contain "initial_locale"="en-US" or similar. """ | |
133 cmd = 'vpd -l | grep initial_locale | cut -f4 -d\'"\'' | |
Hung-Te
2011/03/11 07:28:26
A little concern if some properties in VPD may als
| |
134 layout = utils.system_output(cmd).strip() | |
135 if layout != '': | |
136 return layout | |
137 return None | |
138 | |
131 def run_once(self, layout=None): | 139 def run_once(self, layout=None): |
132 | 140 |
133 factory.log('%s run_once' % self.__class__) | 141 factory.log('%s run_once' % self.__class__) |
134 | 142 |
135 os.chdir(self.srcdir) | 143 os.chdir(self.srcdir) |
136 | 144 |
145 # Autodetect from VPD. | |
146 if not layout: | |
147 layout = self.get_layout_from_vpd() | |
148 # Default to United States. | |
149 if not layout: | |
150 layout = 'en-US' | |
151 | |
137 try: | 152 try: |
138 kbd_image = cairo.ImageSurface.create_from_png('%s.png' % layout) | 153 kbd_image = cairo.ImageSurface.create_from_png('%s.png' % layout) |
139 image_size = (kbd_image.get_width(), kbd_image.get_height()) | 154 image_size = (kbd_image.get_width(), kbd_image.get_height()) |
140 except cairo.Error as e: | 155 except cairo.Error as e: |
141 raise error.TestNAError('Error while opening %s.png: %s' % | 156 raise error.TestNAError('Error while opening %s.png: %s' % |
142 (layout, e.message)) | 157 (layout, e.message)) |
143 | 158 |
144 try: | 159 try: |
145 with open('%s.bindings' % layout, 'r') as file: | 160 with open('%s.bindings' % layout, 'r') as file: |
146 bindings = eval(file.read()) | 161 bindings = eval(file.read()) |
(...skipping 17 matching lines...) Expand all Loading... | |
164 test_widget.pack_start(countdown_widget, False, False) | 179 test_widget.pack_start(countdown_widget, False, False) |
165 | 180 |
166 ful.run_test_widget(self.job, test_widget, | 181 ful.run_test_widget(self.job, test_widget, |
167 window_registration_callback=test.register_callbacks) | 182 window_registration_callback=test.register_callbacks) |
168 | 183 |
169 missing = test.calc_missing_string() | 184 missing = test.calc_missing_string() |
170 if missing: | 185 if missing: |
171 raise error.TestFail(missing) | 186 raise error.TestFail(missing) |
172 | 187 |
173 factory.log('%s run_once finished' % self.__class__) | 188 factory.log('%s run_once finished' % self.__class__) |
OLD | NEW |