diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 06:56:49 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 06:56:49 +0000 |
commit | 4d89f386af65daedfa0acda2ec501c501af84fb8 (patch) | |
tree | 381594fdfb4b2b9c2dc1a1691023fd271438211a /chrome/browser/cocoa | |
parent | 884bc1739d4c28b05a932e661e0fcf9392ebb7f0 (diff) | |
download | chromium_src-4d89f386af65daedfa0acda2ec501c501af84fb8.zip chromium_src-4d89f386af65daedfa0acda2ec501c501af84fb8.tar.gz chromium_src-4d89f386af65daedfa0acda2ec501c501af84fb8.tar.bz2 |
Move the bookmark node iD generation to bookmark model isntead of
bookmark node. This will also make the IDs more dense.
Review URL: http://codereview.chromium.org/99304
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15839 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm | 21 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_cocoa_controller_unittest.mm | 8 |
2 files changed, 12 insertions, 17 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm index 2fe6127..6cf2efb 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm +++ b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm @@ -66,6 +66,7 @@ TEST_F(BookmarkMenuBridgeTest, TestClearBookmarkMenu) { // Test that AddNodeToMenu() properly adds bookmark nodes as menus, // including the recursive case. TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { + std::wstring empty; Profile* profile = browser_test_helper_.profile(); scoped_ptr<BookmarkMenuBridge> bridge(new BookmarkMenuBridge()); @@ -73,8 +74,9 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { NSMenu* menu = [[[NSMenu alloc] initWithTitle:@"foo"] autorelease]; - BookmarkModel* model = new BookmarkModel(profile); - BookmarkNode* root = new BookmarkNode(model, GURL()); + BookmarkModel* model = profile->GetBookmarkModel(); + BookmarkNode* bookmark_bar = model->GetBookmarkBarNode(); + BookmarkNode* root = model->AddGroup(bookmark_bar, 0, empty); EXPECT_TRUE(model && root); const char* short_url = "http://foo/"; @@ -86,16 +88,12 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { // 3 nodes; middle one has a child, last one has a HUGE URL // Set their titles to be the same as the URLs BookmarkNode* node = NULL; - root->Add(0, new BookmarkNode(model, GURL(short_url))); - root->Add(1, new BookmarkNode(model, GURL())); - root->Add(2, new BookmarkNode(model, GURL(long_url))); - - root->GetChild(0)->SetTitle(ASCIIToWide(short_url)); - root->GetChild(2)->SetTitle(ASCIIToWide(long_url)); + model->AddURL(root, 0, ASCIIToWide(short_url), GURL(short_url)); + node = model->AddGroup(root, 1, empty); + model->AddURL(root, 2, ASCIIToWide(long_url), GURL(long_url)); // And the submenu fo the middle one - node = new BookmarkNode(model, GURL("http://sub")); - root->GetChild(1)->Add(0, node); + model->AddURL(node, 0, empty, GURL("http://sub")); // Add to the NSMenu, then confirm it looks good AddNodeToMenu(bridge.get(), root, menu); @@ -131,7 +129,4 @@ TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) { // e.g. http://foo becomes http://foo/) EXPECT_GE([[[menu itemAtIndex:0] toolTip] length], (2*strlen(short_url) - 5)); EXPECT_GE([[[menu itemAtIndex:2] toolTip] length], (2*strlen(long_url) - 5)); - - delete root; // deletes all its kids - delete model; } diff --git a/chrome/browser/cocoa/bookmark_menu_cocoa_controller_unittest.mm b/chrome/browser/cocoa/bookmark_menu_cocoa_controller_unittest.mm index d70f51a..90895fc 100644 --- a/chrome/browser/cocoa/bookmark_menu_cocoa_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_menu_cocoa_controller_unittest.mm @@ -20,17 +20,17 @@ - (id)init { if ((self = [super init])) { + std::wstring empty; helper_ = new BrowserTestHelper(); BookmarkModel* model = helper_->browser()->profile()->GetBookmarkModel(); - nodes_[0] = new BookmarkNode(model, GURL("http://0.com")); - nodes_[1] = new BookmarkNode(model, GURL("http://1.com")); + BookmarkNode* bookmark_bar = model->GetBookmarkBarNode(); + nodes_[0] = model->AddURL(bookmark_bar, 0, empty, GURL("http://0.com")); + nodes_[1] = model->AddURL(bookmark_bar, 1, empty, GURL("http://1.com")); } return self; } - (void)dealloc { - delete nodes_[0]; - delete nodes_[1]; delete helper_; [super dealloc]; } |