diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 15:42:00 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-08 15:42:00 +0000 |
commit | 7024d3eea1d8328883736f5cd3cbef480aa0e740 (patch) | |
tree | 5fc40e7da24d79306321037359bce7bd97bcf36b /chrome/test/pyautolib | |
parent | e9ff5e31b28b6ee684ceaf47afe4f483163f6d1d (diff) | |
download | chromium_src-7024d3eea1d8328883736f5cd3cbef480aa0e740.zip chromium_src-7024d3eea1d8328883736f5cd3cbef480aa0e740.tar.gz chromium_src-7024d3eea1d8328883736f5cd3cbef480aa0e740.tar.bz2 |
Remove wstring from RVH's run Javascript command.
BUG=23581
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6312154
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib')
-rw-r--r-- | chrome/test/pyautolib/pyautolib.cc | 43 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.h | 18 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.i | 18 |
3 files changed, 42 insertions, 37 deletions
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index a1da137..455574a 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 std::wstring& str) { +static int64 StringToId(const string16& str) { int64 id; - base::StringToInt64(WideToUTF8(str), &id); + base::StringToInt64(str, &id); return id; } @@ -241,19 +241,22 @@ std::string PyUITestBase::_GetBookmarksAsJSON() { return s; } -bool PyUITestBase::AddBookmarkGroup(std::wstring& parent_id, int index, - std::wstring& title) { +bool PyUITestBase::AddBookmarkGroup(const string16& parent_id, int index, + const string16& 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(std::wstring& parent_id, int index, - std::wstring& title, std::wstring& url) { +bool PyUITestBase::AddBookmarkURL(const string16& parent_id, int index, + const string16& title, + const string16& url) { scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0); // Window doesn't matter. EXPECT_TRUE(browser_proxy.get()); @@ -261,12 +264,13 @@ bool PyUITestBase::AddBookmarkURL(std::wstring& parent_id, int index, return false; return browser_proxy->AddBookmarkURL(StringToId(parent_id), - index, title, - GURL(WideToUTF8(url))); + index, + title, + GURL(UTF16ToUTF8(url))); } bool PyUITestBase::ReparentBookmark( - std::wstring& id, std::wstring& new_parent_id, int index) { + const string16& id, const string16& new_parent_id, int index) { scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0); // Window doesn't matter. EXPECT_TRUE(browser_proxy.get()); @@ -278,7 +282,7 @@ bool PyUITestBase::ReparentBookmark( index); } -bool PyUITestBase::SetBookmarkTitle(std::wstring& id, std::wstring& title) { +bool PyUITestBase::SetBookmarkTitle(const string16& id, const string16& title) { scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0); // Window doesn't matter. EXPECT_TRUE(browser_proxy.get()); @@ -288,17 +292,17 @@ bool PyUITestBase::SetBookmarkTitle(std::wstring& id, std::wstring& title) { return browser_proxy->SetBookmarkTitle(StringToId(id), title); } -bool PyUITestBase::SetBookmarkURL(std::wstring& id, std::wstring& url) { +bool PyUITestBase::SetBookmarkURL(const string16& id, const string16& 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(WideToUTF8(url))); + return browser_proxy->SetBookmarkURL(StringToId(id), GURL(UTF16ToUTF8(url))); } -bool PyUITestBase::RemoveBookmark(std::wstring& id) { +bool PyUITestBase::RemoveBookmark(const string16& id) { scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0); // Window doesn't matter. EXPECT_TRUE(browser_proxy.get()); @@ -331,18 +335,19 @@ 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 response; + return std::wstring(); scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); EXPECT_TRUE(tab_proxy.get()); if (!tab_proxy.get()) - return response; + return std::wstring(); - EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(frame_xpath, script, + string16 response; + EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(WideToUTF16Hack(frame_xpath), + WideToUTF16Hack(script), &response)); - return response; + return UTF16ToWideHack(response); } std::wstring PyUITestBase::GetDOMValue(const std::wstring& expr, diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h index a3a8e23..3abe987 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 std::wstring, not an int64, for convenience, since + // The id is a string16, 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(std::wstring& parent_id, int index, - std::wstring& title); - bool AddBookmarkURL(std::wstring& parent_id, int index, - std::wstring& title, std::wstring& url); + 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); // Bookmark editing: - bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id, + bool ReparentBookmark(const string16& id, const string16& new_parent_id, int index); - bool SetBookmarkTitle(std::wstring& id, std::wstring& title); - bool SetBookmarkURL(std::wstring& id, std::wstring& url); + bool SetBookmarkTitle(const string16& id, const string16& title); + bool SetBookmarkURL(const string16& id, const string16& url); // Finally, bookmark deletion: - bool RemoveBookmark(std::wstring& id); + bool RemoveBookmark(const string16& 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 34ad6e2..894b7e9 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 Automtion Proxy.") pyautolib +%module(docstring="Python interface to Automation 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 std::wstring& username, const std::wstring& password); + bool SetAuth(const string16& username, const string16& 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(std::wstring parent_id, int index, std::wstring title); + bool AddBookmarkGroup(string16 parent_id, int index, string16 title); %feature("docstring", "Add a bookmark with the given title and URL.") AddBookmarkURL; - bool AddBookmarkURL(std::wstring parent_id, int index, - std::wstring title, const std::wstring url); + bool AddBookmarkURL(string16 parent_id, int index, + string16 title, const string16 url); %feature("docstring", "Move a bookmark to a new parent.") ReparentBookmark; - bool ReparentBookmark(std::wstring id, std::wstring new_parent_id, int index); + bool ReparentBookmark(string16 id, string16 new_parent_id, int index); %feature("docstring", "Set the title of a bookmark.") SetBookmarkTitle; - bool SetBookmarkTitle(std::wstring id, std::wstring title); + bool SetBookmarkTitle(string16 id, string16 title); %feature("docstring", "Set the URL of a bookmark.") SetBookmarkURL; - bool SetBookmarkURL(std::wstring id, const std::wstring url); + bool SetBookmarkURL(string16 id, string16 url); %feature("docstring", "Remove (delete) a bookmark.") RemoveBookmark; - bool RemoveBookmark(std::wstring id); + bool RemoveBookmark(string16 id); %feature("docstring", "Open the Find box in the given or first browser " "window.") OpenFindInPage; |