diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-19 18:33:48 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-19 18:33:48 +0000 |
commit | 848cd05ed947f5939df4cd6028aad4e068484c23 (patch) | |
tree | fda36e250d3d83fbcb58e57b950aba56f090c575 /chrome/browser/bookmarks/bookmark_drag_data_unittest.cc | |
parent | b988fe4ded9067b2e5cb7e3a3937036ce2cb09c8 (diff) | |
download | chromium_src-848cd05ed947f5939df4cd6028aad4e068484c23.zip chromium_src-848cd05ed947f5939df4cd6028aad4e068484c23.tar.gz chromium_src-848cd05ed947f5939df4cd6028aad4e068484c23.tar.bz2 |
Changes the bookmark model to allow more than one bookmark to
reference the same url. Clicking the star button edits the most
recently added bookmark for the URL. Dragging a button/star always
does a move, otherwise drops on the bookmark bar create a new
bookmark.
Also changed the add page context menu for the bookmark bar to
remember where you invoked it from.
BUG=1173228 1678
Review URL: http://codereview.chromium.org/3203
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_drag_data_unittest.cc')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_drag_data_unittest.cc | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc index 76f0f67..a3022f8 100644 --- a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/common/os_exchange_data.h" +#include "chrome/test/testing_profile.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,20 +26,21 @@ TEST_F(BookmarkDragDataTest, BogusRead) { } TEST_F(BookmarkDragDataTest, URL) { - BookmarkModel model(NULL); - BookmarkNode* root = model.GetBookmarkBarNode(); + TestingProfile profile; + profile.CreateBookmarkModel(false); + profile.SetID(L"id"); + BookmarkModel* model = profile.GetBookmarkModel(); + BookmarkNode* root = model->GetBookmarkBarNode(); GURL url(GURL("http://foo.com")); - const std::wstring profile_id(L"blah"); const std::wstring title(L"blah"); - BookmarkNode* node = model.AddURL(root, 0, title, url); + BookmarkNode* node = model->AddURL(root, 0, title, url); BookmarkDragData drag_data(node); - drag_data.profile_id = profile_id; EXPECT_TRUE(drag_data.url == url); EXPECT_EQ(title, drag_data.title); EXPECT_TRUE(drag_data.is_url); scoped_refptr<OSExchangeData> data(new OSExchangeData()); - drag_data.Write(data.get()); + drag_data.Write(&profile, data.get()); // Now read the data back in. scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get())); @@ -48,6 +50,10 @@ TEST_F(BookmarkDragDataTest, URL) { EXPECT_EQ(title, read_data.title); EXPECT_TRUE(read_data.is_valid); EXPECT_TRUE(read_data.is_url); + EXPECT_TRUE(read_data.GetNode(&profile) == node); + + TestingProfile profile2(1); + EXPECT_TRUE(read_data.GetNode(&profile2) == NULL); // Writing should also put the URL and title on the clipboard. GURL read_url; @@ -58,50 +64,54 @@ TEST_F(BookmarkDragDataTest, URL) { } TEST_F(BookmarkDragDataTest, Group) { - BookmarkModel model(NULL); - BookmarkNode* root = model.GetBookmarkBarNode(); - BookmarkNode* g1 = model.AddGroup(root, 0, L"g1"); - BookmarkNode* g11 = model.AddGroup(g1, 0, L"g11"); - BookmarkNode* g12 = model.AddGroup(g1, 0, L"g12"); + TestingProfile profile; + profile.CreateBookmarkModel(false); + profile.SetID(L"id"); + BookmarkModel* model = profile.GetBookmarkModel(); + BookmarkNode* root = model->GetBookmarkBarNode(); + BookmarkNode* g1 = model->AddGroup(root, 0, L"g1"); + BookmarkNode* g11 = model->AddGroup(g1, 0, L"g11"); + BookmarkNode* g12 = model->AddGroup(g1, 0, L"g12"); BookmarkDragData drag_data(g12); - const std::wstring profile_id(L"blah"); - drag_data.profile_id = profile_id; EXPECT_EQ(g12->GetTitle(), drag_data.title); EXPECT_FALSE(drag_data.is_url); scoped_refptr<OSExchangeData> data(new OSExchangeData()); - drag_data.Write(data.get()); + drag_data.Write(&profile, data.get()); // Now read the data back in. scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get())); BookmarkDragData read_data; EXPECT_TRUE(read_data.Read(*data2)); EXPECT_EQ(g12->GetTitle(), read_data.title); - EXPECT_EQ(profile_id, read_data.profile_id); EXPECT_TRUE(read_data.is_valid); EXPECT_FALSE(read_data.is_url); - BookmarkNode* r_g12 = read_data.GetNode(&model); + BookmarkNode* r_g12 = read_data.GetNode(&profile); EXPECT_TRUE(g12 == r_g12); + + TestingProfile profile2(1); + EXPECT_TRUE(read_data.GetNode(&profile2) == NULL); } TEST_F(BookmarkDragDataTest, GroupWithChild) { - BookmarkModel model(NULL); - BookmarkNode* root = model.GetBookmarkBarNode(); - BookmarkNode* group = model.AddGroup(root, 0, L"g1"); + TestingProfile profile; + profile.SetID(L"id"); + profile.CreateBookmarkModel(false); + BookmarkModel* model = profile.GetBookmarkModel(); + BookmarkNode* root = model->GetBookmarkBarNode(); + BookmarkNode* group = model->AddGroup(root, 0, L"g1"); GURL url(GURL("http://foo.com")); - const std::wstring profile_id(L"blah"); const std::wstring title(L"blah2"); - model.AddURL(group, 0, title, url); + model->AddURL(group, 0, title, url); BookmarkDragData drag_data(group); - drag_data.profile_id = profile_id; scoped_refptr<OSExchangeData> data(new OSExchangeData()); - drag_data.Write(data.get()); + drag_data.Write(&profile, data.get()); // Now read the data back in. scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get())); @@ -115,6 +125,6 @@ TEST_F(BookmarkDragDataTest, GroupWithChild) { EXPECT_TRUE(url == read_data.children[0].url); EXPECT_TRUE(read_data.children[0].is_url); - BookmarkNode* r_group = read_data.GetNode(&model); + BookmarkNode* r_group = read_data.GetNode(&profile); EXPECT_TRUE(group == r_group); } |