summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 21:55:53 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 21:55:53 +0000
commita199a9eab7f526bd4f22bb436fbad5207c303723 (patch)
tree7b9464d6c67f03f6c60ae2e4fd019cb53ba80387
parent5346ddb3bf214666a6aaa9f6052dbfe0cc65854f (diff)
downloadchromium_src-a199a9eab7f526bd4f22bb436fbad5207c303723.zip
chromium_src-a199a9eab7f526bd4f22bb436fbad5207c303723.tar.gz
chromium_src-a199a9eab7f526bd4f22bb436fbad5207c303723.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32681 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/bookmark_bubble_controller.mm4
-rw-r--r--chrome/browser/cocoa/bookmark_bubble_controller_unittest.mm36
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 e3bee67..b8ae9c5 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();