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

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

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 14 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
14 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 15 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 17 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/bookmarks/browser/bookmark_node.h" 18 #include "components/bookmarks/browser/bookmark_node.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 std::unique_ptr<base::DictionaryValue> expected(CreateExpectedTree()); 163 std::unique_ptr<base::DictionaryValue> expected(CreateExpectedTree());
163 EXPECT_TRUE(NodeMatchesValue(managed_->managed_node(), expected.get())); 164 EXPECT_TRUE(NodeMatchesValue(managed_->managed_node(), expected.get()));
164 } 165 }
165 166
166 TEST_F(ManagedBookmarkServiceTest, SwapNodes) { 167 TEST_F(ManagedBookmarkServiceTest, SwapNodes) {
167 // Swap the Google bookmark with the Folder. 168 // Swap the Google bookmark with the Folder.
168 std::unique_ptr<base::ListValue> updated(CreateTestTree()); 169 std::unique_ptr<base::ListValue> updated(CreateTestTree());
169 std::unique_ptr<base::Value> removed; 170 std::unique_ptr<base::Value> removed;
170 ASSERT_TRUE(updated->Remove(0, &removed)); 171 ASSERT_TRUE(updated->Remove(0, &removed));
171 updated->Append(removed.release()); 172 updated->Append(std::move(removed));
172 173
173 // These two nodes should just be swapped. 174 // These two nodes should just be swapped.
174 const BookmarkNode* parent = managed_->managed_node(); 175 const BookmarkNode* parent = managed_->managed_node();
175 EXPECT_CALL(observer_, BookmarkNodeMoved(model_, parent, 1, parent, 0)); 176 EXPECT_CALL(observer_, BookmarkNodeMoved(model_, parent, 1, parent, 0));
176 prefs_->SetManagedPref(bookmarks::prefs::kManagedBookmarks, 177 prefs_->SetManagedPref(bookmarks::prefs::kManagedBookmarks,
177 updated->DeepCopy()); 178 updated->DeepCopy());
178 Mock::VerifyAndClearExpectations(&observer_); 179 Mock::VerifyAndClearExpectations(&observer_);
179 180
180 // Verify the final tree. 181 // Verify the final tree.
181 std::unique_ptr<base::DictionaryValue> expected( 182 std::unique_ptr<base::DictionaryValue> expected(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 const BookmarkNode* managed_node = managed_->managed_node()->GetChild(0); 287 const BookmarkNode* managed_node = managed_->managed_node()->GetChild(0);
287 ASSERT_TRUE(managed_node); 288 ASSERT_TRUE(managed_node);
288 289
289 std::vector<const BookmarkNode*> nodes; 290 std::vector<const BookmarkNode*> nodes;
290 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 291 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
291 nodes.push_back(user_node); 292 nodes.push_back(user_node);
292 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 293 EXPECT_FALSE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
293 nodes.push_back(managed_node); 294 nodes.push_back(managed_node);
294 EXPECT_TRUE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node())); 295 EXPECT_TRUE(bookmarks::HasDescendantsOf(nodes, managed_->managed_node()));
295 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698