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

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

Issue 10916328: Convert themes.py to browser test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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/test/functional/themes.py ('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 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 A list of dictionaries representing each password. For an example 3182 A list of dictionaries representing each password. For an example
3183 dictionary see AddSavedPassword documentation. The overall structure will 3183 dictionary see AddSavedPassword documentation. The overall structure will
3184 be: 3184 be:
3185 [ {password1 dictionary}, {password2 dictionary} ] 3185 [ {password1 dictionary}, {password2 dictionary} ]
3186 """ 3186 """
3187 cmd_dict = { # Prepare command for the json interface 3187 cmd_dict = { # Prepare command for the json interface
3188 'command': 'GetSavedPasswords' 3188 'command': 'GetSavedPasswords'
3189 } 3189 }
3190 return self._GetResultFromJSONRequest(cmd_dict)['passwords'] 3190 return self._GetResultFromJSONRequest(cmd_dict)['passwords']
3191 3191
3192 def ResetToDefaultTheme(self, windex=0):
3193 """Reset to default theme.
3194
3195 Args:
3196 windex: Index of the window to reset; defaults to 0.
3197
3198 Raises:
3199 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3200 """
3201 cmd_dict = {
3202 'command': 'ResetToDefaultTheme',
3203 'windex': windex,
3204 }
3205 self._GetResultFromJSONRequest(cmd_dict, windex=None)
3206
3207 def SetTheme(self, crx_file_path, windex=0): 3192 def SetTheme(self, crx_file_path, windex=0):
3208 """Installs the given theme synchronously. 3193 """Installs the given theme synchronously.
3209 3194
3210 A theme file is a file with a .crx suffix, like an extension. The theme 3195 A theme file is a file with a .crx suffix, like an extension. The theme
3211 file must be specified with an absolute path. This method call waits until 3196 file must be specified with an absolute path. This method call waits until
3212 the theme is installed and will trigger the "theme installed" infobar. 3197 the theme is installed and will trigger the "theme installed" infobar.
3213 If the install is unsuccessful, will throw an exception. 3198 If the install is unsuccessful, will throw an exception.
3214 3199
3215 Uses InstallExtension(). 3200 Uses InstallExtension().
3216 3201
3217 Returns: 3202 Returns:
3218 The ID of the installed theme. 3203 The ID of the installed theme.
3219 3204
3220 Raises: 3205 Raises:
3221 pyauto_errors.JSONInterfaceError if the automation call returns an error. 3206 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3222 """ 3207 """
3223 return self.InstallExtension(crx_file_path, True, windex) 3208 return self.InstallExtension(crx_file_path, True, windex)
3224 3209
3225 def WaitUntilDownloadedThemeSet(self, theme_name):
3226 """Waits until the theme has been set.
3227
3228 This should not be called after SetTheme(). It only needs to be called after
3229 downloading a theme file (which will automatically set the theme).
3230
3231 Uses WaitUntil so timeout is capped by automation timeout.
3232
3233 Args:
3234 theme_name: The name that the theme will have once it is installed.
3235 """
3236 def _ReturnThemeSet(name):
3237 theme_info = self.GetThemeInfo()
3238 return theme_info and theme_info['name'] == name
3239 return self.WaitUntil(_ReturnThemeSet, args=[theme_name])
3240
3241 def ClearTheme(self):
3242 """Clear the theme. Resets to default.
3243
3244 Has no effect when the theme is already the default one.
3245 This is a blocking call.
3246
3247 Raises:
3248 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3249 """
3250 cmd_dict = {
3251 'command': 'ClearTheme',
3252 }
3253 self._GetResultFromJSONRequest(cmd_dict)
3254
3255 def GetThemeInfo(self, windex=0):
3256 """Get info about theme.
3257
3258 This includes info about the theme name, its colors, images, etc.
3259
3260 Returns:
3261 a dictionary containing info about the theme.
3262 empty dictionary if no theme has been applied (default theme).
3263 SAMPLE:
3264 { u'colors': { u'frame': [71, 105, 91],
3265 u'ntp_link': [36, 70, 0],
3266 u'ntp_section': [207, 221, 192],
3267 u'ntp_text': [20, 40, 0],
3268 u'toolbar': [207, 221, 192]},
3269 u'images': { u'theme_frame': u'images/theme_frame_camo.png',
3270 u'theme_ntp_background': u'images/theme_ntp_background.png',
3271 u'theme_toolbar': u'images/theme_toolbar_camo.png'},
3272 u'name': u'camo theme',
3273 u'tints': {u'buttons': [0.33000000000000002, 0.5, 0.46999999999999997]}}
3274
3275 Raises:
3276 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3277 """
3278 cmd_dict = {
3279 'command': 'GetThemeInfo',
3280 }
3281 return self._GetResultFromJSONRequest(cmd_dict, windex=windex)
3282
3283 def GetActiveNotifications(self): 3210 def GetActiveNotifications(self):
3284 """Gets a list of the currently active/shown HTML5 notifications. 3211 """Gets a list of the currently active/shown HTML5 notifications.
3285 3212
3286 Returns: 3213 Returns:
3287 a list containing info about each active notification, with the 3214 a list containing info about each active notification, with the
3288 first item in the list being the notification on the bottom of the 3215 first item in the list being the notification on the bottom of the
3289 notification stack. The 'content_url' key can refer to a URL or a data 3216 notification stack. The 'content_url' key can refer to a URL or a data
3290 URI. The 'pid' key-value pair may be invalid if the notification is 3217 URI. The 'pid' key-value pair may be invalid if the notification is
3291 closing. 3218 closing.
3292 3219
(...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6476 successful = result.wasSuccessful() 6403 successful = result.wasSuccessful()
6477 if not successful: 6404 if not successful:
6478 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6405 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6479 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6406 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6480 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6407 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6481 sys.exit(not successful) 6408 sys.exit(not successful)
6482 6409
6483 6410
6484 if __name__ == '__main__': 6411 if __name__ == '__main__':
6485 Main() 6412 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/themes.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698