diff options
author | craigdh@chromium.org <craigdh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:59:03 +0000 |
---|---|---|
committer | craigdh@chromium.org <craigdh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 22:59:03 +0000 |
commit | 9329d68c95459fd0089bf66d4b6cbe5b046b882d (patch) | |
tree | 115a4c092a6274f1618684115e8e0fb0da0f81e0 /chrome | |
parent | d1198fdc8cced343476dbe03ebe108fd44d85309 (diff) | |
download | chromium_src-9329d68c95459fd0089bf66d4b6cbe5b046b882d.zip chromium_src-9329d68c95459fd0089bf66d4b6cbe5b046b882d.tar.gz chromium_src-9329d68c95459fd0089bf66d4b6cbe5b046b882d.tar.bz2 |
Final set of conversions of automation calls to the JSON interface.
Converts the old bookmark automation commands.
TEST=PyAuto CONTINUOUS suite
BUG=132794
Review URL: https://chromiumcodereview.appspot.com/10828245
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151380 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 21 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.h | 6 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 461 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.h | 50 | ||||
-rw-r--r-- | chrome/common/automation_messages_internal.h | 14 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 103 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 29 | ||||
-rwxr-xr-x | chrome/test/pyautolib/pyauto.py | 293 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.cc | 137 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.h | 44 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.i | 53 | ||||
-rw-r--r-- | chrome/test/reliability/automated_ui_test_base.cc | 21 | ||||
-rw-r--r-- | chrome/test/reliability/automated_ui_test_base.h | 4 | ||||
-rw-r--r-- | chrome/test/reliability/automated_ui_tests.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 21 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 6 |
16 files changed, 612 insertions, 653 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 1c9d97d..4f7b70a 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1402,10 +1402,12 @@ AutomationProviderBookmarkModelObserver:: AutomationProviderBookmarkModelObserver( AutomationProvider* provider, IPC::Message* reply_message, - BookmarkModel* model) + BookmarkModel* model, + bool use_json_interface) : automation_provider_(provider->AsWeakPtr()), reply_message_(reply_message), - model_(model) { + model_(model), + use_json_interface_(use_json_interface) { model_->AddObserver(this); } @@ -1424,11 +1426,20 @@ void AutomationProviderBookmarkModelObserver::BookmarkModelBeingDeleted( ReplyAndDelete(false); } +IPC::Message* AutomationProviderBookmarkModelObserver::ReleaseReply() { + return reply_message_.release(); +} + void AutomationProviderBookmarkModelObserver::ReplyAndDelete(bool success) { if (automation_provider_) { - AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( - reply_message_.get(), success); - automation_provider_->Send(reply_message_.release()); + if (use_json_interface_) { + AutomationJSONReply(automation_provider_, + reply_message_.release()).SendSuccess(NULL); + } else { + AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( + reply_message_.get(), success); + automation_provider_->Send(reply_message_.release()); + } } delete this; } diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 8e1d904..5b1983f 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -1045,7 +1045,8 @@ class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { public: AutomationProviderBookmarkModelObserver(AutomationProvider* provider, IPC::Message* reply_message, - BookmarkModel* model); + BookmarkModel* model, + bool use_json_interface); virtual ~AutomationProviderBookmarkModelObserver(); // BookmarkModelObserver: @@ -1071,6 +1072,8 @@ class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { BookmarkModel* model, const BookmarkNode* node) OVERRIDE {} + IPC::Message* ReleaseReply(); + private: // Reply to the automation message with the given success value, // then delete myself (which removes myself from the bookmark model @@ -1080,6 +1083,7 @@ class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { base::WeakPtr<AutomationProvider> automation_provider_; scoped_ptr<IPC::Message> reply_message_; BookmarkModel* model_; + bool use_json_interface_; DISALLOW_COPY_AND_ASSIGN(AutomationProviderBookmarkModelObserver); }; diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 0ca507c..4758ec8 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -409,24 +409,8 @@ bool TestingAutomationProvider::OnMessageReceived( IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, GetFindWindowVisibility) - IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, - GetBookmarkBarVisibility) - IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, - GetBookmarksAsJSON) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, WaitForBookmarkModelToLoad) - IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, - AddBookmarkGroup) - IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkURL, - AddBookmarkURL) - IPC_MESSAGE_HANDLER(AutomationMsg_ReparentBookmark, - ReparentBookmark) - IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkTitle, - SetBookmarkTitle) - IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkURL, - SetBookmarkURL) - IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBookmark, - RemoveBookmark) IPC_MESSAGE_HANDLER_DELAY_REPLY( AutomationMsg_WaitForBrowserWindowCountToBecome, WaitForBrowserWindowCountToBecome) @@ -1270,44 +1254,53 @@ void TestingAutomationProvider::GetFindWindowVisibility(int handle, // Bookmark bar visibility is based on the pref (e.g. is it in the toolbar). // Presence in the NTP is signalled in |detached|. -void TestingAutomationProvider::GetBookmarkBarVisibility(int handle, - bool* visible, - bool* animating, - bool* detached) { - *visible = false; - *animating = false; - - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - // browser->window()->IsBookmarkBarVisible() is not consistent across - // platforms. bookmark_bar_state() also follows prefs::kShowBookmarkBar - // and has a shared implementation on all platforms. - *visible = browser->bookmark_bar_state() == BookmarkBar::SHOW; - *animating = browser->window()->IsBookmarkBarAnimating(); - *detached = browser->bookmark_bar_state() == BookmarkBar::DETACHED; - } +void TestingAutomationProvider::GetBookmarkBarStatus( + DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } + // browser->window()->IsBookmarkBarVisible() is not consistent across + // platforms. bookmark_bar_state() also follows prefs::kShowBookmarkBar + // and has a shared implementation on all platforms. + DictionaryValue dict; + dict.SetBoolean("visible", + browser->bookmark_bar_state() == BookmarkBar::SHOW); + dict.SetBoolean("animating", browser->window()->IsBookmarkBarAnimating()); + dict.SetBoolean("detached", + browser->bookmark_bar_state() == BookmarkBar::DETACHED); + reply.SendSuccess(&dict); } void TestingAutomationProvider::GetBookmarksAsJSON( - int handle, - std::string* bookmarks_as_json, - bool* success) { - *success = false; - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* bookmark_model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!bookmark_model->IsLoaded()) { - return; - } - scoped_refptr<BookmarkStorage> storage(new BookmarkStorage( - browser->profile(), bookmark_model)); - *success = storage->SerializeData(bookmarks_as_json); - } + DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg, bookmarks_as_json; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } + BookmarkModel* bookmark_model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!bookmark_model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + scoped_refptr<BookmarkStorage> storage( + new BookmarkStorage(browser->profile(), bookmark_model)); + if (!storage->SerializeData(&bookmarks_as_json)) { + reply.SendError("Failed to serialize bookmarks"); + return; + } + DictionaryValue dict; + dict.SetString("bookmarks_as_json", bookmarks_as_json); + reply.SendSuccess(&dict); } void TestingAutomationProvider::WaitForBookmarkModelToLoad( @@ -1317,173 +1310,239 @@ void TestingAutomationProvider::WaitForBookmarkModelToLoad( Browser* browser = browser_tracker_->GetResource(handle); BookmarkModel* model = BookmarkModelFactory::GetForProfile(browser->profile()); + AutomationProviderBookmarkModelObserver* observer = + new AutomationProviderBookmarkModelObserver(this, reply_message, + model, false); if (model->IsLoaded()) { + observer->ReleaseReply(); + delete observer; AutomationMsg_WaitForBookmarkModelToLoad::WriteReplyParams( reply_message, true); Send(reply_message); - } else { - // The observer will delete itself when done. - new AutomationProviderBookmarkModelObserver(this, reply_message, - model); } } } -void TestingAutomationProvider::AddBookmarkGroup(int handle, - int64 parent_id, - int index, - std::wstring title, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* parent = model->GetNodeByID(parent_id); - DCHECK(parent); - if (parent) { - const BookmarkNode* child = model->AddFolder(parent, index, - WideToUTF16Hack(title)); - DCHECK(child); - if (child) - *success = true; - } - } +void TestingAutomationProvider::WaitForBookmarkModelToLoadJSON( + DictionaryValue* args, + IPC::Message* reply_message) { + Browser* browser; + std::string error_msg, bookmarks_as_json; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + AutomationJSONReply(this, reply_message).SendError(error_msg); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + AutomationProviderBookmarkModelObserver* observer = + new AutomationProviderBookmarkModelObserver(this, reply_message, model, + true); + if (model->IsLoaded()) { + observer->ReleaseReply(); + delete observer; + AutomationJSONReply(this, reply_message).SendSuccess(NULL); + return; } - *success = false; } -void TestingAutomationProvider::AddBookmarkURL(int handle, - int64 parent_id, - int index, - std::wstring title, - const GURL& url, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* parent = model->GetNodeByID(parent_id); - DCHECK(parent); - if (parent) { - const BookmarkNode* child = model->AddURL(parent, index, - WideToUTF16Hack(title), url); - DCHECK(child); - if (child) - *success = true; - } - } +void TestingAutomationProvider::AddBookmark( + DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg, url; + string16 title; + int parent_id, index; + bool folder; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } - *success = false; + if (!args->GetBoolean("is_folder", &folder)) { + reply.SendError("'is_folder' missing or invalid"); + return; + } + if (!folder && !args->GetString("url", &url)) { + reply.SendError("'url' missing or invalid"); + return; + } + if (!args->GetInteger("parent_id", &parent_id)) { + reply.SendError("'parent_id' missing or invalid"); + return; + } + if (!args->GetInteger("index", &index)) { + reply.SendError("'index' missing or invalid"); + return; + } + if (!args->GetString("title", &title)) { + reply.SendError("'title' missing or invalid"); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + const BookmarkNode* parent = model->GetNodeByID(parent_id); + if (!parent) { + reply.SendError("Failed to get parent bookmark node"); + return; + } + const BookmarkNode* child; + if (folder) { + child = model->AddFolder(parent, index, title); + } else { + child = model->AddURL(parent, index, title, GURL(url)); + } + if (!child) { + reply.SendError("Failed to add bookmark"); + return; + } + reply.SendSuccess(NULL); } -void TestingAutomationProvider::ReparentBookmark(int handle, - int64 id, - int64 new_parent_id, - int index, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* node = model->GetNodeByID(id); - DCHECK(node); - const BookmarkNode* new_parent = model->GetNodeByID(new_parent_id); - DCHECK(new_parent); - if (node && new_parent) { - model->Move(node, new_parent, index); - *success = true; - } - } +void TestingAutomationProvider::ReparentBookmark(DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg; + int new_parent_id, id, index; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } - *success = false; + if (!args->GetInteger("id", &id)) { + reply.SendError("'id' missing or invalid"); + return; + } + if (!args->GetInteger("new_parent_id", &new_parent_id)) { + reply.SendError("'new_parent_id' missing or invalid"); + return; + } + if (!args->GetInteger("index", &index)) { + reply.SendError("'index' missing or invalid"); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + const BookmarkNode* node = model->GetNodeByID(id); + const BookmarkNode* new_parent = model->GetNodeByID(new_parent_id); + if (!node) { + reply.SendError("Failed to get bookmark node"); + return; + } + if (!new_parent) { + reply.SendError("Failed to get new parent bookmark node"); + return; + } + model->Move(node, new_parent, index); + reply.SendSuccess(NULL); } -void TestingAutomationProvider::SetBookmarkTitle(int handle, - int64 id, - std::wstring title, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* node = model->GetNodeByID(id); - DCHECK(node); - if (node) { - model->SetTitle(node, WideToUTF16Hack(title)); - *success = true; - } - } +void TestingAutomationProvider::SetBookmarkTitle(DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg; + string16 title; + int id; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } - *success = false; + if (!args->GetInteger("id", &id)) { + reply.SendError("'id' missing or invalid"); + return; + } + if (!args->GetString("title", &title)) { + reply.SendError("'title' missing or invalid"); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + const BookmarkNode* node = model->GetNodeByID(id); + if (!node) { + reply.SendError("Failed to get bookmark node"); + return; + } + model->SetTitle(node, title); + reply.SendSuccess(NULL); } -void TestingAutomationProvider::SetBookmarkURL(int handle, - int64 id, - const GURL& url, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* node = model->GetNodeByID(id); - DCHECK(node); - if (node) { - model->SetURL(node, url); - *success = true; - } - } +void TestingAutomationProvider::SetBookmarkURL(DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg, url; + int id; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } - *success = false; + if (!args->GetInteger("id", &id)) { + reply.SendError("'id' missing or invalid"); + return; + } + if (!args->GetString("url", &url)) { + reply.SendError("'url' missing or invalid"); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + const BookmarkNode* node = model->GetNodeByID(id); + if (!node) { + reply.SendError("Failed to get bookmark node"); + return; + } + model->SetURL(node, GURL(url)); + reply.SendSuccess(NULL); } -void TestingAutomationProvider::RemoveBookmark(int handle, - int64 id, - bool* success) { - if (browser_tracker_->ContainsHandle(handle)) { - Browser* browser = browser_tracker_->GetResource(handle); - if (browser) { - BookmarkModel* model = - BookmarkModelFactory::GetForProfile(browser->profile()); - if (!model->IsLoaded()) { - *success = false; - return; - } - const BookmarkNode* node = model->GetNodeByID(id); - DCHECK(node); - if (node) { - const BookmarkNode* parent = node->parent(); - DCHECK(parent); - model->Remove(parent, parent->GetIndexOf(node)); - *success = true; - } - } +void TestingAutomationProvider::RemoveBookmark(DictionaryValue* args, + IPC::Message* reply_message) { + AutomationJSONReply reply(this, reply_message); + Browser* browser; + std::string error_msg; + int id; + if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { + reply.SendError(error_msg); + return; } - *success = false; + if (!args->GetInteger("id", &id)) { + reply.SendError("'id' missing or invalid"); + return; + } + BookmarkModel* model = + BookmarkModelFactory::GetForProfile(browser->profile()); + if (!model->IsLoaded()) { + reply.SendError("Bookmark model is not loaded"); + return; + } + const BookmarkNode* node = model->GetNodeByID(id); + if (!node) { + reply.SendError("Failed to get bookmark node"); + return; + } + const BookmarkNode* parent = node->parent(); + if (!parent) { + reply.SendError("Failed to get parent bookmark node"); + return; + } + model->Remove(parent, parent->GetIndexOf(node)); + reply.SendSuccess(NULL); } void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( @@ -1612,6 +1671,24 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() { &TestingAutomationProvider::DeleteCookieInBrowserContext; handler_map_["SetCookieInBrowserContext"] = &TestingAutomationProvider::SetCookieInBrowserContext; + + handler_map_["WaitForBookmarkModelToLoad"] = + &TestingAutomationProvider::WaitForBookmarkModelToLoadJSON; + handler_map_["GetBookmarksAsJSON"] = + &TestingAutomationProvider::GetBookmarksAsJSON; + handler_map_["GetBookmarkBarStatus"] = + &TestingAutomationProvider::GetBookmarkBarStatus; + handler_map_["AddBookmark"] = + &TestingAutomationProvider::AddBookmark; + handler_map_["ReparentBookmark"] = + &TestingAutomationProvider::ReparentBookmark; + handler_map_["SetBookmarkTitle"] = + &TestingAutomationProvider::SetBookmarkTitle; + handler_map_["SetBookmarkURL"] = + &TestingAutomationProvider::SetBookmarkURL; + handler_map_["RemoveBookmark"] = + &TestingAutomationProvider::RemoveBookmark; + handler_map_["GetTabIds"] = &TestingAutomationProvider::GetTabIds; handler_map_["GetViews"] = diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index 2f9a3eb..0500a7a 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -161,41 +161,35 @@ class TestingAutomationProvider : public AutomationProvider, // Get the visibility state of the Find window. void GetFindWindowVisibility(int handle, bool* visible); - // Get the visibility state of the Bookmark bar. - void GetBookmarkBarVisibility( - int handle, bool* visible, bool* animating, bool* detached); - - // Get the bookmarks as a JSON string. - void GetBookmarksAsJSON(int handle, std::string* bookmarks_as_json, - bool* success); - // Wait for the bookmark model to load. void WaitForBookmarkModelToLoad(int handle, IPC::Message* reply_message); // Set |loaded| to true if the bookmark model has loaded, else false. void BookmarkModelHasLoaded(int handle, bool* loaded); - // Editing, modification, and removal of bookmarks. + // Get the visibility state of the Bookmark bar. + // Returns a status dictionary over the JSON interface. + void GetBookmarkBarStatus(base::DictionaryValue* args, + IPC::Message* reply_message); + + // Get the bookmarks as a JSON string. + void GetBookmarksAsJSON(base::DictionaryValue* args, + IPC::Message* reply_message); + + // Editing, modification, and removal of bookmarks through the JSON interface. // Bookmarks are referenced by id. - void AddBookmarkGroup(int handle, - int64 parent_id, int index, std::wstring title, - bool* success); - void AddBookmarkURL(int handle, - int64 parent_id, int index, - std::wstring title, const GURL& url, - bool* success); - void ReparentBookmark(int handle, - int64 id, int64 new_parent_id, int index, - bool* success); - void SetBookmarkTitle(int handle, - int64 id, std::wstring title, - bool* success); - void SetBookmarkURL(int handle, - int64 id, const GURL& url, - bool* success); - void RemoveBookmark(int handle, - int64 id, - bool* success); + void WaitForBookmarkModelToLoadJSON(base::DictionaryValue* args, + IPC::Message* reply_message); + void AddBookmark(base::DictionaryValue* args, + IPC::Message* reply_message); + void ReparentBookmark(base::DictionaryValue* args, + IPC::Message* reply_message); + void SetBookmarkTitle(base::DictionaryValue* args, + IPC::Message* reply_message); + void SetBookmarkURL(base::DictionaryValue* args, + IPC::Message* reply_message); + void RemoveBookmark(base::DictionaryValue* args, + IPC::Message* reply_message); void WaitForBrowserWindowCountToBecome(int target_count, IPC::Message* reply_message); diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index 81c963c..268b3c1 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -801,7 +801,7 @@ IPC_MESSAGE_CONTROL5(AutomationMsg_GetCookiesHostResponse, int /* opaque_cookie_id */) // Return the bookmarks encoded as a JSON string. -IPC_SYNC_MESSAGE_CONTROL1_2(AutomationMsg_GetBookmarksAsJSON, +IPC_SYNC_MESSAGE_CONTROL1_2(AutomationMsg_DEPRECATED_GetBookmarksAsJSON, int /* browser_handle */, std::string /* bookmarks as a JSON string */, bool /* success */) @@ -813,36 +813,36 @@ IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_WaitForBookmarkModelToLoad, // Bookmark addition, modification, and removal. // Bookmarks are indexed by their id. -IPC_SYNC_MESSAGE_CONTROL4_1(AutomationMsg_AddBookmarkGroup, +IPC_SYNC_MESSAGE_CONTROL4_1(AutomationMsg_DEPRECATED_AddBookmarkGroup, int /* browser_handle */, int64 /* parent_id */, int /* index */, std::wstring /* title */, bool /* success */) -IPC_SYNC_MESSAGE_CONTROL5_1(AutomationMsg_AddBookmarkURL, +IPC_SYNC_MESSAGE_CONTROL5_1(AutomationMsg_DEPRECATED_AddBookmarkURL, int /* browser_handle */, int64 /* parent_id */, int /* index */, std::wstring /* title */, GURL /* url */, bool /* success */) -IPC_SYNC_MESSAGE_CONTROL4_1(AutomationMsg_ReparentBookmark, +IPC_SYNC_MESSAGE_CONTROL4_1(AutomationMsg_DEPRECATED_ReparentBookmark, int /* browser_handle */, int64 /* id */, int64 /* new_parent_id */, int /* index */, bool /* success */) -IPC_SYNC_MESSAGE_CONTROL3_1(AutomationMsg_SetBookmarkTitle, +IPC_SYNC_MESSAGE_CONTROL3_1(AutomationMsg_DEPRECATED_SetBookmarkTitle, int /* browser_handle */, int64 /* id */, std::wstring /* title */, bool /* success */) -IPC_SYNC_MESSAGE_CONTROL3_1(AutomationMsg_SetBookmarkURL, +IPC_SYNC_MESSAGE_CONTROL3_1(AutomationMsg_DEPRECATED_SetBookmarkURL, int /* browser_handle */, int64 /* id */, GURL /* url */, bool /* success */) -IPC_SYNC_MESSAGE_CONTROL2_1(AutomationMsg_RemoveBookmark, +IPC_SYNC_MESSAGE_CONTROL2_1(AutomationMsg_DEPRECATED_RemoveBookmark, int /* browser_handle */, int64 /* id */, bool /* success */) diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 2d6ac92a..6716da7 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -244,109 +244,6 @@ bool BrowserProxy::RunCommand(int browser_command) const { return result; } -bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible, - bool* is_animating, - bool* is_detached) { - if (!is_valid()) - return false; - - if (!is_visible || !is_animating) { - NOTREACHED(); - return false; - } - - return sender_->Send(new AutomationMsg_BookmarkBarVisibility( - handle_, is_visible, is_animating, is_detached)); -} - -bool BrowserProxy::GetBookmarksAsJSON(std::string *json_string) { - if (!is_valid()) - return false; - - if (!WaitForBookmarkModelToLoad()) - return false; - - bool result = false; - sender_->Send(new AutomationMsg_GetBookmarksAsJSON(handle_, - json_string, - &result)); - return result; -} - -bool BrowserProxy::WaitForBookmarkModelToLoad() { - if (!is_valid()) - return false; - - bool result = false; - sender_->Send(new AutomationMsg_WaitForBookmarkModelToLoad(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(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(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(handle_, - id, new_parent_id, - index, - &result)); - return result; -} - -bool BrowserProxy::SetBookmarkTitle(int64 id, const std::wstring& title) { - if (!is_valid()) - return false; - bool result = false; - sender_->Send(new AutomationMsg_SetBookmarkTitle(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(handle_, - id, url, - &result)); - return result; -} - -bool BrowserProxy::RemoveBookmark(int64 id) { - if (!is_valid()) - return false; - bool result = false; - sender_->Send(new AutomationMsg_RemoveBookmark(handle_, - id, - &result)); - return result; -} - bool BrowserProxy::TerminateSession() { if (!is_valid()) return false; diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index d20792a..44e0cd3 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -122,35 +122,6 @@ class BrowserProxy : public AutomationResourceProxy { // executed, false otherwise. bool RunCommand(int browser_command) const WARN_UNUSED_RESULT; - // Returns whether the Bookmark bar is visible and whether we are animating - // it into position. Also returns whether it is currently detached from the - // location bar, as in the NTP. - // Returns false on failure. - bool GetBookmarkBarVisibility(bool* is_visible, - bool* is_animating, - bool* is_detached) WARN_UNUSED_RESULT; - - // Get the bookmarks as a JSON string and put it in |json_string|. - // Return true on success. - bool GetBookmarksAsJSON(std::string* json_string) WARN_UNUSED_RESULT; - - // Wait for the bookmarks to load. Called implicitly by GetBookmarksAsJSON(). - bool WaitForBookmarkModelToLoad() WARN_UNUSED_RESULT; - - // 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) WARN_UNUSED_RESULT; - bool AddBookmarkURL(int64 parent_id, int index, - std::wstring& title, const GURL& url) WARN_UNUSED_RESULT; - // Bookmark editing: - bool ReparentBookmark(int64 id, int64 new_parent_id, - int index) WARN_UNUSED_RESULT; - bool SetBookmarkTitle(int64 id, const std::wstring& title) WARN_UNUSED_RESULT; - bool SetBookmarkURL(int64 id, const GURL& url) WARN_UNUSED_RESULT; - // Finally, bookmark deletion: - bool RemoveBookmark(int64 id) WARN_UNUSED_RESULT; - // Simulates a termination the browser session (as if the user logged off the // mahine). bool TerminateSession() WARN_UNUSED_RESULT; diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index a2e081b..1d7b46f 100755 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -1550,6 +1550,299 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): raise JSONInterfaceError('Could not resolve browser proxy.') return bookmark_model.BookmarkModel(bookmarks_as_json) + def _GetBookmarksAsJSON(self, windex=0): + """Get bookmarks as a JSON dictionary; used by GetBookmarkModel().""" + cmd_dict = { + 'command': 'GetBookmarksAsJSON', + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + return self._GetResultFromJSONRequest(cmd_dict, + windex=None)['bookmarks_as_json'] + + def WaitForBookmarkModelToLoad(self, windex=0): + """Gets the status of the bookmark bar as a dictionary. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + cmd_dict = { + 'command': 'WaitForBookmarkModelToLoad', + 'windex': windex, + } + return self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def GetBookmarkBarStatus(self, windex=0): + """Gets the status of the bookmark bar as a dictionary. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + A dictionary. + Example: + { u'visible': True, + u'animating': False, + u'detached': False, } + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + cmd_dict = { + 'command': 'GetBookmarkBarStatus', + 'windex': windex, + } + return self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def GetBookmarkBarStatus(self, windex=0): + """Gets the status of the bookmark bar as a dictionary. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + A dictionary. + Example: + { u'visible': True, + u'animating': False, + u'detached': False, } + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + cmd_dict = { + 'command': 'GetBookmarkBarStatus', + 'windex': windex, + } + return self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def GetBookmarkBarStatus(self, windex=0): + """Gets the status of the bookmark bar as a dictionary. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + A dictionary. + Example: + { u'visible': True, + u'animating': False, + u'detached': False, } + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + cmd_dict = { + 'command': 'GetBookmarkBarStatus', + 'windex': windex, + } + return self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def GetBookmarkBarVisibility(self, windex=0): + """Returns the visibility of the bookmark bar. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + True if the bookmark bar is visible, false otherwise. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + return self.GetBookmarkBarStatus(windex)['visible'] + + def IsBookmarkBarDetached(self, windex=0): + """Returns whether the bookmark bar is detached. + + Args: + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + True if the bookmark bar is detached, false otherwise. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + return self.GetBookmarkBarStatus(windex)['detached'] + + def WaitForBookmarkBarVisibilityChange(self, wait_for_open, windex=0): + """Waits until the bookmark bar is either visible or not visible. + + Args: + wait_for_open: If True, wait until bookmark bar is visible; otherwise wait + until bookmark bar is not visible. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + def IsChanged(wait_for_open, windex): + status = self.GetBookmarkBarStatus(windex) + return status['visible'] == wait_for_open and not status['animating'] + return self.WaitUntil(lambda: IsChanged(wait_for_open, windex)) + + def AddBookmarkGroup(self, parent_id, index, title, windex=0): + """Adds a bookmark folder. + + Args: + parent_id: The parent bookmark folder. + index: The location in the parent's list to insert this bookmark folder. + title: The name of the bookmark folder. + windex: Integer index of the browser window to use; defaults to the first + window. + + Returns: + True if the bookmark bar is detached, false otherwise. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(parent_id, basestring): + parent_id = int(parent_id) + cmd_dict = { + 'command': 'AddBookmark', + 'parent_id': parent_id, + 'index': index, + 'title': title, + 'is_folder': True, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def AddBookmarkURL(self, parent_id, index, title, url, windex=0): + """Add a bookmark URL. + + Args: + parent_id: The parent bookmark folder. + index: The location in the parent's list to insert this bookmark. + title: The name of the bookmark. + url: The url of the bookmark. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(parent_id, basestring): + parent_id = int(parent_id) + cmd_dict = { + 'command': 'AddBookmark', + 'parent_id': parent_id, + 'index': index, + 'title': title, + 'url': url, + 'is_folder': False, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def ReparentBookmark(self, id, new_parent_id, index, windex=0): + """Move a bookmark. + + Args: + id: The bookmark to move. + new_parent_id: The new parent bookmark folder. + index: The location in the parent's list to insert this bookmark. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(id, basestring): + id = int(id) + if isinstance(new_parent_id, basestring): + new_parent_id = int(new_parent_id) + cmd_dict = { + 'command': 'ReparentBookmark', + 'id': id, + 'new_parent_id': new_parent_id, + 'index': index, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def SetBookmarkTitle(self, id, title, windex=0): + """Change the title of a bookmark. + + Args: + id: The bookmark to rename. + title: The new title for the bookmark. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(id, basestring): + id = int(id) + cmd_dict = { + 'command': 'SetBookmarkTitle', + 'id': id, + 'title': title, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def SetBookmarkURL(self, id, url, windex=0): + """Change the URL of a bookmark. + + Args: + id: The bookmark to change. + url: The new url for the bookmark. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(id, basestring): + id = int(id) + cmd_dict = { + 'command': 'SetBookmarkURL', + 'id': id, + 'url': url, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + + def RemoveBookmark(self, id, windex=0): + """Remove a bookmark. + + Args: + id: The bookmark to remove. + windex: Integer index of the browser window to use; defaults to the first + window. + + Raises: + pyauto_errors.JSONInterfaceError if the automation call returns an error. + """ + if isinstance(id, basestring): + id = int(id) + cmd_dict = { + 'command': 'RemoveBookmark', + 'id': id, + 'windex': windex, + } + self.WaitForBookmarkModelToLoad(windex) + self._GetResultFromJSONRequest(cmd_dict, windex=None) + def GetDownloadsInfo(self, windex=0): """Return info about downloads. diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index d053bdc..a4977f5 100644 --- a/chrome/test/pyautolib/pyautolib.cc +++ b/chrome/test/pyautolib/pyautolib.cc @@ -19,12 +19,6 @@ #include "chrome/test/pyautolib/pyautolib.h" #include "googleurl/src/gurl.h" -static int64 StringToId(const std::wstring& str) { - int64 id; - base::StringToInt64(WideToUTF8(str), &id); - return id; -} - // PyUITestSuiteBase PyUITestSuiteBase::PyUITestSuiteBase(int argc, char** argv) : UITestSuite(argc, argv) { @@ -102,136 +96,6 @@ void PyUITestBase::SetLaunchSwitches() { launch_arguments_.AppendSwitchASCII(switches::kHomePage, homepage_); } -bool PyUITestBase::GetBookmarkBarState(bool* visible, - bool* detached, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - // We have no use for animating in this context. - bool animating; - EXPECT_TRUE(browser_proxy->GetBookmarkBarVisibility(visible, - &animating, - detached)); - return true; -} - -bool PyUITestBase::GetBookmarkBarVisibility() { - // We have no use for detached in this context. - bool visible, detached; - if (!GetBookmarkBarState(&visible, &detached)) - return false; - return visible; -} - -bool PyUITestBase::IsBookmarkBarDetached() { - // We have no use for visible in this context. - bool visible, detached; - if (!GetBookmarkBarState(&visible, &detached)) - return false; - return detached; -} - -bool PyUITestBase::WaitForBookmarkBarVisibilityChange(bool wait_for_open, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - // This has a 20sec timeout. If that's not enough we have serious problems. - bool completed = UITestBase::WaitForBookmarkBarVisibilityChange( - browser_proxy.get(), - wait_for_open); - EXPECT_TRUE(completed); - return completed; -} - -std::string PyUITestBase::_GetBookmarksAsJSON(int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return std::string(); - - std::string s; - EXPECT_TRUE(browser_proxy->GetBookmarksAsJSON(&s)); - return s; -} - -bool PyUITestBase::AddBookmarkGroup(std::wstring& parent_id, - int index, - std::wstring& title, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->AddBookmarkGroup(StringToId(parent_id), index, title); -} - -bool PyUITestBase::AddBookmarkURL(std::wstring& parent_id, - int index, - std::wstring& title, - std::wstring& url, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->AddBookmarkURL(StringToId(parent_id), - index, title, - GURL(WideToUTF8(url))); -} - -bool PyUITestBase::ReparentBookmark(std::wstring& id, - std::wstring& new_parent_id, - int index, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->ReparentBookmark(StringToId(id), - StringToId(new_parent_id), - index); -} - -bool PyUITestBase::SetBookmarkTitle(std::wstring& id, - std::wstring& title, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->SetBookmarkTitle(StringToId(id), title); -} - -bool PyUITestBase::SetBookmarkURL(std::wstring& id, - std::wstring& url, - int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->SetBookmarkURL(StringToId(id), GURL(WideToUTF8(url))); -} - -bool PyUITestBase::RemoveBookmark(std::wstring& id, int window_index) { - scoped_refptr<BrowserProxy> browser_proxy = GetBrowserWindow(window_index); - EXPECT_TRUE(browser_proxy.get()); - if (!browser_proxy.get()) - return false; - - return browser_proxy->RemoveBookmark(StringToId(id)); -} - AutomationProxy* PyUITestBase::automation() const { AutomationProxy* automation_proxy = UITestBase::automation(); if (!automation_proxy) { @@ -240,7 +104,6 @@ AutomationProxy* PyUITestBase::automation() const { return automation_proxy; } - scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) { return automation()->GetBrowserWindow(window_index); } diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h index b18236e..cd7cf5d 100644 --- a/chrome/test/pyautolib/pyautolib.h +++ b/chrome/test/pyautolib/pyautolib.h @@ -71,47 +71,6 @@ class PyUITestBase : public UITestBase { // AutomationProxy methods - // Returns bookmark bar visibility state. - bool GetBookmarkBarVisibility(); - - // Returns true if the bookmark bar is visible in the detached state. - bool IsBookmarkBarDetached(); - - // Returns bookmark bar animation state. Warning: timing issues may - // change this return value unexpectedly. - bool IsBookmarkBarAnimating(); - - // Wait for the bookmark bar animation to complete. - // If |wait_for_open| is true, wait for it to open. - // If |wait_for_open| is false, wait for it to close. - bool WaitForBookmarkBarVisibilityChange(bool wait_for_open, - int window_index = 0); - - // Get the bookmarks as a JSON string. Internal method. - std::string _GetBookmarksAsJSON(int window_index = 0); - - // Editing of the bookmark model. Bookmarks are referenced by id. - // 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(std::wstring& parent_id, int index, - std::wstring& title, int window_index = 0); - bool AddBookmarkURL(std::wstring& parent_id, int index, - std::wstring& title, std::wstring& url, - int window_index = 0); - // Bookmark editing: - bool ReparentBookmark(std::wstring& id, std::wstring& new_parent_id, - int index, int window_index = 0); - bool SetBookmarkTitle(std::wstring& id, std::wstring& title, - int window_index = 0); - bool SetBookmarkURL(std::wstring& id, std::wstring& url, - int window_index = 0); - // Finally, bookmark deletion: - bool RemoveBookmark(std::wstring& id, int window_index = 0); - // Get a handle to browser window at the given index, or NULL on failure. scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); @@ -164,9 +123,6 @@ class PyUITestBase : public UITestBase { const base::TimeDelta& timeout, std::string* response); - // Gets the current state of the bookmark bar. Returns false if it failed. - bool GetBookmarkBarState(bool* visible, bool* detached, int window_index = 0); - // Enables PostTask to main thread. // Should be shared across multiple instances of PyUITestBase so that this // class is re-entrant and multiple instances can be created. diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i index aedc5b67..8826a2b 100644 --- a/chrome/test/pyautolib/pyautolib.i +++ b/chrome/test/pyautolib/pyautolib.i @@ -175,59 +175,6 @@ class PyUITestBase { %feature("docstring", "Get the path to profile directory.") user_data_dir; FilePath user_data_dir() const; - %feature("docstring", "Determine if the bookmark bar is visible. " - "If the NTP is visible, only return true if attached " - "(to the chrome).") GetBookmarkBarVisibility; - bool GetBookmarkBarVisibility(); - - %feature("docstring", "Determine if the bookmark bar is detached. " - "This usually is only true on the NTP.") IsBookmarkBarDetached; - bool IsBookmarkBarDetached(); - - %feature("docstring", "Wait for the bookmark bar animation to complete. " - "|wait_for_open| specifies which kind of change we wait for.") - WaitForBookmarkBarVisibilityChange; - bool WaitForBookmarkBarVisibilityChange(bool wait_for_open, - int window_index=0); - - %feature("docstring", "Get the bookmarks as a JSON string. Internal method.") - _GetBookmarksAsJSON; - std::string _GetBookmarksAsJSON(int window_index=0); - - %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, - int window_index=0); - - %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, - int window_index=0); - - %feature("docstring", "Move a bookmark to a new parent.") ReparentBookmark; - bool ReparentBookmark(std::wstring id, - std::wstring new_parent_id, - int index, - int window_index=0); - - %feature("docstring", "Set the title of a bookmark.") SetBookmarkTitle; - bool SetBookmarkTitle(std::wstring id, - std::wstring title, - int window_index=0); - - %feature("docstring", "Set the URL of a bookmark.") SetBookmarkURL; - bool SetBookmarkURL(std::wstring id, - const std::wstring url, - int window_index=0); - - %feature("docstring", "Remove (delete) a bookmark.") RemoveBookmark; - bool RemoveBookmark(std::wstring id, int window_index=0); - // Meta-method %feature("docstring", "Send a sync JSON request to Chrome. " "Returns a JSON dict as a response. " diff --git a/chrome/test/reliability/automated_ui_test_base.cc b/chrome/test/reliability/automated_ui_test_base.cc index 3679435..ec8a704 100644 --- a/chrome/test/reliability/automated_ui_test_base.cc +++ b/chrome/test/reliability/automated_ui_test_base.cc @@ -317,27 +317,6 @@ bool AutomatedUITestBase::SelectPreviousTab() { return RunCommand(IDC_SELECT_PREVIOUS_TAB); } -bool AutomatedUITestBase::ShowBookmarkBar() { - bool is_visible; - bool is_animating; - bool is_detached; - if (!active_browser()->GetBookmarkBarVisibility(&is_visible, - &is_animating, - &is_detached)) { - return false; - } - - if (is_visible) { - // If the bar is visible, then issuing the command again will toggle it. - return true; - } - - if (!RunCommandAsync(IDC_SHOW_BOOKMARK_BAR)) - return false; - - return WaitForBookmarkBarVisibilityChange(active_browser(), true); -} - bool AutomatedUITestBase::ShowDownloads() { return RunCommand(IDC_SHOW_DOWNLOADS); } diff --git a/chrome/test/reliability/automated_ui_test_base.h b/chrome/test/reliability/automated_ui_test_base.h index 36f170e..8fbf138 100644 --- a/chrome/test/reliability/automated_ui_test_base.h +++ b/chrome/test/reliability/automated_ui_test_base.h @@ -107,10 +107,6 @@ class AutomatedUITestBase : public UITest { // Returns true on success. bool SelectPreviousTab(); - // Displays the bookmark bar. - // Returns true on success. - bool ShowBookmarkBar(); - // Opens the Downloads page in the current active browser window. // Returns true on success. bool ShowDownloads(); diff --git a/chrome/test/reliability/automated_ui_tests.cc b/chrome/test/reliability/automated_ui_tests.cc index 108d44a..b214c68 100644 --- a/chrome/test/reliability/automated_ui_tests.cc +++ b/chrome/test/reliability/automated_ui_tests.cc @@ -448,8 +448,6 @@ bool AutomatedUITest::DoAction(const std::string& action) { did_complete_action = SelectNextTab(); } else if (LowerCaseEqualsASCII(action, "selectprevtab")) { did_complete_action = SelectPreviousTab(); - } else if (LowerCaseEqualsASCII(action, "showbookmarks")) { - did_complete_action = ShowBookmarkBar(); } else if (LowerCaseEqualsASCII(action, "setup")) { AutomatedUITestBase::SetUp(); did_complete_action = true; diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 2128b9d..de01ff5 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -313,27 +313,6 @@ void UITestBase::NavigateToURLBlockUntilNavigationsComplete( url, number_of_navigations)) << url.spec(); } -bool UITestBase::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, - bool wait_for_open) { - const int kCycles = 10; - const TimeDelta kDelay = TestTimeouts::action_timeout() / kCycles; - for (int i = 0; i < kCycles; i++) { - bool visible = false; - bool animating = true; - bool detached; - if (!browser->GetBookmarkBarVisibility(&visible, &animating, &detached)) - return false; // Some error. - if (visible == wait_for_open && !animating) - return true; // Bookmark bar visibility change complete. - - // Give it a chance to catch up. - base::PlatformThread::Sleep(kDelay); - } - - ADD_FAILURE() << "Timeout reached in WaitForBookmarkBarVisibilityChange"; - return false; -} - GURL UITestBase::GetActiveTabURL(int window_index) { scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index)); EXPECT_TRUE(tab_proxy.get()); diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index a8d252e..23d4cac 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -141,12 +141,6 @@ class UITestBase { // assert that the tab count is valid at the end of the wait. void WaitUntilTabCount(int tab_count); - // Waits until the Bookmark bar has stopped animating and become fully visible - // (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false). - // This function can time out (in which case it returns false). - bool WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, - bool wait_for_open); - // Closes the specified browser. Returns true if the browser was closed. // This call is blocking. |application_closed| is set to true if this was // the last browser window (and therefore as a result of it closing the |