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

Side by Side Diff: pyautolib/pyauto.py

Issue 10384104: Chrome updater test framework (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: Created 8 years, 6 months 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """PyAuto: Python Interface to Chromium's Automation Proxy. 6 """PyAuto: Python Interface to Chromium's Automation Proxy.
7 7
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. 8 PyAuto uses swig to expose Automation Proxy interfaces to Python.
9 For complete documentation on the functionality available, 9 For complete documentation on the functionality available,
10 run pydoc on this file. 10 run pydoc on this file.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 import string 42 import string
43 import subprocess 43 import subprocess
44 import sys 44 import sys
45 import tempfile 45 import tempfile
46 import time 46 import time
47 import types 47 import types
48 import unittest 48 import unittest
49 import urllib 49 import urllib
50 50
51 import pyauto_paths 51 import pyauto_paths
52 from py_unittest_util import GTestTextTestRunner
52 53
53 54
54 def _LocateBinDirs(): 55 def _LocateBinDirs():
55 """Setup a few dirs where we expect to find dependency libraries.""" 56 """Setup a few dirs where we expect to find dependency libraries."""
56 deps_dirs = [ 57 deps_dirs = [
57 os.path.dirname(__file__), 58 os.path.dirname(__file__),
58 pyauto_paths.GetThirdPartyDir(), 59 pyauto_paths.GetThirdPartyDir(),
59 os.path.join(pyauto_paths.GetThirdPartyDir(), 'webdriver', 'pylib'), 60 os.path.join(pyauto_paths.GetThirdPartyDir(), 'webdriver', 'pylib'),
60 ] 61 ]
61 sys.path += map(os.path.normpath, pyauto_paths.GetBuildDirs() + deps_dirs) 62 sys.path += map(os.path.normpath, pyauto_paths.GetBuildDirs() + deps_dirs)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 Args: 128 Args:
128 methodName: the default method name. Internal use by unittest module 129 methodName: the default method name. Internal use by unittest module
129 130
130 (The rest of the args can be in any order. They can even be skipped in 131 (The rest of the args can be in any order. They can even be skipped in
131 which case the defaults will be used.) 132 which case the defaults will be used.)
132 133
133 clear_profile: If True, clean the profile dir before use. Defaults to True 134 clear_profile: If True, clean the profile dir before use. Defaults to True
134 homepage: the home page. Defaults to "about:blank" 135 homepage: the home page. Defaults to "about:blank"
135 """ 136 """
136 # Fetch provided keyword args, or fill in defaults. 137 # Fetch provided keyword args, or fill in defaults.
138 browser_path = kwargs.get('browser_path', None)
137 clear_profile = kwargs.get('clear_profile', True) 139 clear_profile = kwargs.get('clear_profile', True)
138 homepage = kwargs.get('homepage', 'about:blank') 140 homepage = kwargs.get('homepage', 'about:blank')
139 141
140 pyautolib.PyUITestBase.__init__(self, clear_profile, homepage) 142 pyautolib.PyUITestBase.__init__(self, clear_profile, homepage)
141 self.Initialize(pyautolib.FilePath(self.BrowserPath())) 143 if browser_path:
144 self.Initialize(pyautolib.FilePath(browser_path))
145 else:
146 self.Initialize(pyautolib.FilePath(self.BrowserPath()))
142 unittest.TestCase.__init__(self, methodName) 147 unittest.TestCase.__init__(self, methodName)
143 148
144 # Give all pyauto tests easy access to pprint.PrettyPrinter functions. 149 # Give all pyauto tests easy access to pprint.PrettyPrinter functions.
145 self.pprint = pprint.pprint 150 self.pprint = pprint.pprint
146 self.pformat = pprint.pformat 151 self.pformat = pprint.pformat
147 152
148 # Set up remote proxies, if they were requested. 153 # Set up remote proxies, if they were requested.
149 self.remotes = [] 154 self.remotes = []
150 self.remote = None 155 self.remote = None
151 global _REMOTE_PROXY 156 global _REMOTE_PROXY
(...skipping 5576 matching lines...) Expand 10 before | Expand all | Expand 10 after
5728 logging.debug("Loading %d tests from %s", len(test_names), test_names) 5733 logging.debug("Loading %d tests from %s", len(test_names), test_names)
5729 if self._options.list_tests: # List tests and exit 5734 if self._options.list_tests: # List tests and exit
5730 for name in test_names: 5735 for name in test_names:
5731 print name 5736 print name
5732 sys.exit(0) 5737 sys.exit(0)
5733 pyauto_suite = PyUITestSuite(suite_args) 5738 pyauto_suite = PyUITestSuite(suite_args)
5734 loaded_tests = unittest.defaultTestLoader.loadTestsFromNames(test_names) 5739 loaded_tests = unittest.defaultTestLoader.loadTestsFromNames(test_names)
5735 pyauto_suite.addTests(loaded_tests) 5740 pyauto_suite.addTests(loaded_tests)
5736 verbosity = 1 5741 verbosity = 1
5737 if self._options.verbose: 5742 if self._options.verbose:
5738 verbosity = 2 5743 verbosity = 2
5739 result = PyAutoTextTestRunner(verbosity=verbosity).run(pyauto_suite) 5744 result = GTestTextTestRunner(verbosity=verbosity).run(pyauto_suite)
5740 del loaded_tests # Need to destroy test cases before the suite 5745 del loaded_tests # Need to destroy test cases before the suite
5741 del pyauto_suite 5746 del pyauto_suite
5742 successful = result.wasSuccessful() 5747 successful = result.wasSuccessful()
5743 if not successful: 5748 if not successful:
5744 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5749 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5745 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5750 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5746 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5751 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5747 sys.exit(not successful) 5752 sys.exit(not successful)
5748 5753
5749 5754
5750 if __name__ == '__main__': 5755 if __name__ == '__main__':
5751 Main() 5756 Main()
OLDNEW
« pyautolib/fetch_prebuilt_pyauto.py ('K') | « pyautolib/fetch_prebuilt_pyauto.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698