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

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

Issue 10238014: Fix search engine automation hooks to work with multiple profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 u'loading': True, 1195 u'loading': True,
1196 u'location': u'http://cnn.com/', 1196 u'location': u'http://cnn.com/',
1197 u'showing': False, 1197 u'showing': False,
1198 u'title': u'CNN.com - Breaking News'}, 1198 u'title': u'CNN.com - Breaking News'},
1199 1199
1200 { u'enabled': False } 1200 { u'enabled': False }
1201 """ 1201 """
1202 cmd_dict = {'command': 'GetInstantInfo'} 1202 cmd_dict = {'command': 'GetInstantInfo'}
1203 return self._GetResultFromJSONRequest(cmd_dict)['instant'] 1203 return self._GetResultFromJSONRequest(cmd_dict)['instant']
1204 1204
1205 def GetSearchEngineInfo(self): 1205 def GetSearchEngineInfo(self, windex=0):
1206 """Return info about search engines. 1206 """Return info about search engines.
1207 1207
1208 Args:
1209 windex: The window index, default is 0.
1210
1208 Returns: 1211 Returns:
1209 An ordered list of dictionaries describing info about each search engine. 1212 An ordered list of dictionaries describing info about each search engine.
1210 1213
1211 Example: 1214 Example:
1212 [ { u'display_url': u'{google:baseURL}search?q=%s', 1215 [ { u'display_url': u'{google:baseURL}search?q=%s',
1213 u'host': u'www.google.com', 1216 u'host': u'www.google.com',
1214 u'in_default_list': True, 1217 u'in_default_list': True,
1215 u'is_default': True, 1218 u'is_default': True,
1216 u'is_valid': True, 1219 u'is_valid': True,
1217 u'keyword': u'google.com', 1220 u'keyword': u'google.com',
1218 u'path': u'/search', 1221 u'path': u'/search',
1219 u'short_name': u'Google', 1222 u'short_name': u'Google',
1220 u'supports_replacement': True, 1223 u'supports_replacement': True,
1221 u'url': u'{google:baseURL}search?q={searchTerms}'}, 1224 u'url': u'{google:baseURL}search?q={searchTerms}'},
1222 { u'display_url': u'http://search.yahoo.com/search?p=%s', 1225 { u'display_url': u'http://search.yahoo.com/search?p=%s',
1223 u'host': u'search.yahoo.com', 1226 u'host': u'search.yahoo.com',
1224 u'in_default_list': True, 1227 u'in_default_list': True,
1225 u'is_default': False, 1228 u'is_default': False,
1226 u'is_valid': True, 1229 u'is_valid': True,
1227 u'keyword': u'yahoo.com', 1230 u'keyword': u'yahoo.com',
1228 u'path': u'/search', 1231 u'path': u'/search',
1229 u'short_name': u'Yahoo!', 1232 u'short_name': u'Yahoo!',
1230 u'supports_replacement': True, 1233 u'supports_replacement': True,
1231 u'url': u'http://search.yahoo.com/search?p={searchTerms}'}, 1234 u'url': u'http://search.yahoo.com/search?p={searchTerms}'},
1232 """ 1235 """
1233 # Ensure that the search engine profile is loaded into data model. 1236 # Ensure that the search engine profile is loaded into data model.
1234 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1237 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'},
1238 windex=windex)
1235 cmd_dict = {'command': 'GetSearchEngineInfo'} 1239 cmd_dict = {'command': 'GetSearchEngineInfo'}
1236 return self._GetResultFromJSONRequest(cmd_dict)['search_engines'] 1240 return self._GetResultFromJSONRequest(
1241 cmd_dict, windex=windex)['search_engines']
1237 1242
1238 def AddSearchEngine(self, title, keyword, url): 1243 def AddSearchEngine(self, title, keyword, url, windex=0):
1239 """Add a search engine, as done through the search engines UI. 1244 """Add a search engine, as done through the search engines UI.
1240 1245
1241 Args: 1246 Args:
1242 title: name for search engine. 1247 title: name for search engine.
1243 keyword: keyword, used to initiate a custom search from omnibox. 1248 keyword: keyword, used to initiate a custom search from omnibox.
1244 url: url template for this search engine's query. 1249 url: url template for this search engine's query.
1245 '%s' is replaced by search query string when used to search. 1250 '%s' is replaced by search query string when used to search.
1251 windex: The window index, default is 0.
1246 """ 1252 """
1247 # Ensure that the search engine profile is loaded into data model. 1253 # Ensure that the search engine profile is loaded into data model.
1248 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1254 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'},
1255 windex=windex)
1249 cmd_dict = {'command': 'AddOrEditSearchEngine', 1256 cmd_dict = {'command': 'AddOrEditSearchEngine',
1250 'new_title': title, 1257 'new_title': title,
1251 'new_keyword': keyword, 1258 'new_keyword': keyword,
1252 'new_url': url} 1259 'new_url': url}
1253 self._GetResultFromJSONRequest(cmd_dict) 1260 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1254 1261
1255 def EditSearchEngine(self, keyword, new_title, new_keyword, new_url): 1262 def EditSearchEngine(self, keyword, new_title, new_keyword, new_url,
1263 windex=0):
1256 """Edit info for existing search engine. 1264 """Edit info for existing search engine.
1257 1265
1258 Args: 1266 Args:
1259 keyword: existing search engine keyword. 1267 keyword: existing search engine keyword.
1260 new_title: new name for this search engine. 1268 new_title: new name for this search engine.
1261 new_keyword: new keyword for this search engine. 1269 new_keyword: new keyword for this search engine.
1262 new_url: new url for this search engine. 1270 new_url: new url for this search engine.
1271 windex: The window index, default is 0.
1263 """ 1272 """
1264 # Ensure that the search engine profile is loaded into data model. 1273 # Ensure that the search engine profile is loaded into data model.
1265 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1274 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'},
1275 windex=windex)
1266 cmd_dict = {'command': 'AddOrEditSearchEngine', 1276 cmd_dict = {'command': 'AddOrEditSearchEngine',
1267 'keyword': keyword, 1277 'keyword': keyword,
1268 'new_title': new_title, 1278 'new_title': new_title,
1269 'new_keyword': new_keyword, 1279 'new_keyword': new_keyword,
1270 'new_url': new_url} 1280 'new_url': new_url}
1271 self._GetResultFromJSONRequest(cmd_dict) 1281 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1272 1282
1273 def DeleteSearchEngine(self, keyword): 1283 def DeleteSearchEngine(self, keyword, windex=0):
1274 """Delete search engine with given keyword. 1284 """Delete search engine with given keyword.
1275 1285
1276 Args: 1286 Args:
1277 keyword: the keyword string of the search engine to delete. 1287 keyword: the keyword string of the search engine to delete.
1288 windex: The window index, default is 0.
1278 """ 1289 """
1279 # Ensure that the search engine profile is loaded into data model. 1290 # Ensure that the search engine profile is loaded into data model.
1280 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1291 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'},
1292 windex=windex)
1281 cmd_dict = {'command': 'PerformActionOnSearchEngine', 'keyword': keyword, 1293 cmd_dict = {'command': 'PerformActionOnSearchEngine', 'keyword': keyword,
1282 'action': 'delete'} 1294 'action': 'delete'}
1283 self._GetResultFromJSONRequest(cmd_dict) 1295 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1284 1296
1285 def MakeSearchEngineDefault(self, keyword): 1297 def MakeSearchEngineDefault(self, keyword, windex=0):
1286 """Make search engine with given keyword the default search. 1298 """Make search engine with given keyword the default search.
1287 1299
1288 Args: 1300 Args:
1289 keyword: the keyword string of the search engine to make default. 1301 keyword: the keyword string of the search engine to make default.
1302 windex: The window index, default is 0.
1290 """ 1303 """
1291 # Ensure that the search engine profile is loaded into data model. 1304 # Ensure that the search engine profile is loaded into data model.
1292 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1305 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'},
1306 windex=windex)
1293 cmd_dict = {'command': 'PerformActionOnSearchEngine', 'keyword': keyword, 1307 cmd_dict = {'command': 'PerformActionOnSearchEngine', 'keyword': keyword,
1294 'action': 'default'} 1308 'action': 'default'}
1295 self._GetResultFromJSONRequest(cmd_dict) 1309 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1296 1310
1297 def _EnsureProtectorCheck(self): 1311 def _EnsureProtectorCheck(self):
1298 """Ensure that Protector check for changed settings has been performed in 1312 """Ensure that Protector check for changed settings has been performed in
1299 the current browser session. 1313 the current browser session.
1300 1314
1301 No-op if Protector is disabled. 1315 No-op if Protector is disabled.
1302 """ 1316 """
1303 # Ensure that check for default search engine change has been performed. 1317 # Ensure that check for default search engine change has been performed.
1304 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'}) 1318 self._GetResultFromJSONRequest({'command': 'LoadSearchEngineInfo'})
1305 1319
(...skipping 4102 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 successful = result.wasSuccessful() 5422 successful = result.wasSuccessful()
5409 if not successful: 5423 if not successful:
5410 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5424 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5411 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5425 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5412 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5426 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5413 sys.exit(not successful) 5427 sys.exit(not successful)
5414 5428
5415 5429
5416 if __name__ == '__main__': 5430 if __name__ == '__main__':
5417 Main() 5431 Main()
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698