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

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

Issue 4223001: Add pyauto tests and helper files for system-level testing of Web SQL Databases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/functional
Patch Set: ... Created 10 years, 1 month 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/notifications.py ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 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 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 cmd_dict = { 1589 cmd_dict = {
1590 'command': 'FindInPage', 1590 'command': 'FindInPage',
1591 'tab_index' : tab_index, 1591 'tab_index' : tab_index,
1592 'search_string' : search_string, 1592 'search_string' : search_string,
1593 'forward' : forward, 1593 'forward' : forward,
1594 'match_case' : match_case, 1594 'match_case' : match_case,
1595 'find_next' : find_next, 1595 'find_next' : find_next,
1596 } 1596 }
1597 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) 1597 return self._GetResultFromJSONRequest(cmd_dict, windex=windex)
1598 1598
1599 def CallJavascriptFunc(self, function, args=[], tab_index=0, windex=0):
1600 """Executes a script which calls a given javascript function.
1601
1602 The invoked javascript function must send a result back via the
1603 domAutomationController.send function, or this function will never return.
1604
1605 Defaults to first tab in first window.
1606
1607 Args:
1608 function: name of the function
1609 args: list of all the arguments to pass into the called function. These
1610 should be able to be converted to a string using the |str| function.
1611 tab_index: index of the tab within the given window
1612 windex: index of the window
1613
1614 Returns:
1615 a string that was sent back via the domAutomationController.send method
1616 """
1617 # Convert the given arguments for evaluation in a javascript statement.
1618 converted_args = []
1619 for arg in args:
1620 # If it is a string argument, we need to quote and escape it properly.
1621 if type(arg) == type('string') or type(arg) == type(u'unicode'):
1622 # We must convert all " in the string to \", so that we don't try
1623 # to evaluate invalid javascript like ""arg"".
1624 converted_arg = '"' + arg.replace('"', '\\"') + '"'
1625 else:
1626 # Convert it to a string so that we can use |join| later.
1627 converted_arg = str(arg)
1628 converted_args += [converted_arg]
1629 js = '%s(%s)' % (function, ', '.join(converted_args))
1630 logging.debug('Executing javascript: ', js)
1631 return self.ExecuteJavascript(js, windex, tab_index)
1632
1599 1633
1600 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): 1634 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite):
1601 """Base TestSuite for PyAuto UI tests.""" 1635 """Base TestSuite for PyAuto UI tests."""
1602 1636
1603 def __init__(self, args): 1637 def __init__(self, args):
1604 pyautolib.PyUITestSuiteBase.__init__(self, args) 1638 pyautolib.PyUITestSuiteBase.__init__(self, args)
1605 1639
1606 # Figure out path to chromium binaries 1640 # Figure out path to chromium binaries
1607 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__)) 1641 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__))
1608 logging.debug('Loading pyauto libs from %s', browser_dir) 1642 logging.debug('Loading pyauto libs from %s', browser_dir)
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 if self._options.verbose: 1932 if self._options.verbose:
1899 verbosity = 2 1933 verbosity = 2
1900 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 1934 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
1901 del loaded_tests # Need to destroy test cases before the suite 1935 del loaded_tests # Need to destroy test cases before the suite
1902 del pyauto_suite 1936 del pyauto_suite
1903 sys.exit(not result.wasSuccessful()) 1937 sys.exit(not result.wasSuccessful())
1904 1938
1905 1939
1906 if __name__ == '__main__': 1940 if __name__ == '__main__':
1907 Main() 1941 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/notifications.py ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698