| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "app/os_exchange_data.h" | 5 #include "app/os_exchange_data.h" |
| 6 #include "app/os_exchange_data_provider_win.h" | 6 #include "app/os_exchange_data_provider_win.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 10 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 BookmarkDragData read_data; | 93 BookmarkDragData read_data; |
| 94 EXPECT_TRUE(read_data.Read(data2)); | 94 EXPECT_TRUE(read_data.Read(data2)); |
| 95 EXPECT_TRUE(read_data.is_valid()); | 95 EXPECT_TRUE(read_data.is_valid()); |
| 96 ASSERT_EQ(1, read_data.elements.size()); | 96 ASSERT_EQ(1, read_data.elements.size()); |
| 97 EXPECT_TRUE(read_data.elements[0].is_url); | 97 EXPECT_TRUE(read_data.elements[0].is_url); |
| 98 EXPECT_TRUE(read_data.elements[0].url == url); | 98 EXPECT_TRUE(read_data.elements[0].url == url); |
| 99 EXPECT_EQ(title, read_data.elements[0].title); | 99 EXPECT_EQ(title, read_data.elements[0].title); |
| 100 EXPECT_TRUE(read_data.GetFirstNode(&profile) == node); | 100 EXPECT_TRUE(read_data.GetFirstNode(&profile) == node); |
| 101 | 101 |
| 102 // Make sure asking for the node with a different profile returns NULL. | 102 // Make sure asking for the node with a different profile returns NULL. |
| 103 TestingProfile profile2(1); | 103 TestingProfile profile2; |
| 104 EXPECT_TRUE(read_data.GetFirstNode(&profile2) == NULL); | 104 EXPECT_TRUE(read_data.GetFirstNode(&profile2) == NULL); |
| 105 | 105 |
| 106 // Writing should also put the URL and title on the clipboard. | 106 // Writing should also put the URL and title on the clipboard. |
| 107 GURL read_url; | 107 GURL read_url; |
| 108 std::wstring read_title; | 108 std::wstring read_title; |
| 109 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &read_title)); | 109 EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &read_title)); |
| 110 EXPECT_TRUE(read_url == url); | 110 EXPECT_TRUE(read_url == url); |
| 111 EXPECT_EQ(title, read_title); | 111 EXPECT_EQ(title, read_title); |
| 112 } | 112 } |
| 113 | 113 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 139 EXPECT_TRUE(read_data.is_valid()); | 139 EXPECT_TRUE(read_data.is_valid()); |
| 140 ASSERT_EQ(1, read_data.elements.size()); | 140 ASSERT_EQ(1, read_data.elements.size()); |
| 141 EXPECT_EQ(g12->GetTitle(), read_data.elements[0].title); | 141 EXPECT_EQ(g12->GetTitle(), read_data.elements[0].title); |
| 142 EXPECT_FALSE(read_data.elements[0].is_url); | 142 EXPECT_FALSE(read_data.elements[0].is_url); |
| 143 | 143 |
| 144 // We should get back the same node when asking for the same profile. | 144 // We should get back the same node when asking for the same profile. |
| 145 const BookmarkNode* r_g12 = read_data.GetFirstNode(&profile); | 145 const BookmarkNode* r_g12 = read_data.GetFirstNode(&profile); |
| 146 EXPECT_TRUE(g12 == r_g12); | 146 EXPECT_TRUE(g12 == r_g12); |
| 147 | 147 |
| 148 // A different profile should return NULL for the node. | 148 // A different profile should return NULL for the node. |
| 149 TestingProfile profile2(1); | 149 TestingProfile profile2; |
| 150 EXPECT_TRUE(read_data.GetFirstNode(&profile2) == NULL); | 150 EXPECT_TRUE(read_data.GetFirstNode(&profile2) == NULL); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Tests reading/writing a folder with children. | 153 // Tests reading/writing a folder with children. |
| 154 TEST_F(BookmarkDragDataTest, GroupWithChild) { | 154 TEST_F(BookmarkDragDataTest, GroupWithChild) { |
| 155 TestingProfile profile; | 155 TestingProfile profile; |
| 156 profile.SetID(L"id"); | 156 profile.SetID(L"id"); |
| 157 profile.CreateBookmarkModel(false); | 157 profile.CreateBookmarkModel(false); |
| 158 profile.BlockUntilBookmarkModelLoaded(); | 158 profile.BlockUntilBookmarkModelLoaded(); |
| 159 BookmarkModel* model = profile.GetBookmarkModel(); | 159 BookmarkModel* model = profile.GetBookmarkModel(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // And make sure we get the node back. | 233 // And make sure we get the node back. |
| 234 std::vector<const BookmarkNode*> read_nodes = read_data.GetNodes(&profile); | 234 std::vector<const BookmarkNode*> read_nodes = read_data.GetNodes(&profile); |
| 235 ASSERT_EQ(2, read_nodes.size()); | 235 ASSERT_EQ(2, read_nodes.size()); |
| 236 EXPECT_TRUE(read_nodes[0] == group); | 236 EXPECT_TRUE(read_nodes[0] == group); |
| 237 EXPECT_TRUE(read_nodes[1] == url_node); | 237 EXPECT_TRUE(read_nodes[1] == url_node); |
| 238 | 238 |
| 239 // Asking for the first node should return NULL with more than one element | 239 // Asking for the first node should return NULL with more than one element |
| 240 // present. | 240 // present. |
| 241 EXPECT_TRUE(read_data.GetFirstNode(&profile) == NULL); | 241 EXPECT_TRUE(read_data.GetFirstNode(&profile) == NULL); |
| 242 } | 242 } |
| OLD | NEW |