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

Unified Diff: components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc
diff --git a/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc b/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc
index f76a19688d10f41cf17fd2f07a8a15a302c12a27..3cd88d9ffe9d7563b8375ca6992e3f23a3dbbb7b 100644
--- a/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc
+++ b/components/bookmarks/managed/managed_bookmarks_tracker_unittest.cc
@@ -111,22 +111,21 @@ class ManagedBookmarksTrackerTest : public testing::Test {
static std::unique_ptr<base::DictionaryValue> CreateFolder(
const std::string& title,
- base::ListValue* children) {
+ std::unique_ptr<base::ListValue> children) {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString("name", title);
- dict->Set("children", children);
+ dict->Set("children", std::move(children));
return dict;
}
- static base::ListValue* CreateTestTree() {
- base::ListValue* folder = new base::ListValue();
- base::ListValue* empty = new base::ListValue();
- folder->Append(CreateFolder("Empty", empty));
+ static std::unique_ptr<base::ListValue> CreateTestTree() {
+ auto folder = base::MakeUnique<base::ListValue>();
+ folder->Append(CreateFolder("Empty", base::MakeUnique<base::ListValue>()));
folder->Append(CreateBookmark("Youtube", "http://youtube.com/"));
- base::ListValue* list = new base::ListValue();
+ auto list = base::MakeUnique<base::ListValue>();
list->Append(CreateBookmark("Google", "http://google.com/"));
- list->Append(CreateFolder("Folder", folder));
+ list->Append(CreateFolder("Folder", std::move(folder)));
return list;
}
@@ -248,12 +247,12 @@ TEST_F(ManagedBookmarksTrackerTest, SwapNodes) {
// These two nodes should just be swapped.
const BookmarkNode* parent = managed_node();
EXPECT_CALL(observer_, BookmarkNodeMoved(model_.get(), parent, 1, parent, 0));
- prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->DeepCopy());
+ prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->CreateDeepCopy());
Mock::VerifyAndClearExpectations(&observer_);
// Verify the final tree.
std::unique_ptr<base::DictionaryValue> expected(
- CreateFolder(GetManagedFolderTitle(), updated.release()));
+ CreateFolder(GetManagedFolderTitle(), std::move(updated)));
EXPECT_TRUE(NodeMatchesValue(managed_node(), expected.get()));
}
@@ -267,12 +266,12 @@ TEST_F(ManagedBookmarksTrackerTest, RemoveNode) {
const BookmarkNode* parent = managed_node();
EXPECT_CALL(observer_, BookmarkNodeRemoved(model_.get(), parent, 1, _, _));
- prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->DeepCopy());
+ prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->CreateDeepCopy());
Mock::VerifyAndClearExpectations(&observer_);
// Verify the final tree.
std::unique_ptr<base::DictionaryValue> expected(
- CreateFolder(GetManagedFolderTitle(), updated.release()));
+ CreateFolder(GetManagedFolderTitle(), std::move(updated)));
EXPECT_TRUE(NodeMatchesValue(managed_node(), expected.get()));
}
@@ -290,12 +289,12 @@ TEST_F(ManagedBookmarksTrackerTest, CreateNewNodes) {
const BookmarkNode* parent = managed_node();
EXPECT_CALL(observer_, BookmarkNodeRemoved(model_.get(), parent, 1, _, _))
.Times(2);
- prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->DeepCopy());
+ prefs_.SetManagedPref(prefs::kManagedBookmarks, updated->CreateDeepCopy());
Mock::VerifyAndClearExpectations(&observer_);
// Verify the final tree.
std::unique_ptr<base::DictionaryValue> expected(
- CreateFolder(GetManagedFolderTitle(), updated.release()));
+ CreateFolder(GetManagedFolderTitle(), std::move(updated)));
EXPECT_TRUE(NodeMatchesValue(managed_node(), expected.get()));
}

Powered by Google App Engine
This is Rietveld 408576698