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
3 // found in the LICENSE file.
5 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "base/base_paths.h"
11 #include "base/basictypes.h"
12 #include "base/command_line.h"
13 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/path_service.h"
16 #include "base/strings/string16.h"
17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
24 #include "chrome/browser/bookmarks/bookmark_test_helpers.h"
25 #include "chrome/browser/bookmarks/bookmark_utils.h"
26 #include "chrome/test/base/testing_profile.h"
27 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/base/models/tree_node_iterator.h"
30 #include "ui/base/models/tree_node_model.h"
33 using base::ASCIIToUTF16
;
35 using base::TimeDelta
;
39 // Test cases used to test the removal of extra whitespace when adding
40 // a new folder/bookmark or updating a title of a folder/bookmark.
42 const std::string input_title
;
43 const std::string expected_title
;
44 } url_whitespace_test_cases
[] = {
47 {"foo\nbar", "foo bar"},
48 {"foo\n\nbar", "foo bar"},
49 {"foo\n\n\nbar", "foo bar"},
50 {"foo\r\nbar", "foo bar"},
51 {"foo\r\n\r\nbar", "foo bar"},
52 {"\nfoo\nbar\n", "foo bar"},
54 {"foo bar", "foo bar"},
55 {" foo bar ", "foo bar"},
56 {" foo bar ", "foo bar"},
58 {"\tfoo\tbar\t", "foo bar"},
59 {"\tfoo bar\t", "foo bar"},
61 {"\tfoo\nbar\t", "foo bar"},
62 {"\tfoo\r\nbar\t", "foo bar"},
63 {" foo\tbar\n", "foo bar"},
64 {"\t foo \t bar \t", "foo bar"},
65 {"\n foo\r\n\tbar\n \t", "foo bar"},
68 // Test cases used to test the removal of extra whitespace when adding
69 // a new folder/bookmark or updating a title of a folder/bookmark.
71 const std::string input_title
;
72 const std::string expected_title
;
73 } title_whitespace_test_cases
[] = {
76 {"foo\nbar", "foo bar"},
77 {"foo\n\nbar", "foo bar"},
78 {"foo\n\n\nbar", "foo bar"},
79 {"foo\r\nbar", "foo bar"},
80 {"foo\r\n\r\nbar", "foo bar"},
81 {"\nfoo\nbar\n", " foo bar "},
83 {"foo bar", "foo bar"},
84 {" foo bar ", " foo bar "},
85 {" foo bar ", " foo bar "},
87 {"\tfoo\tbar\t", " foo bar "},
88 {"\tfoo bar\t", " foo bar "},
90 {"\tfoo\nbar\t", " foo bar "},
91 {"\tfoo\r\nbar\t", " foo bar "},
92 {" foo\tbar\n", " foo bar "},
93 {"\t foo \t bar \t", " foo bar "},
94 {"\n foo\r\n\tbar\n \t", " foo bar "},
97 // Helper to get a mutable bookmark node.
98 BookmarkNode
* AsMutable(const BookmarkNode
* node
) {
99 return const_cast<BookmarkNode
*>(node
);
102 void SwapDateAdded(BookmarkNode
* n1
, BookmarkNode
* n2
) {
103 Time tmp
= n1
->date_added();
104 n1
->set_date_added(n2
->date_added());
105 n2
->set_date_added(tmp
);
108 class BookmarkModelTest
: public testing::Test
,
109 public BookmarkModelObserver
{
111 struct ObserverDetails
{
113 Set(NULL
, NULL
, -1, -1);
116 void Set(const BookmarkNode
* node1
,
117 const BookmarkNode
* node2
,
126 void ExpectEquals(const BookmarkNode
* node1
,
127 const BookmarkNode
* node2
,
130 EXPECT_EQ(node1_
, node1
);
131 EXPECT_EQ(node2_
, node2
);
132 EXPECT_EQ(index1_
, index1
);
133 EXPECT_EQ(index2_
, index2
);
137 const BookmarkNode
* node1_
;
138 const BookmarkNode
* node2_
;
145 model_
.AddObserver(this);
149 virtual void BookmarkModelLoaded(BookmarkModel
* model
,
150 bool ids_reassigned
) OVERRIDE
{
151 // We never load from the db, so that this should never get invoked.
155 virtual void BookmarkNodeMoved(BookmarkModel
* model
,
156 const BookmarkNode
* old_parent
,
158 const BookmarkNode
* new_parent
,
159 int new_index
) OVERRIDE
{
161 observer_details_
.Set(old_parent
, new_parent
, old_index
, new_index
);
164 virtual void BookmarkNodeAdded(BookmarkModel
* model
,
165 const BookmarkNode
* parent
,
166 int index
) OVERRIDE
{
168 observer_details_
.Set(parent
, NULL
, index
, -1);
171 virtual void OnWillRemoveBookmarks(BookmarkModel
* model
,
172 const BookmarkNode
* parent
,
174 const BookmarkNode
* node
) OVERRIDE
{
175 ++before_remove_count_
;
178 virtual void BookmarkNodeRemoved(BookmarkModel
* model
,
179 const BookmarkNode
* parent
,
181 const BookmarkNode
* node
) OVERRIDE
{
183 observer_details_
.Set(parent
, NULL
, old_index
, -1);
186 virtual void BookmarkNodeChanged(BookmarkModel
* model
,
187 const BookmarkNode
* node
) OVERRIDE
{
189 observer_details_
.Set(node
, NULL
, -1, -1);
192 virtual void OnWillChangeBookmarkNode(BookmarkModel
* model
,
193 const BookmarkNode
* node
) OVERRIDE
{
194 ++before_change_count_
;
197 virtual void BookmarkNodeChildrenReordered(
198 BookmarkModel
* model
,
199 const BookmarkNode
* node
) OVERRIDE
{
203 virtual void OnWillReorderBookmarkNode(BookmarkModel
* model
,
204 const BookmarkNode
* node
) OVERRIDE
{
205 ++before_reorder_count_
;
208 virtual void BookmarkNodeFaviconChanged(BookmarkModel
* model
,
209 const BookmarkNode
* node
) OVERRIDE
{
210 // We never attempt to load favicons, so that this method never
214 virtual void ExtensiveBookmarkChangesBeginning(
215 BookmarkModel
* model
) OVERRIDE
{
216 ++extensive_changes_beginning_count_
;
219 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel
* model
) OVERRIDE
{
220 ++extensive_changes_ended_count_
;
223 virtual void BookmarkAllNodesRemoved(BookmarkModel
* model
) OVERRIDE
{
224 ++all_bookmarks_removed_
;
227 virtual void OnWillRemoveAllBookmarks(BookmarkModel
* model
) OVERRIDE
{
228 ++before_remove_all_count_
;
232 added_count_
= moved_count_
= removed_count_
= changed_count_
=
233 reordered_count_
= extensive_changes_beginning_count_
=
234 extensive_changes_ended_count_
= all_bookmarks_removed_
=
235 before_remove_count_
= before_change_count_
= before_reorder_count_
=
236 before_remove_all_count_
= 0;
239 void AssertObserverCount(int added_count
,
244 int before_remove_count
,
245 int before_change_count
,
246 int before_reorder_count
,
247 int before_remove_all_count
) {
248 EXPECT_EQ(added_count_
, added_count
);
249 EXPECT_EQ(moved_count_
, moved_count
);
250 EXPECT_EQ(removed_count_
, removed_count
);
251 EXPECT_EQ(changed_count_
, changed_count
);
252 EXPECT_EQ(reordered_count_
, reordered_count
);
253 EXPECT_EQ(before_remove_count_
, before_remove_count
);
254 EXPECT_EQ(before_change_count_
, before_change_count
);
255 EXPECT_EQ(before_reorder_count_
, before_reorder_count
);
256 EXPECT_EQ(before_remove_all_count_
, before_remove_all_count
);
259 void AssertExtensiveChangesObserverCount(
260 int extensive_changes_beginning_count
,
261 int extensive_changes_ended_count
) {
262 EXPECT_EQ(extensive_changes_beginning_count_
,
263 extensive_changes_beginning_count
);
264 EXPECT_EQ(extensive_changes_ended_count_
, extensive_changes_ended_count
);
267 int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_
; }
270 BookmarkModel model_
;
271 ObserverDetails observer_details_
;
278 int reordered_count_
;
279 int extensive_changes_beginning_count_
;
280 int extensive_changes_ended_count_
;
281 int all_bookmarks_removed_
;
282 int before_remove_count_
;
283 int before_change_count_
;
284 int before_reorder_count_
;
285 int before_remove_all_count_
;
287 DISALLOW_COPY_AND_ASSIGN(BookmarkModelTest
);
290 TEST_F(BookmarkModelTest
, InitialState
) {
291 const BookmarkNode
* bb_node
= model_
.bookmark_bar_node();
292 ASSERT_TRUE(bb_node
!= NULL
);
293 EXPECT_EQ(0, bb_node
->child_count());
294 EXPECT_EQ(BookmarkNode::BOOKMARK_BAR
, bb_node
->type());
296 const BookmarkNode
* other_node
= model_
.other_node();
297 ASSERT_TRUE(other_node
!= NULL
);
298 EXPECT_EQ(0, other_node
->child_count());
299 EXPECT_EQ(BookmarkNode::OTHER_NODE
, other_node
->type());
301 const BookmarkNode
* mobile_node
= model_
.mobile_node();
302 ASSERT_TRUE(mobile_node
!= NULL
);
303 EXPECT_EQ(0, mobile_node
->child_count());
304 EXPECT_EQ(BookmarkNode::MOBILE
, mobile_node
->type());
306 EXPECT_TRUE(bb_node
->id() != other_node
->id());
307 EXPECT_TRUE(bb_node
->id() != mobile_node
->id());
308 EXPECT_TRUE(other_node
->id() != mobile_node
->id());
311 TEST_F(BookmarkModelTest
, AddURL
) {
312 const BookmarkNode
* root
= model_
.bookmark_bar_node();
313 const base::string16
title(ASCIIToUTF16("foo"));
314 const GURL
url("http://foo.com");
316 const BookmarkNode
* new_node
= model_
.AddURL(root
, 0, title
, url
);
317 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
318 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
320 ASSERT_EQ(1, root
->child_count());
321 ASSERT_EQ(title
, new_node
->GetTitle());
322 ASSERT_TRUE(url
== new_node
->url());
323 ASSERT_EQ(BookmarkNode::URL
, new_node
->type());
324 ASSERT_TRUE(new_node
== model_
.GetMostRecentlyAddedNodeForURL(url
));
326 EXPECT_TRUE(new_node
->id() != root
->id() &&
327 new_node
->id() != model_
.other_node()->id() &&
328 new_node
->id() != model_
.mobile_node()->id());
331 TEST_F(BookmarkModelTest
, AddURLWithUnicodeTitle
) {
332 const BookmarkNode
* root
= model_
.bookmark_bar_node();
333 const base::string16
title(base::WideToUTF16(
334 L
"\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053"));
335 const GURL
url("https://www.baidu.com/");
337 const BookmarkNode
* new_node
= model_
.AddURL(root
, 0, title
, url
);
338 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
339 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
341 ASSERT_EQ(1, root
->child_count());
342 ASSERT_EQ(title
, new_node
->GetTitle());
343 ASSERT_TRUE(url
== new_node
->url());
344 ASSERT_EQ(BookmarkNode::URL
, new_node
->type());
345 ASSERT_TRUE(new_node
== model_
.GetMostRecentlyAddedNodeForURL(url
));
347 EXPECT_TRUE(new_node
->id() != root
->id() &&
348 new_node
->id() != model_
.other_node()->id() &&
349 new_node
->id() != model_
.mobile_node()->id());
352 TEST_F(BookmarkModelTest
, AddURLWithWhitespaceTitle
) {
353 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(url_whitespace_test_cases
); ++i
) {
354 const BookmarkNode
* root
= model_
.bookmark_bar_node();
355 const base::string16
title(
356 ASCIIToUTF16(url_whitespace_test_cases
[i
].input_title
));
357 const GURL
url("http://foo.com");
359 const BookmarkNode
* new_node
= model_
.AddURL(root
, i
, title
, url
);
362 EXPECT_EQ(size
, root
->child_count());
363 EXPECT_EQ(ASCIIToUTF16(url_whitespace_test_cases
[i
].expected_title
),
364 new_node
->GetTitle());
365 EXPECT_EQ(BookmarkNode::URL
, new_node
->type());
369 TEST_F(BookmarkModelTest
, AddURLToMobileBookmarks
) {
370 const BookmarkNode
* root
= model_
.mobile_node();
371 const base::string16
title(ASCIIToUTF16("foo"));
372 const GURL
url("http://foo.com");
374 const BookmarkNode
* new_node
= model_
.AddURL(root
, 0, title
, url
);
375 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
376 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
378 ASSERT_EQ(1, root
->child_count());
379 ASSERT_EQ(title
, new_node
->GetTitle());
380 ASSERT_TRUE(url
== new_node
->url());
381 ASSERT_EQ(BookmarkNode::URL
, new_node
->type());
382 ASSERT_TRUE(new_node
== model_
.GetMostRecentlyAddedNodeForURL(url
));
384 EXPECT_TRUE(new_node
->id() != root
->id() &&
385 new_node
->id() != model_
.other_node()->id() &&
386 new_node
->id() != model_
.mobile_node()->id());
389 TEST_F(BookmarkModelTest
, AddFolder
) {
390 const BookmarkNode
* root
= model_
.bookmark_bar_node();
391 const base::string16
title(ASCIIToUTF16("foo"));
393 const BookmarkNode
* new_node
= model_
.AddFolder(root
, 0, title
);
394 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
395 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
397 ASSERT_EQ(1, root
->child_count());
398 ASSERT_EQ(title
, new_node
->GetTitle());
399 ASSERT_EQ(BookmarkNode::FOLDER
, new_node
->type());
401 EXPECT_TRUE(new_node
->id() != root
->id() &&
402 new_node
->id() != model_
.other_node()->id() &&
403 new_node
->id() != model_
.mobile_node()->id());
405 // Add another folder, just to make sure folder_ids are incremented correctly.
407 model_
.AddFolder(root
, 0, title
);
408 AssertObserverCount(1, 0, 0, 0, 0, 0, 0, 0, 0);
409 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
412 TEST_F(BookmarkModelTest
, AddFolderWithWhitespaceTitle
) {
413 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(title_whitespace_test_cases
); ++i
) {
414 const BookmarkNode
* root
= model_
.bookmark_bar_node();
415 const base::string16
title(
416 ASCIIToUTF16(title_whitespace_test_cases
[i
].input_title
));
418 const BookmarkNode
* new_node
= model_
.AddFolder(root
, i
, title
);
421 EXPECT_EQ(size
, root
->child_count());
422 EXPECT_EQ(ASCIIToUTF16(title_whitespace_test_cases
[i
].expected_title
),
423 new_node
->GetTitle());
424 EXPECT_EQ(BookmarkNode::FOLDER
, new_node
->type());
428 TEST_F(BookmarkModelTest
, RemoveURL
) {
429 const BookmarkNode
* root
= model_
.bookmark_bar_node();
430 const base::string16
title(ASCIIToUTF16("foo"));
431 const GURL
url("http://foo.com");
432 model_
.AddURL(root
, 0, title
, url
);
435 model_
.Remove(root
, 0);
436 ASSERT_EQ(0, root
->child_count());
437 AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
438 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
440 // Make sure there is no mapping for the URL.
441 ASSERT_TRUE(model_
.GetMostRecentlyAddedNodeForURL(url
) == NULL
);
444 TEST_F(BookmarkModelTest
, RemoveFolder
) {
445 const BookmarkNode
* root
= model_
.bookmark_bar_node();
446 const BookmarkNode
* folder
= model_
.AddFolder(root
, 0, ASCIIToUTF16("foo"));
450 // Add a URL as a child.
451 const base::string16
title(ASCIIToUTF16("foo"));
452 const GURL
url("http://foo.com");
453 model_
.AddURL(folder
, 0, title
, url
);
457 // Now remove the folder.
458 model_
.Remove(root
, 0);
459 ASSERT_EQ(0, root
->child_count());
460 AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
461 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
463 // Make sure there is no mapping for the URL.
464 ASSERT_TRUE(model_
.GetMostRecentlyAddedNodeForURL(url
) == NULL
);
467 TEST_F(BookmarkModelTest
, RemoveAll
) {
468 const BookmarkNode
* bookmark_bar_node
= model_
.bookmark_bar_node();
472 // Add a url to bookmark bar.
473 base::string16
title(ASCIIToUTF16("foo"));
474 GURL
url("http://foo.com");
475 model_
.AddURL(bookmark_bar_node
, 0, title
, url
);
477 // Add a folder with child URL.
478 const BookmarkNode
* folder
= model_
.AddFolder(bookmark_bar_node
, 0, title
);
479 model_
.AddURL(folder
, 0, title
, url
);
481 AssertObserverCount(3, 0, 0, 0, 0, 0, 0, 0, 0);
486 EXPECT_EQ(0, bookmark_bar_node
->child_count());
487 // No individual BookmarkNodeRemoved events are fired, so removed count
489 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 1);
490 AssertExtensiveChangesObserverCount(1, 1);
491 EXPECT_EQ(1, AllNodesRemovedObserverCount());
494 TEST_F(BookmarkModelTest
, SetTitle
) {
495 const BookmarkNode
* root
= model_
.bookmark_bar_node();
496 base::string16
title(ASCIIToUTF16("foo"));
497 const GURL
url("http://foo.com");
498 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
502 title
= ASCIIToUTF16("foo2");
503 model_
.SetTitle(node
, title
);
504 AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0);
505 observer_details_
.ExpectEquals(node
, NULL
, -1, -1);
506 EXPECT_EQ(title
, node
->GetTitle());
509 TEST_F(BookmarkModelTest
, SetTitleWithWhitespace
) {
510 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(title_whitespace_test_cases
); ++i
) {
511 const BookmarkNode
* root
= model_
.bookmark_bar_node();
512 base::string16
title(ASCIIToUTF16("dummy"));
513 const GURL
url("http://foo.com");
514 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
516 title
= ASCIIToUTF16(title_whitespace_test_cases
[i
].input_title
);
517 model_
.SetTitle(node
, title
);
518 EXPECT_EQ(ASCIIToUTF16(title_whitespace_test_cases
[i
].expected_title
),
523 TEST_F(BookmarkModelTest
, SetURL
) {
524 const BookmarkNode
* root
= model_
.bookmark_bar_node();
525 const base::string16
title(ASCIIToUTF16("foo"));
526 GURL
url("http://foo.com");
527 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
531 url
= GURL("http://foo2.com");
532 model_
.SetURL(node
, url
);
533 AssertObserverCount(0, 0, 0, 1, 0, 0, 1, 0, 0);
534 observer_details_
.ExpectEquals(node
, NULL
, -1, -1);
535 EXPECT_EQ(url
, node
->url());
538 TEST_F(BookmarkModelTest
, SetDateAdded
) {
539 const BookmarkNode
* root
= model_
.bookmark_bar_node();
540 const base::string16
title(ASCIIToUTF16("foo"));
541 GURL
url("http://foo.com");
542 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
546 base::Time new_time
= base::Time::Now() + base::TimeDelta::FromMinutes(20);
547 model_
.SetDateAdded(node
, new_time
);
548 AssertObserverCount(0, 0, 0, 0, 0, 0, 0, 0, 0);
549 EXPECT_EQ(new_time
, node
->date_added());
550 EXPECT_EQ(new_time
, model_
.bookmark_bar_node()->date_folder_modified());
553 TEST_F(BookmarkModelTest
, Move
) {
554 const BookmarkNode
* root
= model_
.bookmark_bar_node();
555 const base::string16
title(ASCIIToUTF16("foo"));
556 const GURL
url("http://foo.com");
557 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
558 const BookmarkNode
* folder1
= model_
.AddFolder(root
, 0, ASCIIToUTF16("foo"));
561 model_
.Move(node
, folder1
, 0);
563 AssertObserverCount(0, 1, 0, 0, 0, 0, 0, 0, 0);
564 observer_details_
.ExpectEquals(root
, folder1
, 1, 0);
565 EXPECT_TRUE(folder1
== node
->parent());
566 EXPECT_EQ(1, root
->child_count());
567 EXPECT_EQ(folder1
, root
->GetChild(0));
568 EXPECT_EQ(1, folder1
->child_count());
569 EXPECT_EQ(node
, folder1
->GetChild(0));
571 // And remove the folder.
573 model_
.Remove(root
, 0);
574 AssertObserverCount(0, 0, 1, 0, 0, 1, 0, 0, 0);
575 observer_details_
.ExpectEquals(root
, NULL
, 0, -1);
576 EXPECT_TRUE(model_
.GetMostRecentlyAddedNodeForURL(url
) == NULL
);
577 EXPECT_EQ(0, root
->child_count());
580 TEST_F(BookmarkModelTest
, NonMovingMoveCall
) {
581 const BookmarkNode
* root
= model_
.bookmark_bar_node();
582 const base::string16
title(ASCIIToUTF16("foo"));
583 const GURL
url("http://foo.com");
584 const base::Time
old_date(base::Time::Now() - base::TimeDelta::FromDays(1));
586 const BookmarkNode
* node
= model_
.AddURL(root
, 0, title
, url
);
587 model_
.SetDateFolderModified(root
, old_date
);
589 // Since |node| is already at the index 0 of |root|, this is no-op.
590 model_
.Move(node
, root
, 0);
592 // Check that the modification date is kept untouched.
593 EXPECT_EQ(old_date
, root
->date_folder_modified());
596 TEST_F(BookmarkModelTest
, Copy
) {
597 const BookmarkNode
* root
= model_
.bookmark_bar_node();
598 static const std::string
model_string("a 1:[ b c ] d 2:[ e f g ] h ");
599 test::AddNodesFromModelString(&model_
, root
, model_string
);
601 // Validate initial model.
602 std::string actual_model_string
= test::ModelStringFromNode(root
);
603 EXPECT_EQ(model_string
, actual_model_string
);
605 // Copy 'd' to be after '1:b': URL item from bar to folder.
606 const BookmarkNode
* node_to_copy
= root
->GetChild(2);
607 const BookmarkNode
* destination
= root
->GetChild(1);
608 model_
.Copy(node_to_copy
, destination
, 1);
609 actual_model_string
= test::ModelStringFromNode(root
);
610 EXPECT_EQ("a 1:[ b d c ] d 2:[ e f g ] h ", actual_model_string
);
612 // Copy '1:d' to be after 'a': URL item from folder to bar.
613 const BookmarkNode
* folder
= root
->GetChild(1);
614 node_to_copy
= folder
->GetChild(1);
615 model_
.Copy(node_to_copy
, root
, 1);
616 actual_model_string
= test::ModelStringFromNode(root
);
617 EXPECT_EQ("a d 1:[ b d c ] d 2:[ e f g ] h ", actual_model_string
);
619 // Copy '1' to be after '2:e': Folder from bar to folder.
620 node_to_copy
= root
->GetChild(2);
621 destination
= root
->GetChild(4);
622 model_
.Copy(node_to_copy
, destination
, 1);
623 actual_model_string
= test::ModelStringFromNode(root
);
624 EXPECT_EQ("a d 1:[ b d c ] d 2:[ e 1:[ b d c ] f g ] h ",
625 actual_model_string
);
627 // Copy '2:1' to be after '2:f': Folder within same folder.
628 folder
= root
->GetChild(4);
629 node_to_copy
= folder
->GetChild(1);
630 model_
.Copy(node_to_copy
, folder
, 3);
631 actual_model_string
= test::ModelStringFromNode(root
);
632 EXPECT_EQ("a d 1:[ b d c ] d 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] h ",
633 actual_model_string
);
635 // Copy first 'd' to be after 'h': URL item within the bar.
636 node_to_copy
= root
->GetChild(1);
637 model_
.Copy(node_to_copy
, root
, 6);
638 actual_model_string
= test::ModelStringFromNode(root
);
639 EXPECT_EQ("a d 1:[ b d c ] d 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] h d ",
640 actual_model_string
);
642 // Copy '2' to be after 'a': Folder within the bar.
643 node_to_copy
= root
->GetChild(4);
644 model_
.Copy(node_to_copy
, root
, 1);
645 actual_model_string
= test::ModelStringFromNode(root
);
646 EXPECT_EQ("a 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] d 1:[ b d c ] "
647 "d 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] h d ",
648 actual_model_string
);
651 // Tests that adding a URL to a folder updates the last modified time.
652 TEST_F(BookmarkModelTest
, ParentForNewNodes
) {
653 ASSERT_EQ(model_
.bookmark_bar_node(), model_
.GetParentForNewNodes());
655 const base::string16
title(ASCIIToUTF16("foo"));
656 const GURL
url("http://foo.com");
658 model_
.AddURL(model_
.other_node(), 0, title
, url
);
659 ASSERT_EQ(model_
.other_node(), model_
.GetParentForNewNodes());
662 // Tests that adding a URL to a folder updates the last modified time.
663 TEST_F(BookmarkModelTest
, ParentForNewMobileNodes
) {
664 ASSERT_EQ(model_
.bookmark_bar_node(), model_
.GetParentForNewNodes());
666 const base::string16
title(ASCIIToUTF16("foo"));
667 const GURL
url("http://foo.com");
669 model_
.AddURL(model_
.mobile_node(), 0, title
, url
);
670 ASSERT_EQ(model_
.mobile_node(), model_
.GetParentForNewNodes());
673 // Make sure recently modified stays in sync when adding a URL.
674 TEST_F(BookmarkModelTest
, MostRecentlyModifiedFolders
) {
676 const BookmarkNode
* folder
= model_
.AddFolder(model_
.other_node(), 0,
677 ASCIIToUTF16("foo"));
679 model_
.AddURL(folder
, 0, ASCIIToUTF16("blah"), GURL("http://foo.com"));
681 // Make sure folder is in the most recently modified.
682 std::vector
<const BookmarkNode
*> most_recent_folders
=
683 bookmark_utils::GetMostRecentlyModifiedFolders(&model_
, 1);
684 ASSERT_EQ(1U, most_recent_folders
.size());
685 ASSERT_EQ(folder
, most_recent_folders
[0]);
687 // Nuke the folder and do another fetch, making sure folder isn't in the
689 model_
.Remove(folder
->parent(), 0);
690 most_recent_folders
=
691 bookmark_utils::GetMostRecentlyModifiedFolders(&model_
, 1);
692 ASSERT_EQ(1U, most_recent_folders
.size());
693 ASSERT_TRUE(most_recent_folders
[0] != folder
);
696 // Make sure MostRecentlyAddedEntries stays in sync.
697 TEST_F(BookmarkModelTest
, MostRecentlyAddedEntries
) {
698 // Add a couple of nodes such that the following holds for the time of the
699 // nodes: n1 > n2 > n3 > n4.
700 Time base_time
= Time::Now();
701 BookmarkNode
* n1
= AsMutable(model_
.AddURL(model_
.bookmark_bar_node(),
703 ASCIIToUTF16("blah"),
704 GURL("http://foo.com/0")));
705 BookmarkNode
* n2
= AsMutable(model_
.AddURL(model_
.bookmark_bar_node(),
707 ASCIIToUTF16("blah"),
708 GURL("http://foo.com/1")));
709 BookmarkNode
* n3
= AsMutable(model_
.AddURL(model_
.bookmark_bar_node(),
711 ASCIIToUTF16("blah"),
712 GURL("http://foo.com/2")));
713 BookmarkNode
* n4
= AsMutable(model_
.AddURL(model_
.bookmark_bar_node(),
715 ASCIIToUTF16("blah"),
716 GURL("http://foo.com/3")));
717 n1
->set_date_added(base_time
+ TimeDelta::FromDays(4));
718 n2
->set_date_added(base_time
+ TimeDelta::FromDays(3));
719 n3
->set_date_added(base_time
+ TimeDelta::FromDays(2));
720 n4
->set_date_added(base_time
+ TimeDelta::FromDays(1));
722 // Make sure order is honored.
723 std::vector
<const BookmarkNode
*> recently_added
;
724 bookmark_utils::GetMostRecentlyAddedEntries(&model_
, 2, &recently_added
);
725 ASSERT_EQ(2U, recently_added
.size());
726 ASSERT_TRUE(n1
== recently_added
[0]);
727 ASSERT_TRUE(n2
== recently_added
[1]);
729 // swap 1 and 2, then check again.
730 recently_added
.clear();
731 SwapDateAdded(n1
, n2
);
732 bookmark_utils::GetMostRecentlyAddedEntries(&model_
, 4, &recently_added
);
733 ASSERT_EQ(4U, recently_added
.size());
734 ASSERT_TRUE(n2
== recently_added
[0]);
735 ASSERT_TRUE(n1
== recently_added
[1]);
736 ASSERT_TRUE(n3
== recently_added
[2]);
737 ASSERT_TRUE(n4
== recently_added
[3]);
740 // Makes sure GetMostRecentlyAddedNodeForURL stays in sync.
741 TEST_F(BookmarkModelTest
, GetMostRecentlyAddedNodeForURL
) {
742 // Add a couple of nodes such that the following holds for the time of the
744 Time base_time
= Time::Now();
745 const GURL
url("http://foo.com/0");
746 BookmarkNode
* n1
= AsMutable(model_
.AddURL(
747 model_
.bookmark_bar_node(), 0, ASCIIToUTF16("blah"), url
));
748 BookmarkNode
* n2
= AsMutable(model_
.AddURL(
749 model_
.bookmark_bar_node(), 1, ASCIIToUTF16("blah"), url
));
750 n1
->set_date_added(base_time
+ TimeDelta::FromDays(4));
751 n2
->set_date_added(base_time
+ TimeDelta::FromDays(3));
753 // Make sure order is honored.
754 ASSERT_EQ(n1
, model_
.GetMostRecentlyAddedNodeForURL(url
));
756 // swap 1 and 2, then check again.
757 SwapDateAdded(n1
, n2
);
758 ASSERT_EQ(n2
, model_
.GetMostRecentlyAddedNodeForURL(url
));
761 // Makes sure GetBookmarks removes duplicates.
762 TEST_F(BookmarkModelTest
, GetBookmarksWithDups
) {
763 const GURL
url("http://foo.com/0");
764 const base::string16
title(ASCIIToUTF16("blah"));
765 model_
.AddURL(model_
.bookmark_bar_node(), 0, title
, url
);
766 model_
.AddURL(model_
.bookmark_bar_node(), 1, title
, url
);
768 std::vector
<BookmarkService::URLAndTitle
> bookmarks
;
769 model_
.GetBookmarks(&bookmarks
);
770 ASSERT_EQ(1U, bookmarks
.size());
771 EXPECT_EQ(url
, bookmarks
[0].url
);
772 EXPECT_EQ(title
, bookmarks
[0].title
);
774 model_
.AddURL(model_
.bookmark_bar_node(), 2, ASCIIToUTF16("Title2"), url
);
775 // Only one returned, even titles are different.
777 model_
.GetBookmarks(&bookmarks
);
778 EXPECT_EQ(1U, bookmarks
.size());
781 TEST_F(BookmarkModelTest
, HasBookmarks
) {
782 const GURL
url("http://foo.com/");
783 model_
.AddURL(model_
.bookmark_bar_node(), 0, ASCIIToUTF16("bar"), url
);
785 EXPECT_TRUE(model_
.HasBookmarks());
788 // See comment in PopulateNodeFromString.
789 typedef ui::TreeNodeWithValue
<BookmarkNode::Type
> TestNode
;
791 // Does the work of PopulateNodeFromString. index gives the index of the current
792 // element in description to process.
793 void PopulateNodeImpl(const std::vector
<std::string
>& description
,
796 while (*index
< description
.size()) {
797 const std::string
& element
= description
[*index
];
799 if (element
== "[") {
800 // Create a new folder and recurse to add all the children.
801 // Folders are given a unique named by way of an ever increasing integer
802 // value. The folders need not have a name, but one is assigned to help
804 static int next_folder_id
= 1;
806 new TestNode(base::IntToString16(next_folder_id
++),
807 BookmarkNode::FOLDER
);
808 parent
->Add(new_node
, parent
->child_count());
809 PopulateNodeImpl(description
, index
, new_node
);
810 } else if (element
== "]") {
811 // End the current folder.
816 // All tokens must be space separated. If there is a [ or ] in the name it
817 // likely means a space was forgotten.
818 DCHECK(element
.find('[') == std::string::npos
);
819 DCHECK(element
.find(']') == std::string::npos
);
820 parent
->Add(new TestNode(base::UTF8ToUTF16(element
), BookmarkNode::URL
),
821 parent
->child_count());
826 // Creates and adds nodes to parent based on description. description consists
827 // of the following tokens (all space separated):
828 // [ : creates a new USER_FOLDER node. All elements following the [ until the
829 // next balanced ] is encountered are added as children to the node.
830 // ] : closes the last folder created by [ so that any further nodes are added
831 // to the current folders parent.
832 // text: creates a new URL node.
833 // For example, "a [b] c" creates the following nodes:
837 // In words: a node of type URL with the title a, followed by a folder node with
838 // the title 1 having the single child of type url with name b, followed by
839 // the url node with the title c.
841 // NOTE: each name must be unique, and folders are assigned a unique title by
842 // way of an increasing integer.
843 void PopulateNodeFromString(const std::string
& description
, TestNode
* parent
) {
844 std::vector
<std::string
> elements
;
845 base::SplitStringAlongWhitespace(description
, &elements
);
847 PopulateNodeImpl(elements
, &index
, parent
);
850 // Populates the BookmarkNode with the children of parent.
851 void PopulateBookmarkNode(TestNode
* parent
,
852 BookmarkModel
* model
,
853 const BookmarkNode
* bb_node
) {
854 for (int i
= 0; i
< parent
->child_count(); ++i
) {
855 TestNode
* child
= parent
->GetChild(i
);
856 if (child
->value
== BookmarkNode::FOLDER
) {
857 const BookmarkNode
* new_bb_node
=
858 model
->AddFolder(bb_node
, i
, child
->GetTitle());
859 PopulateBookmarkNode(child
, model
, new_bb_node
);
861 model
->AddURL(bb_node
, i
, child
->GetTitle(),
862 GURL("http://" + UTF16ToASCII(child
->GetTitle())));
867 // Test class that creates a BookmarkModel with a real history backend.
868 class BookmarkModelTestWithProfile
: public testing::Test
{
870 BookmarkModelTestWithProfile()
874 virtual void TearDown() OVERRIDE
{
875 profile_
.reset(NULL
);
879 // Verifies the contents of the bookmark bar node match the contents of the
881 void VerifyModelMatchesNode(TestNode
* expected
, const BookmarkNode
* actual
) {
882 ASSERT_EQ(expected
->child_count(), actual
->child_count());
883 for (int i
= 0; i
< expected
->child_count(); ++i
) {
884 TestNode
* expected_child
= expected
->GetChild(i
);
885 const BookmarkNode
* actual_child
= actual
->GetChild(i
);
886 ASSERT_EQ(expected_child
->GetTitle(), actual_child
->GetTitle());
887 if (expected_child
->value
== BookmarkNode::FOLDER
) {
888 ASSERT_TRUE(actual_child
->type() == BookmarkNode::FOLDER
);
889 // Recurse throught children.
890 VerifyModelMatchesNode(expected_child
, actual_child
);
891 if (HasFatalFailure())
894 // No need to check the URL, just the title is enough.
895 ASSERT_TRUE(actual_child
->is_url());
900 void VerifyNoDuplicateIDs(BookmarkModel
* model
) {
901 ui::TreeNodeIterator
<const BookmarkNode
> it(model
->root_node());
902 base::hash_set
<int64
> ids
;
903 while (it
.has_next())
904 ASSERT_TRUE(ids
.insert(it
.Next()->id()).second
);
907 void BlockTillBookmarkModelLoaded() {
908 bb_model_
= BookmarkModelFactory::GetForProfile(profile_
.get());
909 test::WaitForBookmarkModelToLoad(bb_model_
);
913 scoped_ptr
<TestingProfile
> profile_
;
914 BookmarkModel
* bb_model_
;
917 content::TestBrowserThreadBundle thread_bundle_
;
920 // Creates a set of nodes in the bookmark bar model, then recreates the
921 // bookmark bar model which triggers loading from the db and checks the loaded
922 // structure to make sure it is what we first created.
923 TEST_F(BookmarkModelTestWithProfile
, CreateAndRestore
) {
925 // Structure of the children of the bookmark bar model node.
926 const std::string bbn_contents
;
927 // Structure of the children of the other node.
928 const std::string other_contents
;
929 // Structure of the children of the synced node.
930 const std::string mobile_contents
;
932 // See PopulateNodeFromString for a description of these strings.
936 { "", "[ b ] a [ c [ d e [ f ] ] ]" },
938 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
940 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(data
); ++i
) {
941 // Recreate the profile. We need to reset with NULL first so that the last
942 // HistoryService releases the locks on the files it creates and we can
944 profile_
.reset(NULL
);
945 profile_
.reset(new TestingProfile());
946 profile_
->CreateBookmarkModel(true);
947 ASSERT_TRUE(profile_
->CreateHistoryService(true, false));
948 BlockTillBookmarkModelLoaded();
951 PopulateNodeFromString(data
[i
].bbn_contents
, &bbn
);
952 PopulateBookmarkNode(&bbn
, bb_model_
, bb_model_
->bookmark_bar_node());
955 PopulateNodeFromString(data
[i
].other_contents
, &other
);
956 PopulateBookmarkNode(&other
, bb_model_
, bb_model_
->other_node());
959 PopulateNodeFromString(data
[i
].mobile_contents
, &mobile
);
960 PopulateBookmarkNode(&mobile
, bb_model_
, bb_model_
->mobile_node());
962 profile_
->CreateBookmarkModel(false);
963 BlockTillBookmarkModelLoaded();
965 VerifyModelMatchesNode(&bbn
, bb_model_
->bookmark_bar_node());
966 VerifyModelMatchesNode(&other
, bb_model_
->other_node());
967 VerifyModelMatchesNode(&mobile
, bb_model_
->mobile_node());
968 VerifyNoDuplicateIDs(bb_model_
);
972 TEST_F(BookmarkModelTest
, Sort
) {
973 // Populate the bookmark bar node with nodes for 'B', 'a', 'd' and 'C'.
974 // 'C' and 'a' are folders.
976 PopulateNodeFromString("B [ a ] d [ a ]", &bbn
);
977 const BookmarkNode
* parent
= model_
.bookmark_bar_node();
978 PopulateBookmarkNode(&bbn
, &model_
, parent
);
980 BookmarkNode
* child1
= AsMutable(parent
->GetChild(1));
981 child1
->SetTitle(ASCIIToUTF16("a"));
982 delete child1
->Remove(child1
->GetChild(0));
983 BookmarkNode
* child3
= AsMutable(parent
->GetChild(3));
984 child3
->SetTitle(ASCIIToUTF16("C"));
985 delete child3
->Remove(child3
->GetChild(0));
989 // Sort the children of the bookmark bar node.
990 model_
.SortChildren(parent
);
992 // Make sure we were notified.
993 AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0);
995 // Make sure the order matches (remember, 'a' and 'C' are folders and
997 EXPECT_EQ(parent
->GetChild(0)->GetTitle(), ASCIIToUTF16("a"));
998 EXPECT_EQ(parent
->GetChild(1)->GetTitle(), ASCIIToUTF16("C"));
999 EXPECT_EQ(parent
->GetChild(2)->GetTitle(), ASCIIToUTF16("B"));
1000 EXPECT_EQ(parent
->GetChild(3)->GetTitle(), ASCIIToUTF16("d"));
1003 TEST_F(BookmarkModelTest
, Reorder
) {
1004 // Populate the bookmark bar node with nodes 'A', 'B', 'C' and 'D'.
1006 PopulateNodeFromString("A B C D", &bbn
);
1007 BookmarkNode
* parent
= AsMutable(model_
.bookmark_bar_node());
1008 PopulateBookmarkNode(&bbn
, &model_
, parent
);
1012 // Reorder bar node's bookmarks in reverse order.
1013 std::vector
<const BookmarkNode
*> new_order
;
1014 new_order
.push_back(parent
->GetChild(3));
1015 new_order
.push_back(parent
->GetChild(2));
1016 new_order
.push_back(parent
->GetChild(1));
1017 new_order
.push_back(parent
->GetChild(0));
1018 model_
.ReorderChildren(parent
, new_order
);
1020 // Make sure we were notified.
1021 AssertObserverCount(0, 0, 0, 0, 1, 0, 0, 1, 0);
1023 // Make sure the order matches is correct (it should be reversed).
1024 ASSERT_EQ(4, parent
->child_count());
1025 EXPECT_EQ("D", UTF16ToASCII(parent
->GetChild(0)->GetTitle()));
1026 EXPECT_EQ("C", UTF16ToASCII(parent
->GetChild(1)->GetTitle()));
1027 EXPECT_EQ("B", UTF16ToASCII(parent
->GetChild(2)->GetTitle()));
1028 EXPECT_EQ("A", UTF16ToASCII(parent
->GetChild(3)->GetTitle()));
1031 TEST_F(BookmarkModelTest
, NodeVisibility
) {
1032 EXPECT_TRUE(model_
.bookmark_bar_node()->IsVisible());
1033 EXPECT_TRUE(model_
.other_node()->IsVisible());
1034 // Mobile node invisible by default
1035 EXPECT_FALSE(model_
.mobile_node()->IsVisible());
1037 // Change visibility of permanent nodes.
1038 model_
.SetPermanentNodeVisible(BookmarkNode::BOOKMARK_BAR
, false);
1039 EXPECT_FALSE(model_
.bookmark_bar_node()->IsVisible());
1040 model_
.SetPermanentNodeVisible(BookmarkNode::OTHER_NODE
, false);
1041 EXPECT_FALSE(model_
.other_node()->IsVisible());
1042 model_
.SetPermanentNodeVisible(BookmarkNode::MOBILE
, true);
1043 EXPECT_TRUE(model_
.mobile_node()->IsVisible());
1045 // Arbitrary node should be visible
1047 PopulateNodeFromString("B", &bbn
);
1048 const BookmarkNode
* parent
= model_
.bookmark_bar_node();
1049 PopulateBookmarkNode(&bbn
, &model_
, parent
);
1050 EXPECT_TRUE(parent
->GetChild(0)->IsVisible());
1052 // Bookmark bar should be visible now that it has a child.
1053 EXPECT_TRUE(model_
.bookmark_bar_node()->IsVisible());
1056 TEST_F(BookmarkModelTest
, MobileNodeVisibileWithChildren
) {
1057 const BookmarkNode
* root
= model_
.mobile_node();
1058 const base::string16
title(ASCIIToUTF16("foo"));
1059 const GURL
url("http://foo.com");
1061 model_
.AddURL(root
, 0, title
, url
);
1062 EXPECT_TRUE(model_
.mobile_node()->IsVisible());
1065 TEST_F(BookmarkModelTest
, ExtensiveChangesObserver
) {
1066 AssertExtensiveChangesObserverCount(0, 0);
1067 EXPECT_FALSE(model_
.IsDoingExtensiveChanges());
1068 model_
.BeginExtensiveChanges();
1069 EXPECT_TRUE(model_
.IsDoingExtensiveChanges());
1070 AssertExtensiveChangesObserverCount(1, 0);
1071 model_
.EndExtensiveChanges();
1072 EXPECT_FALSE(model_
.IsDoingExtensiveChanges());
1073 AssertExtensiveChangesObserverCount(1, 1);
1076 TEST_F(BookmarkModelTest
, MultipleExtensiveChangesObserver
) {
1077 AssertExtensiveChangesObserverCount(0, 0);
1078 EXPECT_FALSE(model_
.IsDoingExtensiveChanges());
1079 model_
.BeginExtensiveChanges();
1080 EXPECT_TRUE(model_
.IsDoingExtensiveChanges());
1081 AssertExtensiveChangesObserverCount(1, 0);
1082 model_
.BeginExtensiveChanges();
1083 EXPECT_TRUE(model_
.IsDoingExtensiveChanges());
1084 AssertExtensiveChangesObserverCount(1, 0);
1085 model_
.EndExtensiveChanges();
1086 EXPECT_TRUE(model_
.IsDoingExtensiveChanges());
1087 AssertExtensiveChangesObserverCount(1, 0);
1088 model_
.EndExtensiveChanges();
1089 EXPECT_FALSE(model_
.IsDoingExtensiveChanges());
1090 AssertExtensiveChangesObserverCount(1, 1);
1093 TEST(BookmarkNodeTest
, NodeMetaInfo
) {
1095 BookmarkNode
node(url
);
1096 EXPECT_FALSE(node
.GetMetaInfoMap());
1098 EXPECT_TRUE(node
.SetMetaInfo("key1", "value1"));
1099 std::string out_value
;
1100 EXPECT_TRUE(node
.GetMetaInfo("key1", &out_value
));
1101 EXPECT_EQ("value1", out_value
);
1102 EXPECT_FALSE(node
.SetMetaInfo("key1", "value1"));
1104 EXPECT_FALSE(node
.GetMetaInfo("key2.subkey1", &out_value
));
1105 EXPECT_TRUE(node
.SetMetaInfo("key2.subkey1", "value2"));
1106 EXPECT_TRUE(node
.GetMetaInfo("key2.subkey1", &out_value
));
1107 EXPECT_EQ("value2", out_value
);
1109 EXPECT_FALSE(node
.GetMetaInfo("key2.subkey2.leaf", &out_value
));
1110 EXPECT_TRUE(node
.SetMetaInfo("key2.subkey2.leaf", ""));
1111 EXPECT_TRUE(node
.GetMetaInfo("key2.subkey2.leaf", &out_value
));
1112 EXPECT_EQ("", out_value
);
1114 EXPECT_TRUE(node
.DeleteMetaInfo("key1"));
1115 EXPECT_TRUE(node
.DeleteMetaInfo("key2.subkey1"));
1116 EXPECT_TRUE(node
.DeleteMetaInfo("key2.subkey2.leaf"));
1117 EXPECT_FALSE(node
.DeleteMetaInfo("key3"));
1118 EXPECT_FALSE(node
.GetMetaInfo("key1", &out_value
));
1119 EXPECT_FALSE(node
.GetMetaInfo("key2.subkey1", &out_value
));
1120 EXPECT_FALSE(node
.GetMetaInfo("key2.subkey2", &out_value
));
1121 EXPECT_FALSE(node
.GetMetaInfo("key2.subkey2.leaf", &out_value
));
1122 EXPECT_FALSE(node
.GetMetaInfoMap());