summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib/pyauto.py
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/pyautolib/pyauto.py')
-rw-r--r--chrome/test/pyautolib/pyauto.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 4575a73..b00f071 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -74,6 +74,8 @@ except ImportError:
import bookmark_model
import download_info
import history_info
+import prefs_info
+from pyauto_errors import JSONInterfaceError
import simplejson as json # found in third_party
@@ -230,6 +232,50 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
return download_info.DownloadInfo(
self._SendJSONRequest(0, json.dumps({'command': 'GetDownloadsInfo'})))
+ def GetPrefsInfo(self):
+ """Return info about preferences.
+
+ This represents a snapshot of the preferences. If you expect preferences
+ to have changed, you need to call this method again to get a fresh
+ snapshot.
+
+ Returns:
+ an instance of prefs_info.PrefsInfo
+ """
+ return prefs_info.PrefsInfo(
+ self._SendJSONRequest(0, json.dumps({'command': 'GetPrefsInfo'})))
+
+ def SetPrefs(self, path, value):
+ """Set preference for the given path.
+
+ Preferences are stored by Chromium as a hierarchical dictionary.
+ dot-separated paths can be used to refer to a particular preference.
+ example: "session.restore_on_startup"
+
+ Some preferences are managed, that is, they cannot be changed by the
+ user. It's upto the user to know which ones can be changed. Typically,
+ the options available via Chromium preferences can be changed.
+
+ Args:
+ path: the path the preference key that needs to be changed
+ example: "session.restore_on_startup"
+ One of the equivalent names in chrome/common/pref_names.h could
+ also be used.
+ value: the value to be set. It could be plain values like int, bool,
+ string or complex ones like list.
+ The user has to ensure that the right value is specified for the
+ right key. It's useful to dump the preferences first to determine
+ what type is expected for a particular preference path.
+ """
+ cmd_dict = {
+ 'command': 'SetPrefs',
+ 'path': path,
+ 'value': value,
+ }
+ ret_dict = json.loads(self._SendJSONRequest(0, json.dumps(cmd_dict)))
+ if ret_dict.has_key('error'):
+ raise JSONInterfaceError(ret_dict['error'])
+
def WaitForAllDownloadsToComplete(self):
"""Wait for all downloads to complete."""
# Implementation detail: uses the generic "JSON command" model