Chromium Code Reviews| 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..8359140a6798693b175f498bbe4da684c871e5c8 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,44 @@ 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] performSelector:@selector(openBookmarkFolderFromButton:) |
|
Alexei Svitkine (slow)
2014/08/21 13:41:42
Nit: Why performSelector: and not just call the me
Gaja
2014/08/21 14:45:43
In almost all test cases performSelector: has been
Alexei Svitkine (slow)
2014/08/21 14:48:03
Yes, please. It's unnecessary.
Gaja
2014/08/21 15:01:24
Done.
|
| + withObject: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(); |