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

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 10827050: Added a timezone policy and pyauto tests for it. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """PyAuto: Python Interface to Chromium's Automation Proxy. 6 """PyAuto: Python Interface to Chromium's Automation Proxy.
7 7
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. 8 PyAuto uses swig to expose Automation Proxy interfaces to Python.
9 For complete documentation on the functionality available, 9 For complete documentation on the functionality available,
10 run pydoc on this file. 10 run pydoc on this file.
(...skipping 5388 matching lines...) Expand 10 before | Expand all | Expand 10 after
5399 cmd_dict = { 'command': 'GetTimeInfo' } 5399 cmd_dict = { 'command': 'GetTimeInfo' }
5400 if self.GetLoginInfo()['is_logged_in']: 5400 if self.GetLoginInfo()['is_logged_in']:
5401 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) 5401 return self._GetResultFromJSONRequest(cmd_dict, windex=windex)
5402 else: 5402 else:
5403 return self._GetResultFromJSONRequest(cmd_dict, windex=None) 5403 return self._GetResultFromJSONRequest(cmd_dict, windex=None)
5404 5404
5405 def SetTimezone(self, timezone): 5405 def SetTimezone(self, timezone):
5406 """Sets the timezone on ChromeOS. A user must be logged in. 5406 """Sets the timezone on ChromeOS. A user must be logged in.
5407 5407
5408 The timezone is the relative path to the timezone file in 5408 The timezone is the relative path to the timezone file in
5409 /usr/share/zoneinfo. For example, /usr/share/zoneinfo/America/Los_Angeles 5409 /usr/share/zoneinfo. For example, /usr/share/zoneinfo/America/Los_Angeles is
5410 is 'America/Los_Angeles'. 5410 'America/Los_Angeles'. For a list of valid timezones see
5411 'chrome/browser/chromeos/system/timezone_settings.cc'.
5411 5412
5412 This method does not return indication of success or failure. 5413 This method does not return indication of success or failure.
5413 If the timezone is invalid, it falls back to UTC/GMT. 5414 If the timezone is it falls back to a valid timezone.
5414 5415
5415 Raises: 5416 Raises:
5416 pyauto_errors.JSONInterfaceError if the automation call returns an error. 5417 pyauto_errors.JSONInterfaceError if the automation call returns an error.
5417 """ 5418 """
5418 cmd_dict = { 5419 cmd_dict = {
5419 'command': 'SetTimezone', 5420 'command': 'SetTimezone',
5420 'timezone': timezone, 5421 'timezone': timezone,
5421 } 5422 }
5422 self._GetResultFromJSONRequest(cmd_dict, windex=None) 5423 self._GetResultFromJSONRequest(cmd_dict, windex=None)
5423 5424
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
5612 A user needs to be logged-in as a precondition. Note that the UI is not 5613 A user needs to be logged-in as a precondition. Note that the UI is not
5613 destroyed afterwards, a browser restart is necessary if you want 5614 destroyed afterwards, a browser restart is necessary if you want
5614 to interact with the browser after this call in the same test case. 5615 to interact with the browser after this call in the same test case.
5615 5616
5616 Raises: 5617 Raises:
5617 pyauto_errors.JSONInterfaceError if the automation call returns an error. 5618 pyauto_errors.JSONInterfaceError if the automation call returns an error.
5618 """ 5619 """
5619 cmd_dict = { 'command': 'CaptureProfilePhoto' } 5620 cmd_dict = { 'command': 'CaptureProfilePhoto' }
5620 return self._GetResultFromJSONRequest(cmd_dict) 5621 return self._GetResultFromJSONRequest(cmd_dict)
5621 5622
5623 def SetCrosSetting(self, path, value):
5624 """Set CrosSetting for the given path to the given value.
5625
5626 CrosSettings are not handled by PrefService but by the class
5627 chromeos::CrosSettings. Therefore, we need this separate function besides
5628 SetPrefs.
5629
5630 Args:
5631 path: the path the preference key that needs to be changed
5632 example: "cros.system.timezone"
5633 value: the value to be set.
5634 """
5635 cmd_dict = {
5636 'command': 'SetCrosSetting',
5637 'path': path,
5638 'value': value,
5639 }
5640 self._GetResultFromJSONRequest(cmd_dict, windex=None)
5641
5622 def GetMemoryStatsChromeOS(self, duration): 5642 def GetMemoryStatsChromeOS(self, duration):
5623 """Identifies and returns different kinds of current memory usage stats. 5643 """Identifies and returns different kinds of current memory usage stats.
5624 5644
5625 This function samples values each second for |duration| seconds, then 5645 This function samples values each second for |duration| seconds, then
5626 outputs the min, max, and ending values for each measurement type. 5646 outputs the min, max, and ending values for each measurement type.
5627 5647
5628 Args: 5648 Args:
5629 duration: The number of seconds to sample data before outputting the 5649 duration: The number of seconds to sample data before outputting the
5630 minimum, maximum, and ending values for each measurement type. 5650 minimum, maximum, and ending values for each measurement type.
5631 5651
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 successful = result.wasSuccessful() 6379 successful = result.wasSuccessful()
6360 if not successful: 6380 if not successful:
6361 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6381 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6362 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6382 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6363 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6383 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6364 sys.exit(not successful) 6384 sys.exit(not successful)
6365 6385
6366 6386
6367 if __name__ == '__main__': 6387 if __name__ == '__main__':
6368 Main() 6388 Main()
OLDNEW
« chrome/test/functional/chromeos_time.py ('K') | « chrome/test/functional/policy_test_cases.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698