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

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

Issue 8587004: Add PyAuto tests for triggering browser/page action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Ken's comments Created 9 years 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
OLDNEW
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 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 u'command_line_string': "COMMAND_LINE_STRING --WITH-FLAGS", 1461 u'command_line_string': "COMMAND_LINE_STRING --WITH-FLAGS",
1462 u'branding': 'Chromium', 1462 u'branding': 'Chromium',
1463 u'is_official': False,} 1463 u'is_official': False,}
1464 # The order of the windows and tabs listed here will be the same as 1464 # The order of the windows and tabs listed here will be the same as
1465 # what shows up on screen. 1465 # what shows up on screen.
1466 u'windows': [ { u'index': 0, 1466 u'windows': [ { u'index': 0,
1467 u'height': 1134, 1467 u'height': 1134,
1468 u'incognito': False, 1468 u'incognito': False,
1469 u'profile_path': u'Default', 1469 u'profile_path': u'Default',
1470 u'fullscreen': False, 1470 u'fullscreen': False,
1471 u'visible_page_actions':
1472 [u'dgcoklnmbeljaehamekjpeidmbicddfj',
1473 u'osfcklnfasdofpcldmalwpicslasdfgd']
1471 u'selected_tab': 0, 1474 u'selected_tab': 0,
1472 u'tabs': [ { 1475 u'tabs': [ {
1473 u'index': 0, 1476 u'index': 0,
1474 u'infobars': [], 1477 u'infobars': [],
1475 u'pinned': True, 1478 u'pinned': True,
1476 u'renderer_pid': 93747, 1479 u'renderer_pid': 93747,
1477 u'url': u'http://www.google.com/' }, { 1480 u'url': u'http://www.google.com/' }, {
1478 u'index': 1, 1481 u'index': 1,
1479 u'infobars': [], 1482 u'infobars': [],
1480 u'pinned': False, 1483 u'pinned': False,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 allow_in_incognito: A boolean, allow extension in incognito. 1786 allow_in_incognito: A boolean, allow extension in incognito.
1784 """ 1787 """
1785 cmd_dict = { # Prepare command for the json interface 1788 cmd_dict = { # Prepare command for the json interface
1786 'command': 'SetExtensionStateById', 1789 'command': 'SetExtensionStateById',
1787 'id': id, 1790 'id': id,
1788 'enable': enable, 1791 'enable': enable,
1789 'allow_in_incognito': allow_in_incognito, 1792 'allow_in_incognito': allow_in_incognito,
1790 } 1793 }
1791 self._GetResultFromJSONRequest(cmd_dict) 1794 self._GetResultFromJSONRequest(cmd_dict)
1792 1795
1796 def TriggerPageActionById(self, id, windex=0):
1797 """Trigger page action asynchronously in the active tab.
1798
1799 The page action icon must be displayed before invoking this function.
1800
1801 Args:
1802 id: The string id of the extension.
1803 windex: Integer index of the browser window to use; defaults to 0
1804 (first window).
1805 """
1806 cmd_dict = { # Prepare command for the json interface
1807 'command': 'TriggerPageActionById',
1808 'id': id,
1809 'windex': windex,
1810 }
1811 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1812
1813 def TriggerBrowserActionById(self, id, windex=0):
1814 """Trigger browser action asynchronously in the active tab.
1815
1816 Args:
1817 id: The string id of the extension.
1818 windex: Integer index of the browser window to use; defaults to 0
1819 (first window).
1820 """
1821 cmd_dict = { # Prepare command for the json interface
1822 'command': 'TriggerBrowserActionById',
1823 'id': id,
1824 'windex': windex,
1825 }
1826 self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1827
1793 def UpdateExtensionsNow(self): 1828 def UpdateExtensionsNow(self):
1794 """Auto-updates installed extensions. 1829 """Auto-updates installed extensions.
1795 1830
1796 Waits until all extensions are updated, loaded, and ready for use. 1831 Waits until all extensions are updated, loaded, and ready for use.
1797 This is equivalent to clicking the "Update extensions now" button on the 1832 This is equivalent to clicking the "Update extensions now" button on the
1798 chrome://extensions page. 1833 chrome://extensions page.
1799 1834
1800 Raises: 1835 Raises:
1801 pyauto_errors.JSONInterfaceError if the automation returns an error. 1836 pyauto_errors.JSONInterfaceError if the automation returns an error.
1802 """ 1837 """
(...skipping 10 matching lines...) Expand all
1813 If there are more than one matching extension view, return one at random. 1848 If there are more than one matching extension view, return one at random.
1814 Uses WaitUntil so timeout is capped by automation timeout. 1849 Uses WaitUntil so timeout is capped by automation timeout.
1815 Refer to extension_view dictionary returned in GetBrowserInfo() 1850 Refer to extension_view dictionary returned in GetBrowserInfo()
1816 for sample input/output values. 1851 for sample input/output values.
1817 1852
1818 Args: 1853 Args:
1819 name: (optional) Name of the extension. 1854 name: (optional) Name of the extension.
1820 extension_id: (optional) ID of the extension. 1855 extension_id: (optional) ID of the extension.
1821 url: (optional) URL of the extension view. 1856 url: (optional) URL of the extension view.
1822 view_type: (optional) Type of the extension view. 1857 view_type: (optional) Type of the extension view.
1858 [EXTENSION_BACKGROUND_PAGE|EXTENSION_POPUP|EXTENSION_INFOBAR|
1859 EXTENSION_DIALOG]
dennis_jeffrey 2011/11/23 21:54:54 Should these be strings?
1823 1860
1824 Returns: 1861 Returns:
1825 The 'view' property of the extension view. 1862 The 'view' property of the extension view.
1826 None, if no view loaded. 1863 None, if no view loaded.
1827 1864
1828 Raises: 1865 Raises:
1829 pyauto_errors.JSONInterfaceError if the automation returns an error. 1866 pyauto_errors.JSONInterfaceError if the automation returns an error.
1830 """ 1867 """
1831 def _GetExtensionViewLoaded(): 1868 def _GetExtensionViewLoaded():
1832 extension_views = self.GetBrowserInfo()['extension_views'] 1869 extension_views = self.GetBrowserInfo()['extension_views']
(...skipping 2949 matching lines...) Expand 10 before | Expand all | Expand 10 after
4782 successful = result.wasSuccessful() 4819 successful = result.wasSuccessful()
4783 if not successful: 4820 if not successful:
4784 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 4821 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
4785 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 4822 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
4786 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 4823 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
4787 sys.exit(not successful) 4824 sys.exit(not successful)
4788 4825
4789 4826
4790 if __name__ == '__main__': 4827 if __name__ == '__main__':
4791 Main() 4828 Main()
OLDNEW
« chrome/test/functional/extensions.py ('K') | « chrome/test/functional/extensions.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698