summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authornirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 23:08:28 +0000
committernirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 23:08:28 +0000
commit93e60735dd29d8ca6028ba01decb0279d68a2ac1 (patch)
tree073d31e8f88258dc3999b0dce06df3d787269043 /chrome/test
parent9f651d04dd719ecfafe9dfbee4c742879edf4fca (diff)
downloadchromium_src-93e60735dd29d8ca6028ba01decb0279d68a2ac1.zip
chromium_src-93e60735dd29d8ca6028ba01decb0279d68a2ac1.tar.gz
chromium_src-93e60735dd29d8ca6028ba01decb0279d68a2ac1.tar.bz2
Expose more functionality to pyauto
Additions include some low-hanging fruits: - create tabs - activate a tab by index - apply any accelerator (like IDC_BACK, IDC_REFRESH) - install and load an extension Review URL: http://codereview.chromium.org/647006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/pyautolib/pyautolib.cc22
-rw-r--r--chrome/test/pyautolib/pyautolib.h17
-rw-r--r--chrome/test/pyautolib/pyautolib.i29
3 files changed, 65 insertions, 3 deletions
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 0e19b90..8465e39 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -30,6 +30,24 @@ void PyUITestSuite::NavigateToURL(const char* url_string) {
UITestBase::NavigateToURL(url);
}
+bool PyUITestSuite::AppendTab(const GURL& tab_url, int window_index) {
+ scoped_refptr<BrowserProxy> browser_proxy =
+ automation()->GetBrowserWindow(window_index);
+ return browser_proxy->AppendTab(tab_url);
+}
+
+bool PyUITestSuite::ApplyAccelerator(int id, int window_index) {
+ scoped_refptr<BrowserProxy> browser_proxy =
+ automation()->GetBrowserWindow(window_index);
+ return browser_proxy->ApplyAccelerator(id);
+}
+
+bool PyUITestSuite::ActivateTab(int tab_index, int window_index) {
+ scoped_refptr<BrowserProxy> browser_proxy =
+ automation()->GetBrowserWindow(window_index);
+ return browser_proxy->ActivateTab(tab_index);
+}
+
void PyUITestSuite::SetShelfVisible(bool is_visible) {
scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0);
ASSERT_TRUE(browser_proxy.get());
@@ -80,3 +98,7 @@ bool PyUITestSuite::OpenNewBrowserWindow(bool show) {
return automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, show);
}
+bool PyUITestSuite::InstallExtension(const FilePath& crx_file) {
+ return automation()->InstallExtension(crx_file);
+}
+
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 20e0679..5d1b77c 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -37,6 +37,19 @@ class PyUITestSuite : public UITestSuite, public UITestBase {
// Shows or hides the download shelf.
void SetShelfVisible(bool is_visible);
+ // Appends a new tab with the given URL in the given or first browser window.
+ bool AppendTab(const GURL& tab_url, int window_index = 0);
+
+ // Activate the tab at the given zero-based index in the given or first
+ // browser window.
+ bool ActivateTab(int tab_index, int window_index = 0);
+
+ // Apply the accelerator with given id (IDC_BACK, IDC_NEWTAB ...) to the
+ // browser window at the given or first index.
+ // The list can be found at chrome/app/chrome_dll_resource.h
+ // Returns true if the call was successful.
+ bool ApplyAccelerator(int id, int window_index = 0);
+
// Determines the visibility of the download shelf
bool IsShelfVisible();
@@ -54,6 +67,10 @@ class PyUITestSuite : public UITestSuite, public UITestBase {
// Open a new browser window. Returns false on failure.
bool OpenNewBrowserWindow(bool show);
+ // Installs the extension crx. Returns true only if extension was installed
+ // and loaded successfully. Overinstalls will fail.
+ bool InstallExtension(const FilePath& crx_file);
+
private:
base::ScopedNSAutoreleasePool pool_;
};
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index 7136f01..0b8781e 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -49,10 +49,13 @@
if ($2) free($2);
}
+%include "chrome/app/chrome_dll_resource.h"
+
%feature("docstring", "Represent a URL. Call spec() to get the string.") GURL;
class GURL {
public:
GURL();
+ explicit GURL(const std::string& url_string);
%feature("docstring", "Get the string representation.") spec;
const std::string& spec() const;
};
@@ -61,13 +64,17 @@ class GURL {
"Represent a file path. Call value() to get the string.") FilePath;
class FilePath {
public:
- FilePath();
%feature("docstring", "Get the string representation.") value;
#ifdef SWIGWIN
- const std::wstring& value() const;
+ typedef std::wstring StringType;
#else
- const std::string& value() const;
+ typedef std::string StringType;
#endif // OS_WIN
+ const StringType& value() const;
+ %feature("docstring", "Construct an empty FilePath or from a string.")
+ FilePath;
+ FilePath();
+ explicit FilePath(const StringType& path);
};
class PyUITestSuite {
@@ -88,6 +95,19 @@ class PyUITestSuite {
// BrowserProxy methods
%feature("docstring", "Set download shelf visibility.") SetShelfVisible;
void SetShelfVisible(bool is_visible);
+ %feature("docstring", "Create a new tab at the end of given or first browser "
+ "window and activate it. Blocks until the page is loaded. "
+ "Returns True on success.") AppendTab;
+ bool AppendTab(const GURL& tab_url, int window_index=0);
+ %feature("docstring", "Activate the tab at the given zero-based index in "
+ "the given or first window. Returns True on success.") ActivateTab;
+ bool ActivateTab(int tab_index, int window_index=0);
+ %feature("docstring", "Apply the accelerator with given id "
+ "(IDC_BACK, IDC_NEWTAB ...) to the given or first window. "
+ "The list can be found at chrome/app/chrome_dll_resource.h. "
+ "Returns True on success.")
+ ApplyAccelerator;
+ bool ApplyAccelerator(int id, int window_index=0);
// TabProxy methods
%feature("docstring",
@@ -105,6 +125,9 @@ class PyUITestSuite {
// AutomationProxy methods
%feature("docstring", "Open a new browser window.") OpenNewBrowserWindow;
bool OpenNewBrowserWindow(bool show);
+ %feature("docstring", "Install an extension from the given file. Returns "
+ "True if successfully installed and loaded.") InstallExtension;
+ bool InstallExtension(const FilePath& crx_file);
// UITestBase methods
%feature("docstring", "Path to download directory.") user_data_dir;