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

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

Issue 2014103002: Remove deprecated ListValue::Append(Value*) overload on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ADL fail Created 4 years, 3 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
« no previous file with comments | « base/values.cc ('k') | chrome/browser/custom_handlers/protocol_handler_registry.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/bookmarks/managed/managed_bookmark_service.h" 5 #include "components/bookmarks/managed/managed_bookmark_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
14 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 15 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
15 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 16 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "components/bookmarks/browser/bookmark_model.h" 18 #include "components/bookmarks/browser/bookmark_model.h"
18 #include "components/bookmarks/browser/bookmark_node.h" 19 #include "components/bookmarks/browser/bookmark_node.h"
19 #include "components/bookmarks/browser/bookmark_utils.h" 20 #include "components/bookmarks/browser/bookmark_utils.h"
20 #include "components/bookmarks/common/bookmark_pref_names.h" 21 #include "components/bookmarks/common/bookmark_pref_names.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 57
57 void ResetModel() { 58 void ResetModel() {
58 profile_.CreateBookmarkModel(false); 59 profile_.CreateBookmarkModel(false);
59 model_ = BookmarkModelFactory::GetForBrowserContext(&profile_); 60 model_ = BookmarkModelFactory::GetForBrowserContext(&profile_);
60 bookmarks::test::WaitForBookmarkModelToLoad(model_); 61 bookmarks::test::WaitForBookmarkModelToLoad(model_);
61 model_->AddObserver(&observer_); 62 model_->AddObserver(&observer_);
62 managed_ = ManagedBookmarkServiceFactory::GetForProfile(&profile_); 63 managed_ = ManagedBookmarkServiceFactory::GetForProfile(&profile_);
63 DCHECK(managed_); 64 DCHECK(managed_);
64 } 65 }
65 66
66 static base::DictionaryValue* CreateBookmark(const std::string& title, 67 static std::unique_ptr<base::DictionaryValue> CreateBookmark(
67 const std::string& url) { 68 const std::string& title,
69 const std::string& url) {
68 EXPECT_TRUE(GURL(url).is_valid()); 70 EXPECT_TRUE(GURL(url).is_valid());
69 base::DictionaryValue* dict = new base::DictionaryValue(); 71 auto dict = base::MakeUnique<base::DictionaryValue>();
70 dict->SetString("name", title); 72 dict->SetString("name", title);
71 dict->SetString("url", GURL(url).spec()); 73 dict->SetString("url", GURL(url).spec());
72 return dict; 74 return dict;
73 } 75 }
74 76
75 static base::DictionaryValue* CreateFolder(const std::string& title, 77 static std::unique_ptr<base::DictionaryValue> CreateFolder(
76 base::ListValue* children) { 78 const std::string& title,
77 base::DictionaryValue* dict = new base::DictionaryValue(); 79 base::ListValue* children) {
80 auto dict = base::MakeUnique<base::DictionaryValue>();
78 dict->SetString("name", title); 81 dict->SetString("name", title);
79 dict->Set("children", children); 82 dict->Set("children", children);
80 return dict; 83 return dict;
81 } 84 }
82 85
83 static base::ListValue* CreateTestTree() { 86 static base::ListValue* CreateTestTree() {
84 base::ListValue* folder = new base::ListValue(); 87 base::ListValue* folder = new base::ListValue();
85 base::ListValue* empty = new base::ListValue(); 88 base::ListValue* empty = new base::ListValue();
86 folder->Append(CreateFolder("Empty", empty)); 89 folder->Append(CreateFolder("Empty", empty));
87 folder->Append(CreateBookmark("Youtube", "http://youtube.com/")); 90 folder->Append(CreateBookmark("Youtube", "http://youtube.com/"));
88 91
89 base::ListValue* list = new base::ListValue(); 92 base::ListValue* list = new base::ListValue();
90 list->Append(CreateBookmark("Google", "http://google.com/")); 93 list->Append(CreateBookmark("Google", "http://google.com/"));
91 list->Append(CreateFolder("Folder", folder)); 94 list->Append(CreateFolder("Folder", folder));
92 95
93 return list; 96 return list;
94 } 97 }
95 98
96 static base::DictionaryValue* CreateExpectedTree() { 99 static std::unique_ptr<base::DictionaryValue> CreateExpectedTree() {
97 return CreateFolder(GetManagedFolderTitle(), CreateTestTree()); 100 return CreateFolder(GetManagedFolderTitle(), CreateTestTree());
98 } 101 }
99 102
100 static std::string GetManagedFolderTitle() { 103 static std::string GetManagedFolderTitle() {
101 return l10n_util::GetStringUTF8( 104 return l10n_util::GetStringUTF8(
102 IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME); 105 IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME);
103 } 106 }
104 107
105 static bool NodeMatchesValue(const BookmarkNode* node, 108 static bool NodeMatchesValue(const BookmarkNode* node,
106 const base::DictionaryValue* dict) { 109 const base::DictionaryValue* dict) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const BookmarkNode* managed_node = managed_->managed_node()->GetChild(0); 290 const BookmarkNode* managed_node = managed_->managed_node()->GetChild(0);
288 ASSERT_TRUE(managed_node); 291 ASSERT_TRUE(managed_node);
289 292
290 std::vector<const BookmarkNode*> nodes; 293 std::vector<const BookmarkNode*> nodes;
291 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 294 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
292 nodes.push_back(user_node); 295 nodes.push_back(user_node);
293 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 296 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
294 nodes.push_back(managed_node); 297 nodes.push_back(managed_node);
295 EXPECT_TRUE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 298 EXPECT_TRUE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
296 } 299 }
OLDNEW
« no previous file with comments | « base/values.cc ('k') | chrome/browser/custom_handlers/protocol_handler_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698