OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
8 | 8 |
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
(...skipping 3091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3102 | 3102 |
3103 Raises: | 3103 Raises: |
3104 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3104 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
3105 """ | 3105 """ |
3106 cmd_dict = { | 3106 cmd_dict = { |
3107 'command': 'KillRendererProcess', | 3107 'command': 'KillRendererProcess', |
3108 'pid': pid | 3108 'pid': pid |
3109 } | 3109 } |
3110 return self._GetResultFromJSONRequest(cmd_dict) | 3110 return self._GetResultFromJSONRequest(cmd_dict) |
3111 | 3111 |
3112 def GetNTPThumbnailMode(self): | |
3113 """Identifies whether or not each relevant NTP section is in thumbnail mode. | |
3114 | |
3115 Thumbnail mode applies to the Apps section and the Most Visited section. | |
3116 When in thumbnail mode, large thumbnails appear for each item in the | |
3117 section. When not in thumbnail mode, small icons appear instead. At any | |
3118 given time, at most one section can be in thumbnail mode in the NTP. | |
3119 | |
3120 SAMPLE OUTPUT: | |
3121 { | |
3122 u'apps': True, | |
3123 u'most_visited': False | |
3124 } | |
3125 | |
3126 Returns: | |
3127 A dictionary indicating whether or not each relevant section of the NTP | |
3128 is in thumbnail mode. | |
3129 | |
3130 Raises: | |
3131 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
3132 """ | |
3133 cmd_dict = { | |
3134 'command': 'GetNTPThumbnailMode', | |
3135 } | |
3136 return self._GetResultFromJSONRequest(cmd_dict) | |
3137 | |
3138 def SetNTPThumbnailMode(self, section, turn_on): | |
3139 """Puts or removes a section of the NTP into/from thumbnail (expanded) mode. | |
3140 | |
3141 Thumbnail mode applies to the Apps section and the Most Visited section. | |
3142 At any given time, at most one section can be in thumbnail mode in the NTP; | |
3143 when a specified section is put into thumbnail mode, the other section is | |
3144 removed from thumbnail mode. | |
3145 | |
3146 Args: | |
3147 section: A string representing the NTP section to use. | |
3148 Possible values: | |
3149 'apps': the "Apps" section. | |
3150 'most_visited': the "Most Visited" section. | |
3151 turn_on: A boolean indicating whether to put the section into thumbnail | |
3152 mode (True), or remove the section from thumbnail mode (False). | |
3153 | |
3154 Raises: | |
3155 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
3156 """ | |
3157 cmd_dict = { | |
3158 'command': 'SetNTPThumbnailMode', | |
3159 'section': section, | |
3160 'turn_on': turn_on | |
3161 } | |
3162 return self._GetResultFromJSONRequest(cmd_dict) | |
3163 | |
3164 def GetNTPMenuMode(self): | |
3165 """Identifies whether or not each relevant NTP section is in menu mode. | |
3166 | |
3167 Menu mode applies to the Apps section, the Most Visited section, and the | |
3168 Recently Closed section. When in menu mode, the section is almost | |
3169 completely hidden, appearing as a menu at the bottom of the NTP. When not | |
3170 in menu mode, the section appears with all information in the regular | |
3171 location in the NTP. | |
3172 | |
3173 SAMPLE OUTPUT: | |
3174 { | |
3175 u'apps': False, | |
3176 u'most_visited': True, | |
3177 u'recently_closed': True | |
3178 } | |
3179 | |
3180 Returns: | |
3181 A dictionary indicating whether or not each relevant section of the NTP | |
3182 is in menu mode. | |
3183 | |
3184 Raises: | |
3185 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
3186 """ | |
3187 cmd_dict = { | |
3188 'command': 'GetNTPMenuMode', | |
3189 } | |
3190 return self._GetResultFromJSONRequest(cmd_dict) | |
3191 | |
3192 def SetNTPMenuMode(self, section, turn_on): | |
3193 """Puts or removes the specified section of the NTP into/from menu mode. | |
3194 | |
3195 Menu mode applies to the Apps section, the Most Visited section, and the | |
3196 Recently Closed section. | |
3197 | |
3198 Args: | |
3199 section: A string representing the NTP section to use. | |
3200 Possible values: | |
3201 'apps': the "Apps" section. | |
3202 'most_visited': the "Most Visited" section. | |
3203 'recently_closed': the "Recently Closed" section. | |
3204 turn_on: A boolean indicating whether to put the section into menu mode | |
3205 (True), or remove the section from menu mode (False). | |
3206 | |
3207 Raises: | |
3208 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
3209 """ | |
3210 cmd_dict = { | |
3211 'command': 'SetNTPMenuMode', | |
3212 'section': section, | |
3213 'turn_on': turn_on | |
3214 } | |
3215 return self._GetResultFromJSONRequest(cmd_dict) | |
3216 | |
3217 def NewWebDriver(self): | 3112 def NewWebDriver(self): |
3218 """Returns a new remote WebDriver instance. | 3113 """Returns a new remote WebDriver instance. |
3219 | 3114 |
3220 Returns: | 3115 Returns: |
3221 selenium.webdriver.remote.webdriver.WebDriver instance | 3116 selenium.webdriver.remote.webdriver.WebDriver instance |
3222 """ | 3117 """ |
3223 from chrome_driver_factory import ChromeDriverFactory | 3118 from chrome_driver_factory import ChromeDriverFactory |
3224 global _CHROME_DRIVER_FACTORY | 3119 global _CHROME_DRIVER_FACTORY |
3225 if _CHROME_DRIVER_FACTORY is None: | 3120 if _CHROME_DRIVER_FACTORY is None: |
3226 _CHROME_DRIVER_FACTORY = ChromeDriverFactory() | 3121 _CHROME_DRIVER_FACTORY = ChromeDriverFactory() |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4767 successful = result.wasSuccessful() | 4662 successful = result.wasSuccessful() |
4768 if not successful: | 4663 if not successful: |
4769 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 4664 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
4770 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 4665 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
4771 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 4666 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
4772 sys.exit(not successful) | 4667 sys.exit(not successful) |
4773 | 4668 |
4774 | 4669 |
4775 if __name__ == '__main__': | 4670 if __name__ == '__main__': |
4776 Main() | 4671 Main() |
OLD | NEW |