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

Side by Side Diff: chrome/test/telemetry/chromeos/login_unittest.py

Issue 137783008: testOobeLocalization implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium 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 import json 4 import json
5 import logging 5 import logging
6 import os 6 import os
7 import unittest 7 import unittest
8 8
9 from telemetry.core import browser_finder 9 from telemetry.core import browser_finder
10 from telemetry.core import exceptions 10 from telemetry.core import exceptions
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 util.WaitFor(lambda: not browser.oobe, 10) 145 util.WaitFor(lambda: not browser.oobe, 10)
146 self.assertFalse(self._IsScreenLocked(browser)) 146 self.assertFalse(self._IsScreenLocked(browser))
147 147
148 def testScreenLock(self): 148 def testScreenLock(self):
149 """Tests autotestPrivate.screenLock""" 149 """Tests autotestPrivate.screenLock"""
150 with self._CreateBrowser(autotest_ext=True) as browser: 150 with self._CreateBrowser(autotest_ext=True) as browser:
151 self._LockScreen(browser) 151 self._LockScreen(browser)
152 self._AttemptUnlockBadPassword(browser) 152 self._AttemptUnlockBadPassword(browser)
153 self._UnlockScreen(browser) 153 self._UnlockScreen(browser)
154 154
155
156 def testLogout(self): 155 def testLogout(self):
157 """Tests autotestPrivate.logout""" 156 """Tests autotestPrivate.logout"""
158 with self._CreateBrowser(autotest_ext=True) as b: 157 with self._CreateBrowser(autotest_ext=True) as b:
159 extension = self._GetAutotestExtension(b) 158 extension = self._GetAutotestExtension(b)
160 try: 159 try:
161 extension.ExecuteJavaScript('chrome.autotestPrivate.logout();') 160 extension.ExecuteJavaScript('chrome.autotestPrivate.logout();')
162 except (exceptions.BrowserConnectionGoneException, 161 except (exceptions.BrowserConnectionGoneException,
163 exceptions.BrowserGoneException): 162 exceptions.BrowserGoneException):
164 pass 163 pass
165 util.WaitFor(lambda: not self._IsCryptohomeMounted(), 20) 164 util.WaitFor(lambda: not self._IsCryptohomeMounted(), 20)
165
166 def _SwitchRegion(self, region):
167 # Overwrite VPD settings (requires RW-enabled firmware).
168 for item in region.__dict__.items():
169 self._cri.RunCmdOnDevice(['vpd', '-s', '"%s"="%s"' % item])
170
171 self._cri.RunCmdOnDevice(['stop', 'ui'])
172
173 # Remove cached files to clear initial locale info and force regeneration.
174 self._cri.RunCmdOnDevice(['rm', '-rf', '/home/chronos/*'])
175 self._cri.RunCmdOnDevice(['dump_vpd_log', '--force'])
176
177 self._cri.RunCmdOnDevice(['start', 'ui'])
178
179 def _OobeHasOption(self, browser, selectId, value):
180 hasOptionJs = '''
181 // Check that the option is present, and selected if it is the default.
182 (function hasOption(selectId, value, isDefault) {
183 var options = document.getElementById(selectId).options;
184 for (var i = 0; i < options.length; i++) {
185 if (options[i].value == value) {
186 // The option is present. Make sure it's selected if necessary.
187 return !isDefault || options.selectedIndex == i;
188 }
189 }
190 return false;
191 })("%s", "%s", %s);
192 '''
193 return browser.oobe.EvaluateJavaScript(
194 hasOptionJs % (selectId, value, "true"))
195
196 def testOobeLocalization(self):
197 """Tests different region configurations at OOBE"""
198 # Save the original device localization settings.
199 initial_region = self.Region('', '', '', '', '')
200 for key in initial_region.__dict__.keys():
201 initial_region.__dict__[key], _ = self._cri.RunCmdOnDevice(
202 ['vpd', '-g', key])
203
204 for region in self.REGIONS_LIST:
205 self._SwitchRegion(region)
206 with self._CreateBrowser(auto_login=False) as browser:
207 # Ensure the dropdown lists have been created.
208 util.WaitFor(lambda: browser.oobe.EvaluateJavaScript(
209 "document.getElementById('language-select') != null"),
210 10)
211
212 self.assertTrue(self._OobeHasOption(
213 browser, 'language-select', region.initial_locale))
214 self.assertTrue(self._OobeHasOption(
215 browser, 'keyboard-select', region.keyboard_layout))
michaelpg 2014/01/15 02:21:55 How does this indentation look?
achuithb 2014/01/15 19:52:11 Technically I believe self._OobeHasOption should b
216
217 # Test is finished. Restore original region settings.
218 self._SwitchRegion(initial_region)
219
220 class Region(object):
221 def __init__(self, region_code, keyboard, time_zone, language_code,
222 keyboard_mechanical_layout):
223 self.region = region_code
224 self.keyboard_layout = keyboard
225 self.initial_timezone = time_zone
226 self.initial_locale = language_code
227
228 REGIONS_LIST = [
229 Region('fr', 'xkb:fr::fra', 'Europe/Paris', 'fr', 'kml'),
230 Region('de', 'xkb:de::ger', 'Europe/Berlin', 'de', 'kml'),
231 Region('nl', 'xkb:us:intl:eng', 'Europe/Amsterdam', 'nl', 'kml_ansi'),
232 Region('ie', 'xkb:gb:extd:eng', 'Europe/Dublin', 'en-GB', 'kml'),
233 Region('se', 'xkb:se::swe', 'Europe/Stockholm', 'sv', 'kml'),
234 Region('fi', 'xkb:fi::fin', 'Europe/Helsinki', 'fi', 'kml'),
235 Region('my', 'xkb:us::eng', 'Asia/Kuala_Lumpur', 'ms', 'kml_ansi'),
236 Region('sg', 'xkb:us::eng', 'Asia/Singapore', 'en-GB', 'kml_ansi'),
237 Region('nordic', 'xkb:se::swe', 'Europe/Stockholm', 'en-US', 'kml'),
238 Region('in', 'xkb:us::eng', 'Asia/Calcutta', 'en-US', 'kml_ansi'),
239 Region('es', 'xkb:es::spa', 'Europe/Madrid', 'es', 'kml'),
240 Region('it', 'xkb:it::ita', 'Europe/Rome', 'it', 'kml'),
241 Region('jp', 'xkb:jp::jpn', 'Asia/Tokyo', 'ja', 'kml_jis'),
242 Region('ch', 'xkb:ch::ger', 'Europe/Zurich', 'en-US', 'kml'),
243 ]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698