summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 19:56:14 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 19:56:14 +0000
commita771dc3feb97ae20170cf5617ba48d6340549698 (patch)
tree2482dd2533a3341ede166407b6eb3761a28ec4e7 /chrome/test/pyautolib
parent0f786468a0c44da5093c6759915e1c0384535adf (diff)
downloadchromium_src-a771dc3feb97ae20170cf5617ba48d6340549698.zip
chromium_src-a771dc3feb97ae20170cf5617ba48d6340549698.tar.gz
chromium_src-a771dc3feb97ae20170cf5617ba48d6340549698.tar.bz2
Revert 74118 - Remove wstring from RVH's run Javascript command.
BUG=23581 TEST=no visible changes; all tests pass Review URL: http://codereview.chromium.org/6312154 TBR=avi@chromium.org Review URL: http://codereview.chromium.org/6459002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib')
-rw-r--r--chrome/test/pyautolib/pyautolib.cc43
-rw-r--r--chrome/test/pyautolib/pyautolib.h18
-rw-r--r--chrome/test/pyautolib/pyautolib.i18
3 files changed, 37 insertions, 42 deletions
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 455574a..a1da137 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -11,9 +11,9 @@
#include "chrome/test/pyautolib/pyautolib.h"
#include "googleurl/src/gurl.h"
-static int64 StringToId(const string16& str) {
+static int64 StringToId(const std::wstring& str) {
int64 id;
- base::StringToInt64(str, &id);
+ base::StringToInt64(WideToUTF8(str), &id);
return id;
}
@@ -241,22 +241,19 @@ std::string PyUITestBase::_GetBookmarksAsJSON() {
return s;
}
-bool PyUITestBase::AddBookmarkGroup(const string16& parent_id, int index,
- const string16& title) {
+bool PyUITestBase::AddBookmarkGroup(std::wstring& parent_id, int index,
+ std::wstring& title) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
if (!browser_proxy.get())
return false;
- return browser_proxy->AddBookmarkGroup(StringToId(parent_id),
- index,
- title);
+ return browser_proxy->AddBookmarkGroup(StringToId(parent_id), index, title);
}
-bool PyUITestBase::AddBookmarkURL(const string16& parent_id, int index,
- const string16& title,
- const string16& url) {
+bool PyUITestBase::AddBookmarkURL(std::wstring& parent_id, int index,
+ std::wstring& title, std::wstring& url) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
@@ -264,13 +261,12 @@ bool PyUITestBase::AddBookmarkURL(const string16& parent_id, int index,
return false;
return browser_proxy->AddBookmarkURL(StringToId(parent_id),
- index,
- title,
- GURL(UTF16ToUTF8(url)));
+ index, title,
+ GURL(WideToUTF8(url)));
}
bool PyUITestBase::ReparentBookmark(
- const string16& id, const string16& new_parent_id, int index) {
+ std::wstring& id, std::wstring& new_parent_id, int index) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
@@ -282,7 +278,7 @@ bool PyUITestBase::ReparentBookmark(
index);
}
-bool PyUITestBase::SetBookmarkTitle(const string16& id, const string16& title) {
+bool PyUITestBase::SetBookmarkTitle(std::wstring& id, std::wstring& title) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
@@ -292,17 +288,17 @@ bool PyUITestBase::SetBookmarkTitle(const string16& id, const string16& title) {
return browser_proxy->SetBookmarkTitle(StringToId(id), title);
}
-bool PyUITestBase::SetBookmarkURL(const string16& id, const string16& url) {
+bool PyUITestBase::SetBookmarkURL(std::wstring& id, std::wstring& url) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
if (!browser_proxy.get())
return false;
- return browser_proxy->SetBookmarkURL(StringToId(id), GURL(UTF16ToUTF8(url)));
+ return browser_proxy->SetBookmarkURL(StringToId(id), GURL(WideToUTF8(url)));
}
-bool PyUITestBase::RemoveBookmark(const string16& id) {
+bool PyUITestBase::RemoveBookmark(std::wstring& id) {
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(0); // Window doesn't matter.
EXPECT_TRUE(browser_proxy.get());
@@ -335,19 +331,18 @@ std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script,
scoped_refptr<BrowserProxy> browser_proxy =
automation()->GetBrowserWindow(window_index);
EXPECT_TRUE(browser_proxy.get());
+ std::wstring response;
if (!browser_proxy.get())
- return std::wstring();
+ return response;
scoped_refptr<TabProxy> tab_proxy =
browser_proxy->GetTab(tab_index);
EXPECT_TRUE(tab_proxy.get());
if (!tab_proxy.get())
- return std::wstring();
+ return response;
- string16 response;
- EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(WideToUTF16Hack(frame_xpath),
- WideToUTF16Hack(script),
+ EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(frame_xpath, script,
&response));
- return UTF16ToWideHack(response);
+ return response;
}
std::wstring PyUITestBase::GetDOMValue(const std::wstring& expr,
diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h
index 3abe987..a3a8e23 100644
--- a/chrome/test/pyautolib/pyautolib.h
+++ b/chrome/test/pyautolib/pyautolib.h
@@ -135,23 +135,23 @@ class PyUITestBase : public UITestBase {
std::string _GetBookmarksAsJSON();
// Editing of the bookmark model. Bookmarks are referenced by id.
- // The id is a string16, not an int64, for convenience, since
+ // The id is a std::wstring, not an int64, for convenience, since
// the python side gets IDs converted from a JSON representation
// (which "extracts" into a string, not an int). Since IDs are
// grabbed from the current model (and not generated), a conversion
// is unnecessary. URLs are strings and not GURLs for a similar reason.
// Bookmark or group (folder) creation:
- bool AddBookmarkGroup(const string16& parent_id, int index,
- const string16& title);
- bool AddBookmarkURL(const string16& parent_id, int index,
- const string16& title, const string16& url);
+ bool AddBookmarkGroup(std::wstring& parent_id, int index,
+ std::wstring& title);
+ bool AddBookmarkURL(std::wstring& parent_id, int index,
+ std::wstring& title, std::wstring& url);
// Bookmark editing:
- bool ReparentBookmark(const string16& id, const string16& new_parent_id,
+ bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id,
int index);
- bool SetBookmarkTitle(const string16& id, const string16& title);
- bool SetBookmarkURL(const string16& id, const string16& url);
+ bool SetBookmarkTitle(std::wstring& id, std::wstring& title);
+ bool SetBookmarkURL(std::wstring& id, std::wstring& url);
// Finally, bookmark deletion:
- bool RemoveBookmark(const string16& id);
+ bool RemoveBookmark(std::wstring& id);
// Get a handle to browser window at the given index, or NULL on failure.
scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index);
diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i
index 894b7e9..34ad6e2 100644
--- a/chrome/test/pyautolib/pyautolib.i
+++ b/chrome/test/pyautolib/pyautolib.i
@@ -14,7 +14,7 @@
// 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 Automation Proxy.") pyautolib
+%module(docstring="Python interface to Automtion Proxy.") pyautolib
%feature("autodoc", "1");
%include <std_wstring.i>
@@ -152,7 +152,7 @@ class TabProxy {
%feature("docstring", "Supply authentication to a login prompt. "
"Blocks until navigation completes or another login prompt appears "
"in the case of failed auth.") SetAuth;
- bool SetAuth(const string16& username, const string16& password);
+ bool SetAuth(const std::wstring& username, const std::wstring& password);
%feature("docstring", "Cancel authentication to a login prompt. ")
CancelAuth;
bool CancelAuth();
@@ -277,23 +277,23 @@ class PyUITestBase {
%feature("docstring", "Add a bookmark folder with the given index in the parent."
" |title| is the title/name of the folder.") AddBookmarkGroup;
- bool AddBookmarkGroup(string16 parent_id, int index, string16 title);
+ bool AddBookmarkGroup(std::wstring parent_id, int index, std::wstring title);
%feature("docstring", "Add a bookmark with the given title and URL.") AddBookmarkURL;
- bool AddBookmarkURL(string16 parent_id, int index,
- string16 title, const string16 url);
+ bool AddBookmarkURL(std::wstring parent_id, int index,
+ std::wstring title, const std::wstring url);
%feature("docstring", "Move a bookmark to a new parent.") ReparentBookmark;
- bool ReparentBookmark(string16 id, string16 new_parent_id, int index);
+ bool ReparentBookmark(std::wstring id, std::wstring new_parent_id, int index);
%feature("docstring", "Set the title of a bookmark.") SetBookmarkTitle;
- bool SetBookmarkTitle(string16 id, string16 title);
+ bool SetBookmarkTitle(std::wstring id, std::wstring title);
%feature("docstring", "Set the URL of a bookmark.") SetBookmarkURL;
- bool SetBookmarkURL(string16 id, string16 url);
+ bool SetBookmarkURL(std::wstring id, const std::wstring url);
%feature("docstring", "Remove (delete) a bookmark.") RemoveBookmark;
- bool RemoveBookmark(string16 id);
+ bool RemoveBookmark(std::wstring id);
%feature("docstring", "Open the Find box in the given or first browser "
"window.") OpenFindInPage;