summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/pyautolib/pyauto.py2
-rw-r--r--chrome/test/pyautolib/pyautolib.cc24
-rw-r--r--chrome/test/pyautolib/pyautolib.h12
-rw-r--r--chrome/test/pyautolib/pyautolib.i70
-rw-r--r--chrome/test/ui/ui_test.h1
5 files changed, 95 insertions, 14 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 52f477e..4fee17c 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -39,7 +39,7 @@ def _LocateBinDirs():
_LocateBinDirs()
try:
- from pyautolib import PyUITestSuite
+ from pyautolib import *
except ImportError:
print >>sys.stderr, "Could not locate built libraries. Did you build?"
raise
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index a891e8e..0e19b90 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -46,14 +46,8 @@ bool PyUITestSuite::IsShelfVisible() {
return visible;
}
-std::wstring PyUITestSuite::GetActiveTabTitle() {
- std::wstring title;
- scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
- EXPECT_TRUE(tab_proxy.get());
- if (!tab_proxy.get())
- return title;
- EXPECT_TRUE(tab_proxy->GetTabTitle(&title));
- return title;
+GURL PyUITestSuite::GetActiveTabURL() {
+ return UITestBase::GetActiveTabURL();
}
void PyUITestSuite::OpenFindInPage() {
@@ -72,3 +66,17 @@ bool PyUITestSuite::IsFindInPageVisible() {
return is_visible;
}
+std::string PyUITestSuite::GetDownloadDirectory() {
+ FilePath download_dir;
+ scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
+ EXPECT_TRUE(tab_proxy.get());
+ if (!tab_proxy.get())
+ return download_dir.value();
+ EXPECT_TRUE(tab_proxy->GetDownloadDirectory(&download_dir));
+ return download_dir.value();
+}
+
+bool PyUITestSuite::OpenNewBrowserWindow(bool show) {
+ return automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, show);
+}
+
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 04fe7a8..20e0679 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -29,8 +29,8 @@ class PyUITestSuite : public UITestSuite, public UITestBase {
void NavigateToURL(const char* url_string);
- // Get the title of the active tab. Empty string in case of error.
- std::wstring GetActiveTabTitle();
+ // Get the URL of the active tab.
+ GURL GetActiveTabURL();
// BrowserProxy methods
@@ -46,6 +46,14 @@ class PyUITestSuite : public UITestSuite, public UITestBase {
// Determines the visibility of the Find box
bool IsFindInPageVisible();
+ // Get the path to the downloads directory
+ std::string GetDownloadDirectory();
+
+ // AutomationProxy methods
+
+ // Open a new browser window. Returns false on failure.
+ bool OpenNewBrowserWindow(bool show);
+
private:
base::ScopedNSAutoreleasePool pool_;
};
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index 83854c0..7136f01 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -9,7 +9,13 @@
// swig -python -c++ chrome/test/pyautolib/pyautolib.i
// would generate pyautolib.py, pyautolib_wrap.cxx
-%module pyautolib
+// When adding a new class or method, make sure you specify the doc string using
+// %feature("docstring", "doc string goes here") NODENAME;
+// and attach it to your node (class or method). This doc string will be
+// copied over in the generated python classes/methods.
+
+%module(docstring="Python interface to Automtion Proxy.") pyautolib
+%feature("autodoc", "1");
%include "std_string.i"
%include "std_wstring.i"
@@ -43,21 +49,79 @@
if ($2) free($2);
}
+%feature("docstring", "Represent a URL. Call spec() to get the string.") GURL;
+class GURL {
+ public:
+ GURL();
+ %feature("docstring", "Get the string representation.") spec;
+ const std::string& spec() const;
+};
+
+%feature("docstring",
+ "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;
+#else
+ const std::string& value() const;
+#endif // OS_WIN
+};
-// TODO(nirnimesh): Fill in the autodoc constructs - crbug.com/32287
class PyUITestSuite {
public:
PyUITestSuite(int argc, char** argv);
+ %feature("docstring",
+ "Fires up the browser and opens a window.") SetUp;
virtual void SetUp();
+ %feature("docstring",
+ "Closes all windows and destroys the browser.") TearDown;
virtual void TearDown();
+ %feature("docstring", "Navigate to the given url in the active tab. "
+ "Blocks until page has loaded.") NavigateToURL;
void NavigateToURL(const char* url_string);
- std::wstring GetActiveTabTitle();
// BrowserProxy methods
+ %feature("docstring", "Set download shelf visibility.") SetShelfVisible;
void SetShelfVisible(bool is_visible);
+
+ // TabProxy methods
+ %feature("docstring",
+ "Determine if the download shelf is visible.") IsShelfVisible;
bool IsShelfVisible();
+ %feature("docstring", "Open the Find box.") OpenFindInPage;
void OpenFindInPage();
+ %feature("docstring",
+ "Determine if the find box is visible.") IsFindInPageVisible;
bool IsFindInPageVisible();
+ %feature("docstring",
+ "Get the path to download directory.") GetDownloadDirectory;
+ std::string GetDownloadDirectory();
+
+ // AutomationProxy methods
+ %feature("docstring", "Open a new browser window.") OpenNewBrowserWindow;
+ bool OpenNewBrowserWindow(bool show);
+
+ // UITestBase methods
+ %feature("docstring", "Path to download directory.") user_data_dir;
+ FilePath user_data_dir() const;
+ %feature("docstring", "Get the index of the active tab.") GetActiveTabIndex;
+ int GetActiveTabIndex();
+ %feature("docstring", "Get the title of the active tab.") GetActiveTabTitle;
+ std::wstring GetActiveTabTitle();
+ %feature("docstring", "Get the URL for the active tab. "
+ "Returns an instance of GURL") GetActiveTabURL;
+ GURL GetActiveTabURL();
+ %feature("docstring", "Determine if the browser is running. "
+ "Returns False if user closed the window or if the browser died")
+ IsBrowserRunning;
+ bool IsBrowserRunning();
+ %feature("docstring",
+ "Count of the number of tabs in the front window.") GetTabCount;
+ int GetTabCount();
};
+
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 48b1b90..362f7dc 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -66,6 +66,7 @@ class UITestBase {
// Set up the test time out values.
virtual void InitializeTimeouts();
+ public:
// ********* Utility functions *********
// Launches the browser and IPC testing server.