Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: chrome/browser/bookmarks/bookmark_node_data_unittest.cc

Issue 11827058: bookmarks: GetNameForURL() function is only used by gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update os_exchange_data_win_unittest.cc Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 ui::OSExchangeData data; 51 ui::OSExchangeData data;
52 BookmarkNodeData drag_data; 52 BookmarkNodeData drag_data;
53 EXPECT_FALSE(drag_data.Read(ui::OSExchangeData(CloneProvider(data)))); 53 EXPECT_FALSE(drag_data.Read(ui::OSExchangeData(CloneProvider(data))));
54 EXPECT_FALSE(drag_data.is_valid()); 54 EXPECT_FALSE(drag_data.is_valid());
55 } 55 }
56 56
57 // Writes a URL to the clipboard and make sure BookmarkNodeData can correctly 57 // Writes a URL to the clipboard and make sure BookmarkNodeData can correctly
58 // read it. 58 // read it.
59 TEST_F(BookmarkNodeDataTest, JustURL) { 59 TEST_F(BookmarkNodeDataTest, JustURL) {
60 const GURL url("http://google.com"); 60 const GURL url("http://google.com");
61 const string16 title(ASCIIToUTF16("title")); 61 const string16 title(ASCIIToUTF16("google.com"));
62 62
63 ui::OSExchangeData data; 63 ui::OSExchangeData data;
64 data.SetURL(url, title); 64 data.SetURL(url, title);
65 65
66 BookmarkNodeData drag_data; 66 BookmarkNodeData drag_data;
67 EXPECT_TRUE(drag_data.Read(ui::OSExchangeData(CloneProvider(data)))); 67 EXPECT_TRUE(drag_data.Read(ui::OSExchangeData(CloneProvider(data))));
68 EXPECT_TRUE(drag_data.is_valid()); 68 EXPECT_TRUE(drag_data.is_valid());
69 ASSERT_EQ(1, drag_data.elements.size()); 69 ASSERT_EQ(1, drag_data.elements.size());
70 EXPECT_TRUE(drag_data.elements[0].is_url); 70 EXPECT_TRUE(drag_data.elements[0].is_url);
71 EXPECT_EQ(url, drag_data.elements[0].url); 71 EXPECT_EQ(url, drag_data.elements[0].url);
72 EXPECT_EQ(title, drag_data.elements[0].title); 72 EXPECT_EQ(title, drag_data.elements[0].title);
73 EXPECT_EQ(0, drag_data.elements[0].children.size()); 73 EXPECT_EQ(0, drag_data.elements[0].children.size());
74 } 74 }
75 75
76 TEST_F(BookmarkNodeDataTest, URL) { 76 TEST_F(BookmarkNodeDataTest, URL) {
77 // Write a single node representing a URL to the clipboard. 77 // Write a single node representing a URL to the clipboard.
78 TestingProfile profile; 78 TestingProfile profile;
79 profile.CreateBookmarkModel(false); 79 profile.CreateBookmarkModel(false);
80 profile.BlockUntilBookmarkModelLoaded(); 80 profile.BlockUntilBookmarkModelLoaded();
81 profile.SetID(L"id"); 81 profile.SetID(L"id");
82 BookmarkModel* model = BookmarkModelFactory::GetForProfile(&profile); 82 BookmarkModel* model = BookmarkModelFactory::GetForProfile(&profile);
83 const BookmarkNode* root = model->bookmark_bar_node(); 83 const BookmarkNode* root = model->bookmark_bar_node();
84 GURL url(GURL("http://foo.com")); 84 GURL url(GURL("http://foo.com"));
85 const string16 title(ASCIIToUTF16("blah")); 85 const string16 title(ASCIIToUTF16("foo.com"));
86 const BookmarkNode* node = model->AddURL(root, 0, title, url); 86 const BookmarkNode* node = model->AddURL(root, 0, title, url);
87 BookmarkNodeData drag_data(node); 87 BookmarkNodeData drag_data(node);
88 EXPECT_TRUE(drag_data.is_valid()); 88 EXPECT_TRUE(drag_data.is_valid());
89 ASSERT_EQ(1, drag_data.elements.size()); 89 ASSERT_EQ(1, drag_data.elements.size());
90 EXPECT_TRUE(drag_data.elements[0].is_url); 90 EXPECT_TRUE(drag_data.elements[0].is_url);
91 EXPECT_EQ(url, drag_data.elements[0].url); 91 EXPECT_EQ(url, drag_data.elements[0].url);
92 EXPECT_EQ(title, drag_data.elements[0].title); 92 EXPECT_EQ(title, drag_data.elements[0].title);
93 ui::OSExchangeData data; 93 ui::OSExchangeData data;
94 drag_data.Write(&profile, &data); 94 drag_data.Write(&profile, &data);
95 95
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // And make sure we get the node back. 238 // And make sure we get the node back.
239 std::vector<const BookmarkNode*> read_nodes = read_data.GetNodes(&profile); 239 std::vector<const BookmarkNode*> read_nodes = read_data.GetNodes(&profile);
240 ASSERT_EQ(2, read_nodes.size()); 240 ASSERT_EQ(2, read_nodes.size());
241 EXPECT_TRUE(read_nodes[0] == folder); 241 EXPECT_TRUE(read_nodes[0] == folder);
242 EXPECT_TRUE(read_nodes[1] == url_node); 242 EXPECT_TRUE(read_nodes[1] == url_node);
243 243
244 // Asking for the first node should return NULL with more than one element 244 // Asking for the first node should return NULL with more than one element
245 // present. 245 // present.
246 EXPECT_TRUE(read_data.GetFirstNode(&profile) == NULL); 246 EXPECT_TRUE(read_data.GetFirstNode(&profile) == NULL);
247 } 247 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698