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

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

Issue 1007007: PyAuto: Flags to forbid cleaning profile dir... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyautolib.h » ('j') | chrome/test/pyautolib/pyautolib.h » ('J')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 Example: 62 Example:
63 63
64 class MyTest(PyUITest): 64 class MyTest(PyUITest):
65 65
66 def testNavigation(self): 66 def testNavigation(self):
67 self.NavigateToURL("http://www.google.com") 67 self.NavigateToURL("http://www.google.com")
68 self.assertTrue("Google" == self.GetActiveTabTitle()) 68 self.assertTrue("Google" == self.GetActiveTabTitle())
69 """ 69 """
70 70
71 def __init__(self, methodName='runTest', extra_chrome_flags=None): 71 def __init__(self, methodName='runTest', **kwargs):
72 """Initialize PyUITest. 72 """Initialize PyUITest.
73 73
74 When redefining __init__ in a derived class, make sure that: 74 When redefining __init__ in a derived class, make sure that:
75 o you make a call this __init__ 75 o you make a call this __init__
76 o __init__ takes methodName as a arg. this is mandated by unittest module 76 o __init__ takes methodName as a arg. this is mandated by unittest module
77 77
78 Args: 78 Args:
79 methodName: the default method name. Internal use by unittest module 79 methodName: the default method name. Internal use by unittest module
80 extra_chrome_flags: additional flags to pass when launching chrome 80
81 (The rest of the args can be in any order. They can even be skipped in
82 which case the defaults will be used.)
83
84 extra_chrome_flags: additional flags to pass when launching chrome.
85 Defaults to None
86 clear_profile: If True, clean the profile dir before use. Defaults to True
87 homepage: the home page. Defaults to "about:blank"
81 """ 88 """
89 # Fetch provided keyword args, or fill in defaults.
90 extra_chrome_flags = kwargs.get('extra_chrome_flags')
91 clear_profile = kwargs.get('clear_profile', True)
92 homepage = kwargs.get('homepage', 'about:blank')
93
82 args = sys.argv 94 args = sys.argv
83 if extra_chrome_flags is not None: 95 if extra_chrome_flags is not None:
John Grabowski 2010/03/17 01:18:56 "if extra chrome flags:" (no need for "is not None
84 args.append('--extra-chrome-flags=%s' % extra_chrome_flags) 96 args.append('--extra-chrome-flags=%s' % extra_chrome_flags)
85 pyautolib.PyUITestSuite.__init__(self, args) 97 pyautolib.PyUITestSuite.__init__(self, args, clear_profile, homepage)
86 # Figure out path to chromium binaries 98 # Figure out path to chromium binaries
87 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__)) 99 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__))
88 os.environ['PATH'] = browser_dir + os.pathsep + os.environ['PATH'] 100 os.environ['PATH'] = browser_dir + os.pathsep + os.environ['PATH']
89 self.Initialize(pyautolib.FilePath(browser_dir)) 101 self.Initialize(pyautolib.FilePath(browser_dir))
90 unittest.TestCase.__init__(self, methodName) 102 unittest.TestCase.__init__(self, methodName)
91 103
92 def __del__(self): 104 def __del__(self):
93 pyautolib.PyUITestSuite.__del__(self) 105 pyautolib.PyUITestSuite.__del__(self)
94 106
95 def run(self, result=None): 107 def run(self, result=None):
96 """The main run method. 108 """The main run method.
97 109
98 We override this method to make calls to the setup steps in PyUITestSuite. 110 We override this method to make calls to the setup steps in PyUITestSuite.
99 """ 111 """
100 self.SetUp() # Open a browser window 112 self.SetUp() # Open a browser window
101 unittest.TestCase.run(self, result) 113 unittest.TestCase.run(self, result)
102 self.TearDown() # Destroy the browser window 114 self.TearDown() # Destroy the browser window
103 115
104 def GetBookmarkModel(self): 116 def GetBookmarkModel(self):
105 """Return the bookmark model as a BookmarkModel object. 117 """Return the bookmark model as a BookmarkModel object.
106 118
107 This is a snapshot of the bookmark model; it is not a proxy and 119 This is a snapshot of the bookmark model; it is not a proxy and
108 does not get updated as the bookmark model changes. 120 does not get updated as the bookmark model changes.
109 """ 121 """
110 return bookmark_model.BookmarkModel(self._GetBookmarksAsJSON()) 122 return bookmark_model.BookmarkModel(self._GetBookmarksAsJSON())
OLDNEW
« no previous file with comments | « no previous file | chrome/test/pyautolib/pyautolib.h » ('j') | chrome/test/pyautolib/pyautolib.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698