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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 u'height': 1134, | 1167 u'height': 1134, |
| 1168 u'incognito': False, | 1168 u'incognito': False, |
| 1169 u'fullscreen': False, | 1169 u'fullscreen': False, |
| 1170 u'selected_tab': 0, | 1170 u'selected_tab': 0, |
| 1171 u'tabs': [ { | 1171 u'tabs': [ { |
| 1172 u'index': 0, | 1172 u'index': 0, |
| 1173 u'infobars': [], | 1173 u'infobars': [], |
| 1174 u'pinned': True, | 1174 u'pinned': True, |
| 1175 u'renderer_pid': 93747, | 1175 u'renderer_pid': 93747, |
| 1176 u'url': u'http://www.google.com/' }, { | 1176 u'url': u'http://www.google.com/' }, { |
| 1177 u'index': 1, | 1177 u'index': 1, |
|
Nirnimesh
2011/06/08 21:50:28
Add 'type' here
dtu
2011/06/08 22:02:57
Done.
| |
| 1178 u'infobars': [], | 1178 u'infobars': [], |
| 1179 u'pinned': False, | 1179 u'pinned': False, |
| 1180 u'renderer_pid': 93919, | 1180 u'renderer_pid': 93919, |
| 1181 u'url': u'https://chrome.google.com/'}, { | 1181 u'url': u'https://chrome.google.com/'}, { |
| 1182 u'index': 2, | 1182 u'index': 2, |
| 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', |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2911 u'battery_time_to_empty': 29617, | 2911 u'battery_time_to_empty': 29617, |
| 2912 u'battery_percentage': 100.0, | 2912 u'battery_percentage': 100.0, |
| 2913 u'battery_fully_charged': False } | 2913 u'battery_fully_charged': False } |
| 2914 | 2914 |
| 2915 Raises: | 2915 Raises: |
| 2916 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 2916 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
| 2917 """ | 2917 """ |
| 2918 cmd_dict = { 'command': 'GetBatteryInfo' } | 2918 cmd_dict = { 'command': 'GetBatteryInfo' } |
| 2919 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) | 2919 return self._GetResultFromJSONRequest(cmd_dict, windex=-1) |
| 2920 | 2920 |
| 2921 def GetPanelInfo(self): | |
| 2922 """Get details about open ChromeOS panels. | |
| 2923 | |
| 2924 Returns: | |
| 2925 A dictionary. | |
| 2926 Sample: | |
| 2927 [{ 'incognito': False, | |
| 2928 'renderer_pid': 4820, | |
| 2929 'title': u'Downloads', | |
| 2930 'url': u'chrome://active-downloads/'}] | |
| 2931 | |
| 2932 Raises: | |
| 2933 pyauto_errors.JSONInterfaceError if the automation call returns an error. | |
| 2934 """ | |
| 2935 panels = [] | |
| 2936 browsers = self.GetBrowserInfo() | |
| 2937 for browser in browsers['windows']: | |
| 2938 if browser['type'] != 'panel': | |
| 2939 continue | |
| 2940 | |
| 2941 panel = {} | |
| 2942 panels.append(panel) | |
| 2943 panel['incognito'] = browser['incognito'] | |
| 2944 panel['title'] = self.GetActiveTabTitle(browser['index']) | |
| 2945 | |
| 2946 for tab in browser['tabs']: | |
|
Nirnimesh
2011/06/08 21:50:28
Won't there be just one tab?
dtu
2011/06/08 22:02:57
Done.
| |
| 2947 if tab['index'] != browser['selected_tab']: | |
| 2948 continue | |
| 2949 | |
| 2950 panel['renderer_pid'] = tab['renderer_pid'] | |
| 2951 panel['url'] = tab['url'] | |
| 2952 break | |
| 2953 | |
| 2954 return panels | |
| 2955 | |
| 2921 def GetNetworkInfo(self): | 2956 def GetNetworkInfo(self): |
| 2922 """Get details about ethernet, wifi, and cellular networks on chromeos. | 2957 """Get details about ethernet, wifi, and cellular networks on chromeos. |
| 2923 | 2958 |
| 2924 Returns: | 2959 Returns: |
| 2925 A dictionary. | 2960 A dictionary. |
| 2926 Sample: | 2961 Sample: |
| 2927 { u'connected_ethernet': u'/profile/default/ethernet_abcd', | 2962 { u'connected_ethernet': u'/profile/default/ethernet_abcd', |
| 2928 u'connected_wifi': u'/profile/default/wifi_abcd_1234_managed_none', | 2963 u'connected_wifi': u'/profile/default/wifi_abcd_1234_managed_none', |
| 2929 u'ethernet_networks': | 2964 u'ethernet_networks': |
| 2930 { u'/profile/default/ethernet_abcd': | 2965 { u'/profile/default/ethernet_abcd': |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3624 if self._options.verbose: | 3659 if self._options.verbose: |
| 3625 verbosity = 2 | 3660 verbosity = 2 |
| 3626 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 3661 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
| 3627 del loaded_tests # Need to destroy test cases before the suite | 3662 del loaded_tests # Need to destroy test cases before the suite |
| 3628 del pyauto_suite | 3663 del pyauto_suite |
| 3629 sys.exit(not result.wasSuccessful()) | 3664 sys.exit(not result.wasSuccessful()) |
| 3630 | 3665 |
| 3631 | 3666 |
| 3632 if __name__ == '__main__': | 3667 if __name__ == '__main__': |
| 3633 Main() | 3668 Main() |
| OLD | NEW |