OLD | NEW |
---|---|
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 Loading... | |
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] 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.
| |
1178 withObject:otherButton]; | |
1179 BookmarkBarFolderController* folder = [bar_ folderController]; | |
1180 EXPECT_TRUE(folder); | |
1181 | |
1182 // Initially there is only (empty) placeholder button, hence buttonCount | |
1183 // should be 1. | |
1184 NSArray* buttons = [folder buttons]; | |
1185 EXPECT_TRUE(buttons); | |
1186 EXPECT_EQ(1U, [buttons count]); | |
1187 | |
1188 // Add a new bookmark into 'Other bookmarks' folder. | |
1189 model->AddURL(otherBookmarks, otherBookmarks->child_count(), | |
1190 ASCIIToUTF16("TheOther"), | |
1191 GURL("http://www.other.com")); | |
1192 | |
1193 // buttonCount still should be 1, as we remove the (empty) placeholder button | |
1194 // when adding a new button to an empty folder. | |
1195 EXPECT_EQ(1U, [buttons count]); | |
1196 | |
1197 // Now we have only 1 button; remove it so that 'Other bookmarks' folder | |
1198 // is hidden. | |
1199 [folder removeButton:0 animate:NO]; | |
1200 EXPECT_EQ(0U, [buttons count]); | |
1201 | |
1202 // 'Other bookmarks' folder gets closed once we remove the last button. Hence | |
1203 // folderController_ should be NULL. | |
1204 EXPECT_FALSE([bar_ folderController]); | |
1205 } | |
1206 | |
1169 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { | 1207 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { |
1170 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1208 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
1171 const BookmarkNode* root = model->bookmark_bar_node(); | 1209 const BookmarkNode* root = model->bookmark_bar_node(); |
1172 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); | 1210 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
1173 test::AddNodesFromModelString(model, root, model_string); | 1211 test::AddNodesFromModelString(model, root, model_string); |
1174 | 1212 |
1175 // Validate initial model. | 1213 // Validate initial model. |
1176 std::string actualModelString = test::ModelStringFromNode(root); | 1214 std::string actualModelString = test::ModelStringFromNode(root); |
1177 EXPECT_EQ(model_string, actualModelString); | 1215 EXPECT_EQ(model_string, actualModelString); |
1178 | 1216 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1603 DeleteBookmark([folder parentButton], profile()); | 1641 DeleteBookmark([folder parentButton], profile()); |
1604 EXPECT_FALSE([folder folderController]); | 1642 EXPECT_FALSE([folder folderController]); |
1605 } | 1643 } |
1606 | 1644 |
1607 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1645 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
1608 // they are hard to test. Factor out "fire timers" into routines | 1646 // they are hard to test. Factor out "fire timers" into routines |
1609 // which can be overridden to fire immediately to make behavior | 1647 // which can be overridden to fire immediately to make behavior |
1610 // confirmable. | 1648 // confirmable. |
1611 // There is a similar problem with mouseEnteredButton: and | 1649 // There is a similar problem with mouseEnteredButton: and |
1612 // mouseExitedButton:. | 1650 // mouseExitedButton:. |
OLD | NEW |