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

Unified Diff: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm

Issue 199024: (Mac) Display the bookmark bar off-the-side menu on mouse down. Also align the menu. (Closed)
Patch Set: Rebased ToT. Created 11 years, 3 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/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/menu_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
index 55c4c18a0e6a945fc23662e456f652d05d717adc..7799e5c11f542a1708577bb9cf84abf6d1fe42fd 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
@@ -524,6 +524,49 @@ TEST_F(BookmarkBarControllerTest, MiddleClick) {
[bar_ setUrlDelegate:nil];
}
+TEST_F(BookmarkBarControllerTest, TestBuildOffTheSideMenu) {
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+ NSMenu* menu = [bar_ offTheSideMenu];
+ ASSERT_TRUE(menu);
+
+ // The bookmark bar should start out with nothing.
+ EXPECT_EQ(0U, [[bar_ buttons] count]);
+
+ // Make sure things work when there's nothing. Note that there should always
+ // be a blank first menu item.
+ [bar_ buildOffTheSideMenu];
+ EXPECT_EQ(1, [menu numberOfItems]);
+
+ // We add lots of bookmarks. At first, we expect nothing to be added to the
+ // off-the-side menu. But once they start getting added, we expect the
+ // remaining ones to be added too. We expect a reasonably substantial number
+ // of items to be added by the end.
+ int num_off_the_side = 0;
+ for (int i = 0; i < 50; i++) {
+ const BookmarkNode* parent = model->GetBookmarkBarNode();
+ model->AddURL(parent, parent->GetChildCount(),
+ L"very wide title",
+ GURL("http://www.foobar.com/"));
+ [bar_ buildOffTheSideMenu];
+
+ if (num_off_the_side) {
+ num_off_the_side++;
+ EXPECT_EQ(1 + num_off_the_side, [menu numberOfItems]);
+ } else {
+ EXPECT_TRUE([menu numberOfItems] == 1 || [menu numberOfItems] == 2);
+ if ([menu numberOfItems] == 2)
+ num_off_the_side++;
+ }
+ }
+ EXPECT_GE(num_off_the_side, 20);
+
+ // Reset, and check that the built menu is "empty" again.
+ [bar_ clearBookmarkBar];
+ EXPECT_EQ(0U, [[bar_ buttons] count]);
+ [bar_ buildOffTheSideMenu];
+ EXPECT_EQ(1, [menu numberOfItems]);
+}
+
// Cannot test these methods since they simply call a single static
// method, BookmarkEditor::Show(), which is impossible to mock.
// editBookmark:, addPage:
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/menu_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698