Chromium Code Reviews| Index: chrome/test/telemetry/chromeos/login_unittest.py |
| diff --git a/chrome/test/telemetry/chromeos/login_unittest.py b/chrome/test/telemetry/chromeos/login_unittest.py |
| index 7675e95dbf72118c523e0b0e885f9239fd1dd535..c6b24c56b5e378404d1e5985d2fbf25c28c13837 100644 |
| --- a/chrome/test/telemetry/chromeos/login_unittest.py |
| +++ b/chrome/test/telemetry/chromeos/login_unittest.py |
| @@ -152,7 +152,6 @@ class CrOSAutoTest(unittest.TestCase): |
| self._AttemptUnlockBadPassword(browser) |
| self._UnlockScreen(browser) |
| - |
| def testLogout(self): |
| """Tests autotestPrivate.logout""" |
| with self._CreateBrowser(autotest_ext=True) as b: |
| @@ -163,3 +162,78 @@ class CrOSAutoTest(unittest.TestCase): |
| exceptions.BrowserGoneException): |
| pass |
| util.WaitFor(lambda: not self._IsCryptohomeMounted(), 20) |
| + |
| + def _SwitchRegion(self, region): |
| + # Overwrite VPD settings (requires RW-enabled firmware). |
| + for item in region.__dict__.items(): |
| + 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
|
| + |
| + self._cri.RunCmdOnDevice(['stop', 'ui']) |
| + |
| + # Remove cached files to clear initial locale info and force regeneration. |
| + 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.
|
| + self._cri.RunCmdOnDevice(['dump_vpd_log', '--force']) |
| + |
| + self._cri.RunCmdOnDevice(['start', 'ui']) |
| + |
| + def _OobeHasOption(self, browser, select, value): |
| + # JavaScript to check that the option is present and selected. |
| + 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.
|
| + (function hasOption(select, value, isDefault) { |
| + var options = document.getElementById(select).options; |
| + for (var i = 0; i < options.length; i++) { |
| + if (options[i].value == value) |
| + return !isDefault || options.selectedIndex == i; |
| + } |
| + return false; |
| + })("%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
|
| + ''' |
| + 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.
|
| + js % (select, value, "true"))) |
| + |
| + def testOobeLocalization(self): |
| + """Tests different region configurations at OOBE""" |
| + # Save the original device localization settings. |
| + initial_region = self.Region('', '', '', '', '') |
| + for key in initial_region.__dict__.keys(): |
| + initial_region.__dict__[key], _ = self._cri.RunCmdOnDevice( |
| + ['vpd', '-g', key]) |
| + |
| + for region in self.REGIONS_LIST: |
| + self._SwitchRegion(region) |
| + with self._CreateBrowser(auto_login=False) as browser: |
| + # Ensure the dropdown lists have been created. |
| + util.WaitFor(lambda: browser.oobe.EvaluateJavaScript( |
| + "document.getElementById('language-select') != null"), |
| + 10) |
| + |
| + self._OobeHasOption(browser, 'language-select', region.initial_locale) |
| + self._OobeHasOption(browser, 'keyboard-select', region.keyboard_layout) |
| + |
| + # Test is finished. Restore original region settings. |
| + self._SwitchRegion(initial_region) |
| + |
| + class Region(object): |
| + def __init__(self, region_code, keyboard, time_zone, language_code, |
| + 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.
|
| + self.region = region_code |
| + self.keyboard_layout = keyboard |
| + self.initial_timezone = time_zone |
| + self.initial_locale = language_code |
| + |
| + REGIONS_LIST = [ |
| + Region('fr', 'xkb:fr::fra', 'Europe/Paris', 'fr', 'kml'), |
| + Region('de', 'xkb:de::ger', 'Europe/Berlin', 'de', 'kml'), |
| + Region('nl', 'xkb:us:intl:eng', 'Europe/Amsterdam', 'nl', 'kml_ansi'), |
| + Region('ie', 'xkb:gb:extd:eng', 'Europe/Dublin', 'en-GB', 'kml'), |
| + Region('se', 'xkb:se::swe', 'Europe/Stockholm', 'sv', 'kml'), |
| + Region('fi', 'xkb:fi::fin', 'Europe/Helsinki', 'fi', 'kml'), |
| + Region('my', 'xkb:us::eng', 'Asia/Kuala_Lumpur', 'ms', 'kml_ansi'), |
| + Region('sg', 'xkb:us::eng', 'Asia/Singapore', 'en-GB', 'kml_ansi'), |
| + Region('nordic', 'xkb:se::swe', 'Europe/Stockholm', 'en-US', 'kml'), |
| + Region('in', 'xkb:us::eng', 'Asia/Calcutta', 'en-US', 'kml_ansi'), |
| + Region('es', 'xkb:es::spa', 'Europe/Madrid', 'es', 'kml'), |
| + Region('it', 'xkb:it::ita', 'Europe/Rome', 'it', 'kml'), |
| + Region('jp', 'xkb:jp::jpn', 'Asia/Tokyo', 'ja', 'kml_jis'), |
| + Region('ch', 'xkb:ch::ger', 'Europe/Zurich', 'en-US', 'kml'), |
| + ] |