summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authordtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 23:54:48 +0000
committerdtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 23:54:48 +0000
commitc5398d3db4c26fa00494ac223fb424c9b66b97fa (patch)
tree89fac63a8759a91fe0ba3e5ed71d2f9c2761397c /chrome/test
parentae9f26cada993a1f38878e0194de6d9925c0249f (diff)
downloadchromium_src-c5398d3db4c26fa00494ac223fb424c9b66b97fa.zip
chromium_src-c5398d3db4c26fa00494ac223fb424c9b66b97fa.tar.gz
chromium_src-c5398d3db4c26fa00494ac223fb424c9b66b97fa.tar.bz2
GetTimeInfo() returns the display time, date, and time zone.
SetTimezone() sets the user's time zone. Also modifies the PyAuto function matching behavior. You can now specify two handlers for a PyAuto JSON call, one that takes a Browser and one that does not. BUG=chromium-os:18031 TEST=This is a test. Run python chromeos_time.py Review URL: http://codereview.chromium.org/7520019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/functional/PYAUTO_TESTS5
-rw-r--r--chrome/test/functional/chromeos_time.py38
-rw-r--r--chrome/test/pyautolib/pyauto.py43
3 files changed, 82 insertions, 4 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS
index 8eac082..ec25dc4d 100644
--- a/chrome/test/functional/PYAUTO_TESTS
+++ b/chrome/test/functional/PYAUTO_TESTS
@@ -253,12 +253,13 @@
# primary chrome on ChromeOS.
'chromeos': [
'chromeos_basic',
+ 'chromeos_firmware_version_checker',
'chromeos_power',
+ 'chromeos_prefs',
'chromeos_security',
+ 'chromeos_time',
'chromeos_update',
'chromeos_wifi_sanity',
- 'chromeos_firmware_version_checker',
- 'chromeos_prefs',
# ===========================
# Permanently-disabled tests.
diff --git a/chrome/test/functional/chromeos_time.py b/chrome/test/functional/chromeos_time.py
new file mode 100644
index 0000000..c5b7d56
--- /dev/null
+++ b/chrome/test/functional/chromeos_time.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+
+import pyauto_functional # Must be imported before pyauto
+import pyauto
+
+class ChromeosTime(pyauto.PyUITest):
+ """Tests for the ChromeOS status area clock and timezone settings."""
+
+ def setUp(self):
+ pyauto.PyUITest.setUp(self)
+ self._initial_timezone = self.GetTimeInfo()['timezone']
+
+ def tearDown(self):
+ self.SetTimezone(self._initial_timezone)
+ pyauto.PyUITest.tearDown(self)
+
+ def testTimeInfo(self):
+ """Print the the display time, date, and timezone."""
+ logging.debug(self.GetTimeInfo())
+
+ def testSetTimezone(self):
+ """Sanity test to make sure setting the timezone works."""
+ self.SetTimezone('America/Los_Angeles')
+ pacific_time = self.GetTimeInfo()['display_time']
+ self.SetTimezone('America/New_York')
+ eastern_time = self.GetTimeInfo()['display_time']
+
+ self.assertNotEqual(pacific_time, eastern_time,
+ 'Time zone changed but display time did not.')
+
+
+if __name__ == '__main__':
+ pyauto_functional.Main()
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index ec3be84..282b998 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -3490,11 +3490,50 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Raises:
pyauto_errors.JSONInterfaceError if the fetch fails.
"""
+ cmd_dict = { 'command': 'FetchEnterprisePolicy' }
+ self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+ return self.GetEnterprisePolicyInfo()
+
+ def GetTimeInfo(self, windex=0):
+ """Gets info about the ChromeOS status bar clock.
+
+ Set the 24-hour clock by using:
+ self.SetPrefs('settings.clock.use_24hour_clock', True)
+
+ Returns:
+ a dictionary.
+ Sample:
+ {u'display_date': u'Tuesday, July 26, 2011',
+ u'display_time': u'4:30',
+ u'timezone': u'America/Los_Angeles'}
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = { 'command': 'GetTimeInfo' }
+ if self.GetLoginInfo()['is_logged_in']:
+ return self._GetResultFromJSONRequest(cmd_dict, windex=windex)
+ else:
+ return self._GetResultFromJSONRequest(cmd_dict, windex=-1)
+
+ def SetTimezone(self, timezone):
+ """Sets the timezone on ChromeOS. A user must be logged in.
+
+ The timezone is the relative path to the timezone file in
+ /usr/share/zoneinfo. For example, /usr/share/zoneinfo/America/Los_Angeles
+ is 'America/Los_Angeles'.
+
+ This method does not return indication of success or failure.
+ If the timezone is invalid, it falls back to UTC/GMT.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
cmd_dict = {
- 'command': 'FetchEnterprisePolicy',
+ 'command': 'SetTimezone',
+ 'timezone': timezone,
}
self._GetResultFromJSONRequest(cmd_dict, windex=-1)
- return self.GetEnterprisePolicyInfo()
def EnrollEnterpriseDevice(self, user, password):
"""Enrolls an unenrolled device as an enterprise device.