diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 20:02:23 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 20:02:23 +0000 |
commit | 3cb98c208053e8c610b8d5b832982232625dd369 (patch) | |
tree | ed131b9511a02dd9ed6abd2260fe1317d8bdd086 /chrome/test | |
parent | 3d1e89df95d421bcedec406019b3a9dbbf94b8c1 (diff) | |
download | chromium_src-3cb98c208053e8c610b8d5b832982232625dd369.zip chromium_src-3cb98c208053e8c610b8d5b832982232625dd369.tar.gz chromium_src-3cb98c208053e8c610b8d5b832982232625dd369.tar.bz2 |
Allow pyauto to provide extra flags to be passed when launching chrome
With this, a test can provide additional flags to pass to chrome, for example
to specify the proxy server to use, as in the example below:
class ArgsTest(PyUITest):
def __init__(self, methodName):
PyUITest.__init__(self, methodName,
extra_chrome_flags="--proxy-server=PROXY_SERVER:PORT")
def testProxy(self):
self.NavigateToURL("http://www.google.com")
TEST=None
BUG=None
Review URL: http://codereview.chromium.org/805001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/pyautolib/pyauto.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index 636552a..8e1db78 100644 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -40,6 +40,9 @@ _LocateBinDirs() try: import pyautolib + # Needed so that all additional classes (like: FilePath, GURL) exposed by + # swig interface get available in this module. + from pyautolib import * except ImportError: print >>sys.stderr, "Could not locate built libraries. Did you build?" raise @@ -63,8 +66,21 @@ class PyUITest(pyautolib.PyUITestSuite, unittest.TestCase): self.assertTrue("Google" == self.GetActiveTabTitle()) """ - def __init__(self, methodName='runTest'): - pyautolib.PyUITestSuite.__init__(self, sys.argv) + def __init__(self, methodName='runTest', extra_chrome_flags=None): + """Initialize PyUITest. + + When redefining __init__ in a derived class, make sure that: + o you make a call this __init__ + o __init__ takes methodName as a arg. this is mandated by unittest module + + Args: + methodName: the default method name. Internal use by unittest module + extra_chrome_flags: additional flags to pass when launching chrome + """ + args = sys.argv + if extra_chrome_flags is not None: + args.append('--extra-chrome-flags=%s' % extra_chrome_flags) + pyautolib.PyUITestSuite.__init__(self, args) # Figure out path to chromium binaries browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__)) os.environ['PATH'] = browser_dir + os.pathsep + os.environ['PATH'] |