Chromium Code Reviews| 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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 u'infobars': [ { | 1183 u'infobars': [ { |
| 1184 u'buttons': [u'Allow', u'Deny'], | 1184 u'buttons': [u'Allow', u'Deny'], |
| 1185 u'link_text': u'Learn more', | 1185 u'link_text': u'Learn more', |
| 1186 u'text': u'slides.html5rocks.com wants to track ' | 1186 u'text': u'slides.html5rocks.com wants to track ' |
| 1187 'your physical location', | 1187 'your physical location', |
| 1188 u'type': u'confirm_infobar'}], | 1188 u'type': u'confirm_infobar'}], |
| 1189 u'pinned': False, | 1189 u'pinned': False, |
| 1190 u'renderer_pid': 93929, | 1190 u'renderer_pid': 93929, |
| 1191 u'url': u'http://slides.html5rocks.com/#slide14'}, | 1191 u'url': u'http://slides.html5rocks.com/#slide14'}, |
| 1192 ], | 1192 ], |
| 1193 u'type': u'tabbed', | |
| 1193 u'width': 925, | 1194 u'width': 925, |
| 1194 u'x': 26, | 1195 u'x': 26, |
| 1195 u'y': 44}]} | 1196 u'y': 44}]} |
| 1196 | 1197 |
| 1197 Raises: | 1198 Raises: |
| 1198 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 1199 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 1199 """ | 1200 """ |
| 1200 cmd_dict = { # Prepare command for the json interface | 1201 cmd_dict = { # Prepare command for the json interface |
| 1201 'command': 'GetBrowserInfo', | 1202 'command': 'GetBrowserInfo', |
| 1202 } | 1203 } |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2911 u'battery_time_to_empty': 29617, | 2912 u'battery_time_to_empty': 29617, |
| 2912 u'battery_percentage': 100.0, | 2913 u'battery_percentage': 100.0, |
| 2913 u'battery_fully_charged': False } | 2914 u'battery_fully_charged': False } |
| 2914 | 2915 |
| 2915 Raises: | 2916 Raises: |
| 2916 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2917 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 2917 """ | 2918 """ |
| 2918 cmd_dict = { 'command': 'GetBatteryInfo' } | 2919 cmd_dict = { 'command': 'GetBatteryInfo' } |
| 2919 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2920 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
| 2920 | 2921 |
| 2922 def GetPanelInfo(self): | |
| 2923 """Get details about open ChromeOS panels. | |
|
Nirnimesh
2011/06/08 22:07:22
Add some notes like:
A panel is actually a specia
| |
| 2924 | |
| 2925 Returns: | |
| 2926 A dictionary. | |
| 2927 Sample: | |
| 2928 [{ 'incognito': False, | |
| 2929 'renderer_pid': 4820, | |
| 2930 'title': u'Downloads', | |
| 2931 'url': u'chrome://active-downloads/'}] | |
| 2932 | |
| 2933 Raises: | |
| 2934 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 2935 """ | |
| 2936 panels = [] | |
| 2937 for browser in self.GetBrowserInfo()['windows']: | |
| 2938 if browser['type'] != 'panel': | |
| 2939 continue | |
| 2940 | |
| 2941 panel = {} | |
| 2942 panels.append(panel) | |
| 2943 tab = browser['tabs'][0] | |
| 2944 panel['incognito'] = browser['incognito'] | |
| 2945 panel['renderer_pid'] = tab['renderer_pid'] | |
| 2946 panel['title'] = self.GetActiveTabTitle(browser['index']) | |
| 2947 panel['url'] = tab['url'] | |
| 2948 | |
| 2949 return panels | |
| 2950 | |
| 2921 def GetNetworkInfo(self): | 2951 def GetNetworkInfo(self): |
| 2922 """Get details about ethernet, wifi, and cellular networks on chromeos. | 2952 """Get details about ethernet, wifi, and cellular networks on chromeos. |
| 2923 | 2953 |
| 2924 Returns: | 2954 Returns: |
| 2925 A dictionary. | 2955 A dictionary. |
| 2926 Sample: | 2956 Sample: |
| 2927 { u'connected_ethernet': u'/profile/default/ethernet_abcd', | 2957 { u'connected_ethernet': u'/profile/default/ethernet_abcd', |
| 2928 u'connected_wifi': u'/profile/default/wifi_abcd_1234_managed_none', | 2958 u'connected_wifi': u'/profile/default/wifi_abcd_1234_managed_none', |
| 2929 u'ethernet_networks': | 2959 u'ethernet_networks': |
| 2930 { u'/profile/default/ethernet_abcd': | 2960 { u'/profile/default/ethernet_abcd': |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3624 if self._options.verbose: | 3654 if self._options.verbose: |
| 3625 verbosity = 2 | 3655 verbosity = 2 |
| 3626 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 3656 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
| 3627 del loaded_tests # Need to destroy test cases before the suite | 3657 del loaded_tests # Need to destroy test cases before the suite |
| 3628 del pyauto_suite | 3658 del pyauto_suite |
| 3629 sys.exit(not result.wasSuccessful()) | 3659 sys.exit(not result.wasSuccessful()) |
| 3630 | 3660 |
| 3631 | 3661 |
| 3632 if __name__ == '__main__': | 3662 if __name__ == '__main__': |
| 3633 Main() | 3663 Main() |
| OLD | NEW |