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

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])
achuithb 2014/01/15 01:46:59 How does this work? 2 %s and only 1 item?
michaelpg 2014/01/15 02:21:55 Each item is a (key, value) pair. I could write th
achuithb 2014/01/15 19:52:11 That may be clearer, or maybe just add a comment s
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/*'])
achuithb 2014/01/15 01:46:59 Which files do we really need to remove? Should we
michaelpg 2014/01/15 02:21:55 'Local State' and .oobe_completed must be removed.
achuithb 2014/01/15 19:52:11 I think that may be best? Just remove the 2 files
michaelpg 2014/01/17 20:35:12 Done.
175 self._cri.RunCmdOnDevice(['dump_vpd_log', '--force'])
176
177 self._cri.RunCmdOnDevice(['start', 'ui'])
178
179 def _OobeHasOption(self, browser, select, value):
180 # JavaScript to check that the option is present and selected.
181 js = '''
achuithb 2014/01/15 01:46:59 Let's add a comment explaining what the js is doin
michaelpg 2014/01/15 02:21:55 Done.
182 (function hasOption(select, value, isDefault) {
183 var options = document.getElementById(select).options;
184 for (var i = 0; i < options.length; i++) {
185 if (options[i].value == value)
186 return !isDefault || options.selectedIndex == i;
187 }
188 return false;
189 })("%s", "%s", %s);
achuithb 2014/01/15 01:46:59 Any way we can be consistent with using " or not?
michaelpg 2014/01/15 02:21:55 The JS function takes two strings and one boolean
190 '''
191 self.assertTrue(browser.oobe.EvaluateJavaScript(
achuithb 2014/01/15 01:46:59 Let's just return true/false from this function an
michaelpg 2014/01/15 02:21:55 Done.
192 js % (select, value, "true")))
193
194 def testOobeLocalization(self):
195 """Tests different region configurations at OOBE"""
196 # Save the original device localization settings.
197 initial_region = self.Region('', '', '', '', '')
198 for key in initial_region.__dict__.keys():
199 initial_region.__dict__[key], _ = self._cri.RunCmdOnDevice(
200 ['vpd', '-g', key])
201
202 for region in self.REGIONS_LIST:
203 self._SwitchRegion(region)
204 with self._CreateBrowser(auto_login=False) as browser:
205 # Ensure the dropdown lists have been created.
206 util.WaitFor(lambda: browser.oobe.EvaluateJavaScript(
207 "document.getElementById('language-select') != null"),
208 10)
209
210 self._OobeHasOption(browser, 'language-select', region.initial_locale)
211 self._OobeHasOption(browser, 'keyboard-select', region.keyboard_layout)
212
213 # Test is finished. Restore original region settings.
214 self._SwitchRegion(initial_region)
215
216 class Region(object):
217 def __init__(self, region_code, keyboard, time_zone, language_code,
218 keyboard_mechanical_layout):
achuithb 2014/01/15 01:46:59 Are we not using keyboard_mechnical_layout?
michaelpg 2014/01/15 02:21:55 Nope, it's there but doesn't seem to be used outsi
achuithb 2014/01/15 19:52:11 Maybe we can just save it in the object in case we
michaelpg 2014/01/17 20:35:12 Done.
219 self.region = region_code
220 self.keyboard_layout = keyboard
221 self.initial_timezone = time_zone
222 self.initial_locale = language_code
223
224 REGIONS_LIST = [
225 Region('fr', 'xkb:fr::fra', 'Europe/Paris', 'fr', 'kml'),
226 Region('de', 'xkb:de::ger', 'Europe/Berlin', 'de', 'kml'),
227 Region('nl', 'xkb:us:intl:eng', 'Europe/Amsterdam', 'nl', 'kml_ansi'),
228 Region('ie', 'xkb:gb:extd:eng', 'Europe/Dublin', 'en-GB', 'kml'),
229 Region('se', 'xkb:se::swe', 'Europe/Stockholm', 'sv', 'kml'),
230 Region('fi', 'xkb:fi::fin', 'Europe/Helsinki', 'fi', 'kml'),
231 Region('my', 'xkb:us::eng', 'Asia/Kuala_Lumpur', 'ms', 'kml_ansi'),
232 Region('sg', 'xkb:us::eng', 'Asia/Singapore', 'en-GB', 'kml_ansi'),
233 Region('nordic', 'xkb:se::swe', 'Europe/Stockholm', 'en-US', 'kml'),
234 Region('in', 'xkb:us::eng', 'Asia/Calcutta', 'en-US', 'kml_ansi'),
235 Region('es', 'xkb:es::spa', 'Europe/Madrid', 'es', 'kml'),
236 Region('it', 'xkb:it::ita', 'Europe/Rome', 'it', 'kml'),
237 Region('jp', 'xkb:jp::jpn', 'Asia/Tokyo', 'ja', 'kml_jis'),
238 Region('ch', 'xkb:ch::ger', 'Europe/Zurich', 'en-US', 'kml'),
239 ]
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