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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/mac/scoped_nsobject.h" 6 #include "base/mac/scoped_nsobject.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 [folder removeButton:1 animate:NO]; 1159 [folder removeButton:1 animate:NO];
1160 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]); 1160 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]);
1161 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]); 1161 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]);
1162 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]); 1162 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]);
1163 EXPECT_EQ(oldDisplayedButtons, [buttons count]); 1163 EXPECT_EQ(oldDisplayedButtons, [buttons count]);
1164 1164
1165 // Check button spacing. 1165 // Check button spacing.
1166 [folder validateMenuSpacing]; 1166 [folder validateMenuSpacing];
1167 } 1167 }
1168 1168
1169 TEST_F(BookmarkBarFolderControllerMenuTest, RemoveLastButtonOtherBookmarks) {
1170 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
1171 const BookmarkNode* otherBookmarks = model->other_node();
1172
1173 BookmarkButton* otherButton = [bar_ otherBookmarksButton];
1174 ASSERT_TRUE(otherButton);
1175
1176 // Open the folder to get the folderController_.
1177 [[otherButton target] openBookmarkFolderFromButton:otherButton];
1178 BookmarkBarFolderController* folder = [bar_ folderController];
1179 EXPECT_TRUE(folder);
1180
1181 // Initially there is only (empty) placeholder button, hence buttonCount
1182 // should be 1.
1183 NSArray* buttons = [folder buttons];
1184 EXPECT_TRUE(buttons);
1185 EXPECT_EQ(1U, [buttons count]);
1186
1187 // Add a new bookmark into 'Other bookmarks' folder.
1188 model->AddURL(otherBookmarks, otherBookmarks->child_count(),
1189 ASCIIToUTF16("TheOther"),
1190 GURL("http://www.other.com"));
1191
1192 // buttonCount still should be 1, as we remove the (empty) placeholder button
1193 // when adding a new button to an empty folder.
1194 EXPECT_EQ(1U, [buttons count]);
1195
1196 // Now we have only 1 button; remove it so that 'Other bookmarks' folder
1197 // is hidden.
1198 [folder removeButton:0 animate:NO];
1199 EXPECT_EQ(0U, [buttons count]);
1200
1201 // 'Other bookmarks' folder gets closed once we remove the last button. Hence
1202 // folderController_ should be NULL.
1203 EXPECT_FALSE([bar_ folderController]);
1204 }
1205
1169 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { 1206 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) {
1170 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 1207 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
1171 const BookmarkNode* root = model->bookmark_bar_node(); 1208 const BookmarkNode* root = model->bookmark_bar_node();
1172 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); 1209 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b ");
1173 test::AddNodesFromModelString(model, root, model_string); 1210 test::AddNodesFromModelString(model, root, model_string);
1174 1211
1175 // Validate initial model. 1212 // Validate initial model.
1176 std::string actualModelString = test::ModelStringFromNode(root); 1213 std::string actualModelString = test::ModelStringFromNode(root);
1177 EXPECT_EQ(model_string, actualModelString); 1214 EXPECT_EQ(model_string, actualModelString);
1178 1215
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 DeleteBookmark([folder parentButton], profile()); 1640 DeleteBookmark([folder parentButton], profile());
1604 EXPECT_FALSE([folder folderController]); 1641 EXPECT_FALSE([folder folderController]);
1605 } 1642 }
1606 1643
1607 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 1644 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
1608 // they are hard to test. Factor out "fire timers" into routines 1645 // they are hard to test. Factor out "fire timers" into routines
1609 // which can be overridden to fire immediately to make behavior 1646 // which can be overridden to fire immediately to make behavior
1610 // confirmable. 1647 // confirmable.
1611 // There is a similar problem with mouseEnteredButton: and 1648 // There is a similar problem with mouseEnteredButton: and
1612 // mouseExitedButton:. 1649 // mouseExitedButton:.
OLDNEW
« 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