summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 18:27:53 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 18:27:53 +0000
commit6d8ffc9f70711222db4aaaca570be0574e88de42 (patch)
treeeafb5c341c9119e5c438025caa27dfda4902b096 /chrome/test/automation
parenta9710f39948f20b8eb3d9897a692a594374ee576 (diff)
downloadchromium_src-6d8ffc9f70711222db4aaaca570be0574e88de42.zip
chromium_src-6d8ffc9f70711222db4aaaca570be0574e88de42.tar.gz
chromium_src-6d8ffc9f70711222db4aaaca570be0574e88de42.tar.bz2
Add pyauto hooks for bookmarks.
Get model, add/remove, add folder, reparent, change title/url. BUG=34492 Review URL: http://codereview.chromium.org/792003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_messages_internal.h47
-rw-r--r--chrome/test/automation/browser_proxy.cc89
-rw-r--r--chrome/test/automation/browser_proxy.h19
3 files changed, 155 insertions, 0 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 26aabfc..c01df68 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1230,4 +1230,51 @@ IPC_BEGIN_MESSAGES(Automation)
bool /* Whether successful*/)
#endif
+ // Return the bookmarks encoded as a JSON string.
+ IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_GetBookmarksAsJSON,
+ int /* browser_handle */,
+ std::string /* bookmarks as a JSON string */,
+ bool /* success */)
+
+ // Wait for the bookmark model to load.
+ IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_WaitForBookmarkModelToLoad,
+ int /* browser_handle */,
+ bool /* success */)
+
+ // Bookmark addition, modification, and removal.
+ // Bookmarks are indexed by their id.
+ IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_AddBookmarkGroup,
+ int /* browser_handle */,
+ int64 /* parent_id */,
+ int /* index */,
+ std::wstring /* title */,
+ bool /* success */)
+ IPC_SYNC_MESSAGE_ROUTED5_1(AutomationMsg_AddBookmarkURL,
+ int /* browser_handle */,
+ int64 /* parent_id */,
+ int /* index */,
+ std::wstring /* title */,
+ GURL /* url */,
+ bool /* success */)
+ IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_ReparentBookmark,
+ int /* browser_handle */,
+ int64 /* id */,
+ int64 /* new_parent_id */,
+ int /* index */,
+ bool /* success */)
+ IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetBookmarkTitle,
+ int /* browser_handle */,
+ int64 /* id */,
+ std::wstring /* title */,
+ bool /* success */)
+ IPC_SYNC_MESSAGE_ROUTED3_1(AutomationMsg_SetBookmarkURL,
+ int /* browser_handle */,
+ int64 /* id */,
+ GURL /* url */,
+ bool /* success */)
+ IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_RemoveBookmark,
+ int /* browser_handle */,
+ int64 /* id */,
+ bool /* success */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 2b62b71..2411dd6 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -327,6 +327,95 @@ bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible,
0, handle_, is_visible, is_animating));
}
+bool BrowserProxy::GetBookmarksAsJSON(std::string *json_string) {
+ if (!is_valid())
+ return false;
+
+ if (!WaitForBookmarkModelToLoad())
+ return false;
+
+ bool result = false;
+ sender_->Send(new AutomationMsg_GetBookmarksAsJSON(0, handle_,
+ json_string,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::WaitForBookmarkModelToLoad() {
+ if (!is_valid())
+ return false;
+
+ bool result = false;
+ sender_->Send(new AutomationMsg_WaitForBookmarkModelToLoad(0, handle_,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::AddBookmarkGroup(int64 parent_id, int index,
+ std::wstring& title) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_AddBookmarkGroup(0, handle_,
+ parent_id, index,
+ title,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::AddBookmarkURL(int64 parent_id, int index,
+ std::wstring& title, const GURL& url) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_AddBookmarkURL(0, handle_,
+ parent_id, index,
+ title, url,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::ReparentBookmark(int64 id, int64 new_parent_id, int index) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_ReparentBookmark(0, handle_,
+ id, new_parent_id,
+ index,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::SetBookmarkTitle(int64 id, std::wstring& title) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_SetBookmarkTitle(0, handle_,
+ id, title,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::SetBookmarkURL(int64 id, const GURL& url) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_SetBookmarkURL(0, handle_,
+ id, url,
+ &result));
+ return result;
+}
+
+bool BrowserProxy::RemoveBookmark(int64 id) {
+ if (!is_valid())
+ return false;
+ bool result = false;
+ sender_->Send(new AutomationMsg_RemoveBookmark(0, handle_,
+ id,
+ &result));
+ return result;
+}
+
bool BrowserProxy::IsShelfVisible(bool* is_visible) {
if (!is_valid())
return false;
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index 939e87b..04e6288 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -181,6 +181,25 @@ class BrowserProxy : public AutomationResourceProxy {
// it into position. Returns false on failure.
bool GetBookmarkBarVisibility(bool* is_visible, bool* is_animating);
+ // Get the bookmarks as a JSON string and put it in |json_string|.
+ // Return true on success.
+ bool GetBookmarksAsJSON(std::string* json_string);
+
+ // Wait for the bookmarks to load. Called implicitly by GetBookmarksAsJSON().
+ bool WaitForBookmarkModelToLoad();
+
+ // Editing of the bookmark model. Bookmarks are referenced by id.
+ // Bookmark or group (folder) creation:
+ bool AddBookmarkGroup(int64 parent_id, int index, std::wstring& title);
+ bool AddBookmarkURL(int64 parent_id, int index,
+ std::wstring& title, const GURL& url);
+ // Bookmark editing:
+ bool ReparentBookmark(int64 id, int64 new_parent_id, int index);
+ bool SetBookmarkTitle(int64 id, std::wstring& title);
+ bool SetBookmarkURL(int64 id, const GURL& url);
+ // Finally, bookmark deletion:
+ bool RemoveBookmark(int64 id);
+
// Fills |*is_visible| with whether the browser's download shelf is currently
// visible. The return value indicates success. On failure, |*is_visible| is
// unchanged.