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..b1a3498c0bdd0c15a300c043cc038d36a3204489 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,82 @@ 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]) |
| + |
| + self._cri.RunCmdOnDevice(['stop', 'ui']) |
| + |
| + # Remove cached files to clear initial locale info and force regeneration. |
| + self._cri.RunCmdOnDevice(['rm', '-rf', '/home/chronos/*']) |
| + self._cri.RunCmdOnDevice(['dump_vpd_log', '--force']) |
| + |
| + self._cri.RunCmdOnDevice(['start', 'ui']) |
| + |
| + def _OobeHasOption(self, browser, selectId, value): |
| + hasOptionJs = ''' |
| + // Check that the option is present, and selected if it is the default. |
| + (function hasOption(selectId, value, isDefault) { |
| + var options = document.getElementById(selectId).options; |
| + for (var i = 0; i < options.length; i++) { |
| + if (options[i].value == value) { |
| + // The option is present. Make sure it's selected if necessary. |
| + return !isDefault || options.selectedIndex == i; |
| + } |
| + } |
| + return false; |
| + })("%s", "%s", %s); |
| + ''' |
| + return browser.oobe.EvaluateJavaScript( |
| + hasOptionJs % (selectId, 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.assertTrue(self._OobeHasOption( |
| + browser, 'language-select', region.initial_locale)) |
| + self.assertTrue(self._OobeHasOption( |
| + 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
|
| + |
| + # 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): |
| + 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'), |
| + ] |