diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 22:33:14 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 22:33:14 +0000 |
commit | 03814723a5b1a9f60aa0d86ce32096149983a81b (patch) | |
tree | 70600a64528c3b362730fe334f0a5ef4c54eaac5 /chrome/browser/cocoa | |
parent | 1b7ebfd9b79802b9f7385992ebd011af993ba381 (diff) | |
download | chromium_src-03814723a5b1a9f60aa0d86ce32096149983a81b.zip chromium_src-03814723a5b1a9f60aa0d86ce32096149983a81b.tar.gz chromium_src-03814723a5b1a9f60aa0d86ce32096149983a81b.tar.bz2 |
Merge 32681 - Change popup construction logic so that folders with empty name is no longer used for excluding the root node from display, rather, user is_root() for that purpose. A folder with an empty name is now shown as a blank line in the popup.
BUG=28313
TEST=Create a new folder with a blank name and add an URL to that folder. Select the new bookmark. Bring up the bubble and click either 'Edit' or 'Close'. It should not crash at this point. Also, click on the popup and a blank line should appear representing the newly created folder.
Review URL: http://codereview.chromium.org/418027
TBR=mrossetti@chromium.org
Review URL: http://codereview.chromium.org/424010
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@32689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bubble_controller.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/bookmark_bubble_controller.mm b/chrome/browser/cocoa/bookmark_bubble_controller.mm index 2eed1d8..ca8f913 100644 --- a/chrome/browser/cocoa/bookmark_bubble_controller.mm +++ b/chrome/browser/cocoa/bookmark_bubble_controller.mm @@ -226,8 +226,8 @@ // the given pop up button. - (void)addFolderNodes:(const BookmarkNode*)parent toPopUpButton:(NSPopUpButton*)button { - NSString* title = base::SysWideToNSString(parent->GetTitle()); - if ([title length]) { // no title if root + if (!model_->is_root(parent)) { + NSString* title = base::SysWideToNSString(parent->GetTitle()); NSMenu* menu = [button menu]; NSMenuItem* item = [menu addItemWithTitle:title action:NULL diff --git a/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm index 76b8d38..9f037da 100644 --- a/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm @@ -129,6 +129,42 @@ TEST_F(BookmarkBubbleControllerTest, TestFillInFolder) { EXPECT_FALSE([titles containsObject:@"title2"]); } +// Confirm ability to handle folders with blank name. +TEST_F(BookmarkBubbleControllerTest, TestFolderWithBlankName) { + // Create some folders, including a nested folder + BookmarkModel* model = GetBookmarkModel(); + EXPECT_TRUE(model); + const BookmarkNode* bookmarkBarNode = model->GetBookmarkBarNode(); + EXPECT_TRUE(bookmarkBarNode); + const BookmarkNode* node1 = model->AddGroup(bookmarkBarNode, 0, L"one"); + EXPECT_TRUE(node1); + const BookmarkNode* node2 = model->AddGroup(bookmarkBarNode, 1, L""); + EXPECT_TRUE(node2); + const BookmarkNode* node3 = model->AddGroup(bookmarkBarNode, 2, L"three"); + EXPECT_TRUE(node3); + const BookmarkNode* node2_1 = + model->AddURL(node2, 0, L"title1", GURL("http://www.google.com")); + EXPECT_TRUE(node2_1); + + BookmarkBubbleController* controller = ControllerForNode(node1); + EXPECT_TRUE(controller); + + // One of the items should be blank and its node should be node2. + NSArray* items = [[controller folderPopUpButton] itemArray]; + EXPECT_EQ(6U, [items count]); + BOOL blankFolderFound = NO; + for (NSMenuItem* item in [[controller folderPopUpButton] itemArray]) { + if ([[item title] length] == 0 && + static_cast<const BookmarkNode*>([[item representedObject] + pointerValue]) == node2) { + blankFolderFound = YES; + break; + } + } + EXPECT_TRUE(blankFolderFound); +} + + // Click on edit; bubble gets closed. TEST_F(BookmarkBubbleControllerTest, TestEdit) { BookmarkModel* model = GetBookmarkModel(); |