summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/pyautolib/pyauto.py20
-rw-r--r--chrome/test/pyautolib/pyautolib.cc5
-rw-r--r--chrome/test/pyautolib/pyautolib.h5
-rw-r--r--chrome/test/pyautolib/pyautolib.i9
-rw-r--r--chrome/test/ui/ui_test.h12
5 files changed, 41 insertions, 10 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index d910489..7ddca87 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -68,7 +68,7 @@ class PyUITest(pyautolib.PyUITestSuite, unittest.TestCase):
self.assertTrue("Google" == self.GetActiveTabTitle())
"""
- def __init__(self, methodName='runTest', extra_chrome_flags=None):
+ def __init__(self, methodName='runTest', **kwargs):
"""Initialize PyUITest.
When redefining __init__ in a derived class, make sure that:
@@ -77,12 +77,24 @@ class PyUITest(pyautolib.PyUITestSuite, unittest.TestCase):
Args:
methodName: the default method name. Internal use by unittest module
- extra_chrome_flags: additional flags to pass when launching chrome
+
+ (The rest of the args can be in any order. They can even be skipped in
+ which case the defaults will be used.)
+
+ extra_chrome_flags: additional flags to pass when launching chrome.
+ Defaults to None
+ clear_profile: If True, clean the profile dir before use. Defaults to True
+ homepage: the home page. Defaults to "about:blank"
"""
+ # Fetch provided keyword args, or fill in defaults.
+ extra_chrome_flags = kwargs.get('extra_chrome_flags')
+ clear_profile = kwargs.get('clear_profile', True)
+ homepage = kwargs.get('homepage', 'about:blank')
+
args = sys.argv
- if extra_chrome_flags is not None:
+ if extra_chrome_flags:
args.append('--extra-chrome-flags=%s' % extra_chrome_flags)
- pyautolib.PyUITestSuite.__init__(self, args)
+ pyautolib.PyUITestSuite.__init__(self, args, clear_profile, homepage)
# 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']
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index f009549..14e0c8e 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -9,9 +9,12 @@
#include "chrome/test/pyautolib/pyautolib.h"
#include "googleurl/src/gurl.h"
-PyUITestSuite::PyUITestSuite(int argc, char** argv)
+PyUITestSuite::PyUITestSuite(
+ int argc, char** argv, bool clear_profile, std::wstring homepage)
: UITestSuite(argc, argv),
UITestBase() {
+ set_clear_profile(clear_profile);
+ set_homepage(homepage);
}
PyUITestSuite::~PyUITestSuite() {
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 154c97c..7e87171 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -27,7 +27,10 @@
class PyUITestSuite : public UITestSuite, public UITestBase {
public:
// Only public methods are accessible from swig.
- PyUITestSuite(int argc, char** argv);
+
+ // Constructor. Lookup pyauto.py for doc on these args.
+ PyUITestSuite(int argc, char** argv, bool clear_profile,
+ std::wstring homepage);
~PyUITestSuite();
// Initialize the setup. Should be called before launching the browser.
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index e181a71..51755bb 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -79,7 +79,8 @@ class FilePath {
class PyUITestSuite {
public:
- PyUITestSuite(int argc, char** argv);
+ PyUITestSuite(int argc, char** argv, bool clear_profile,
+ std::wstring homepage);
%feature("docstring", "Initialize the entire setup. Should be called "
"before launching the browser. For internal use.") Initialize;
@@ -130,12 +131,12 @@ class PyUITestSuite {
"given or first browser window.") IsDownloadShelfVisible;
bool IsDownloadShelfVisible(int window_index=0);
- %feature("docstring", "Determine if the bookmark bar is visible. "
+ %feature("docstring", "Determine if the bookmark bar is visible. "
"If the NTP is visible, only return true if attached "
- "(to the chrome).") GetBookmarkBarVisibility;
+ "(to the chrome).") GetBookmarkBarVisibility;
bool GetBookmarkBarVisibility();
- %feature("docstring", "Wait for the bookmark bar animation to complete. "
+ %feature("docstring", "Wait for the bookmark bar animation to complete. "
"|wait_for_open| specifies which kind of change we wait for.")
WaitForBookmarkBarVisibilityChange;
bool WaitForBookmarkBarVisibilityChange(bool wait_for_open);
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 56c7e9c..334e8b2 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -435,6 +435,18 @@ class UITestBase {
ui_test_name_ = name;
}
+ // Sets clear_profile_. Should be called before launching browser to have
+ // any effect.
+ void set_clear_profile(bool clear_profile) {
+ clear_profile_ = clear_profile;
+ }
+
+ // Sets homepage_. Should be called before launching browser to have
+ // any effect.
+ void set_homepage(const std::wstring& homepage) {
+ homepage_ = homepage;
+ }
+
// Count the number of active browser processes launched by this test.
// The count includes browser sub-processes.
int GetBrowserProcessCount();