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

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

Issue 8890026: Allow chromedriver to set local state preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 One of the equivalent names in chrome/common/pref_names.h could 1164 One of the equivalent names in chrome/common/pref_names.h could
1165 also be used. 1165 also be used.
1166 value: the value to be set. It could be plain values like int, bool, 1166 value: the value to be set. It could be plain values like int, bool,
1167 string or complex ones like list. 1167 string or complex ones like list.
1168 The user has to ensure that the right value is specified for the 1168 The user has to ensure that the right value is specified for the
1169 right key. It's useful to dump the preferences first to determine 1169 right key. It's useful to dump the preferences first to determine
1170 what type is expected for a particular preference path. 1170 what type is expected for a particular preference path.
1171 """ 1171 """
1172 cmd_dict = { 1172 cmd_dict = {
1173 'command': 'SetLocalStatePrefs', 1173 'command': 'SetLocalStatePrefs',
1174 'windex': 0,
1174 'path': path, 1175 'path': path,
1175 'value': value, 1176 'value': value,
1176 } 1177 }
1177 self._GetResultFromJSONRequest(cmd_dict) 1178 self._GetResultFromJSONRequest(cmd_dict, windex=-1)
1178 1179
1179 def GetPrefsInfo(self): 1180 def GetPrefsInfo(self):
1180 """Return info about preferences. 1181 """Return info about preferences.
1181 1182
1182 This represents a snapshot of the preferences. If you expect preferences 1183 This represents a snapshot of the preferences. If you expect preferences
1183 to have changed, you need to call this method again to get a fresh 1184 to have changed, you need to call this method again to get a fresh
1184 snapshot. 1185 snapshot.
1185 1186
1186 Returns: 1187 Returns:
1187 an instance of prefs_info.PrefsInfo 1188 an instance of prefs_info.PrefsInfo
1188 """ 1189 """
1190 cmd_dict = {
1191 'command': 'GetPrefsInfo',
1192 'windex': 0,
1193 }
1189 return prefs_info.PrefsInfo( 1194 return prefs_info.PrefsInfo(
1190 self._SendJSONRequest(0, json.dumps({'command': 'GetPrefsInfo'}), 1195 self._SendJSONRequest(-1, json.dumps(cmd_dict),
1191 self.action_max_timeout_ms())) 1196 self.action_max_timeout_ms()))
1192 1197
1193 def SetPrefs(self, path, value): 1198 def SetPrefs(self, path, value):
1194 """Set preference for the given path. 1199 """Set preference for the given path.
1195 1200
1196 Preferences are stored by Chromium as a hierarchical dictionary. 1201 Preferences are stored by Chromium as a hierarchical dictionary.
1197 dot-separated paths can be used to refer to a particular preference. 1202 dot-separated paths can be used to refer to a particular preference.
1198 example: "session.restore_on_startup" 1203 example: "session.restore_on_startup"
1199 1204
1200 Some preferences are managed, that is, they cannot be changed by the 1205 Some preferences are managed, that is, they cannot be changed by the
1201 user. It's up to the user to know which ones can be changed. Typically, 1206 user. It's up to the user to know which ones can be changed. Typically,
1202 the options available via Chromium preferences can be changed. 1207 the options available via Chromium preferences can be changed.
1203 1208
1204 Args: 1209 Args:
1205 path: the path the preference key that needs to be changed 1210 path: the path the preference key that needs to be changed
1206 example: "session.restore_on_startup" 1211 example: "session.restore_on_startup"
1207 One of the equivalent names in chrome/common/pref_names.h could 1212 One of the equivalent names in chrome/common/pref_names.h could
1208 also be used. 1213 also be used.
1209 value: the value to be set. It could be plain values like int, bool, 1214 value: the value to be set. It could be plain values like int, bool,
1210 string or complex ones like list. 1215 string or complex ones like list.
1211 The user has to ensure that the right value is specified for the 1216 The user has to ensure that the right value is specified for the
1212 right key. It's useful to dump the preferences first to determine 1217 right key. It's useful to dump the preferences first to determine
1213 what type is expected for a particular preference path. 1218 what type is expected for a particular preference path.
1214 """ 1219 """
1215 cmd_dict = { 1220 cmd_dict = {
1216 'command': 'SetPrefs', 1221 'command': 'SetPrefs',
1222 'windex': 0,
1217 'path': path, 1223 'path': path,
1218 'value': value, 1224 'value': value,
1219 } 1225 }
1220 self._GetResultFromJSONRequest(cmd_dict) 1226 self._GetResultFromJSONRequest(cmd_dict, windex=-1)
1221 1227
1222 def SendWebkitKeyEvent(self, key_type, key_code, tab_index=0, windex=0): 1228 def SendWebkitKeyEvent(self, key_type, key_code, tab_index=0, windex=0):
1223 """Send a webkit key event to the browser. 1229 """Send a webkit key event to the browser.
1224 1230
1225 Args: 1231 Args:
1226 key_type: the raw key type such as 0 for up and 3 for down. 1232 key_type: the raw key type such as 0 for up and 3 for down.
1227 key_code: the hex value associated with the keypress (virtual key code). 1233 key_code: the hex value associated with the keypress (virtual key code).
1228 tab_index: tab index to work on. Defaults to 0 (first tab). 1234 tab_index: tab index to work on. Defaults to 0 (first tab).
1229 windex: window index to work on. Defaults to 0 (first window). 1235 windex: window index to work on. Defaults to 0 (first window).
1230 """ 1236 """
(...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4843 successful = result.wasSuccessful() 4849 successful = result.wasSuccessful()
4844 if not successful: 4850 if not successful:
4845 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 4851 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
4846 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 4852 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
4847 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 4853 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
4848 sys.exit(not successful) 4854 sys.exit(not successful)
4849 4855
4850 4856
4851 if __name__ == '__main__': 4857 if __name__ == '__main__':
4852 Main() 4858 Main()
OLDNEW
« no previous file with comments | « chrome/test/pyautolib/chrome_driver_factory.py ('k') | chrome/test/webdriver/commands/create_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698