Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm

Issue 485003002: Adding (empty) placeholder button to 'Other bookmarks' folder is unnecessary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing performSelector: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm
index 52979985dc9304a25f8f52cbbc8e65b0ee58bb2b..4b9c3ac93fd99c84055e7d5851d1a7fa5a19e485 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller_unittest.mm
@@ -1166,6 +1166,43 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MoveRemoveAddButtons) {
[folder validateMenuSpacing];
}
+TEST_F(BookmarkBarFolderControllerMenuTest, RemoveLastButtonOtherBookmarks) {
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
+ const BookmarkNode* otherBookmarks = model->other_node();
+
+ BookmarkButton* otherButton = [bar_ otherBookmarksButton];
+ ASSERT_TRUE(otherButton);
+
+ // Open the folder to get the folderController_.
+ [[otherButton target] openBookmarkFolderFromButton:otherButton];
+ BookmarkBarFolderController* folder = [bar_ folderController];
+ EXPECT_TRUE(folder);
+
+ // Initially there is only (empty) placeholder button, hence buttonCount
+ // should be 1.
+ NSArray* buttons = [folder buttons];
+ EXPECT_TRUE(buttons);
+ EXPECT_EQ(1U, [buttons count]);
+
+ // Add a new bookmark into 'Other bookmarks' folder.
+ model->AddURL(otherBookmarks, otherBookmarks->child_count(),
+ ASCIIToUTF16("TheOther"),
+ GURL("http://www.other.com"));
+
+ // buttonCount still should be 1, as we remove the (empty) placeholder button
+ // when adding a new button to an empty folder.
+ EXPECT_EQ(1U, [buttons count]);
+
+ // Now we have only 1 button; remove it so that 'Other bookmarks' folder
+ // is hidden.
+ [folder removeButton:0 animate:NO];
+ EXPECT_EQ(0U, [buttons count]);
+
+ // 'Other bookmarks' folder gets closed once we remove the last button. Hence
+ // folderController_ should be NULL.
+ EXPECT_FALSE([bar_ folderController]);
+}
+
TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) {
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* root = model->bookmark_bar_node();
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698