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

Side by Side Diff: components/bookmarks/browser/bookmark_model_unittest.cc

Issue 1906973002: Convert //components/bookmarks from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/browser/bookmark_model.h" 5 #include "components/bookmarks/browser/bookmark_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ++grouped_changes_beginning_count_; 363 ++grouped_changes_beginning_count_;
364 } 364 }
365 365
366 void GroupedBookmarkChangesEnded(BookmarkModel* model) override { 366 void GroupedBookmarkChangesEnded(BookmarkModel* model) override {
367 ++grouped_changes_ended_count_; 367 ++grouped_changes_ended_count_;
368 } 368 }
369 369
370 void OnBookmarkNodeRemoved(BookmarkModel* model, 370 void OnBookmarkNodeRemoved(BookmarkModel* model,
371 const BookmarkNode* parent, 371 const BookmarkNode* parent,
372 int index, 372 int index,
373 scoped_ptr<BookmarkNode> node) override { 373 std::unique_ptr<BookmarkNode> node) override {
374 node_removal_details_.push_back( 374 node_removal_details_.push_back(
375 NodeRemovalDetail(parent, index, node.get())); 375 NodeRemovalDetail(parent, index, node.get()));
376 } 376 }
377 377
378 void ClearCounts() { 378 void ClearCounts() {
379 added_count_ = moved_count_ = removed_count_ = changed_count_ = 379 added_count_ = moved_count_ = removed_count_ = changed_count_ =
380 reordered_count_ = extensive_changes_beginning_count_ = 380 reordered_count_ = extensive_changes_beginning_count_ =
381 extensive_changes_ended_count_ = all_bookmarks_removed_ = 381 extensive_changes_ended_count_ = all_bookmarks_removed_ =
382 before_remove_count_ = before_change_count_ = before_reorder_count_ = 382 before_remove_count_ = before_change_count_ = before_reorder_count_ =
383 before_remove_all_count_ = grouped_changes_beginning_count_ = 383 before_remove_all_count_ = grouped_changes_beginning_count_ =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_; } 423 int AllNodesRemovedObserverCount() const { return all_bookmarks_removed_; }
424 424
425 BookmarkPermanentNode* ReloadModelWithExtraNode() { 425 BookmarkPermanentNode* ReloadModelWithExtraNode() {
426 model_->RemoveObserver(this); 426 model_->RemoveObserver(this);
427 427
428 BookmarkPermanentNode* extra_node = new BookmarkPermanentNode(100); 428 BookmarkPermanentNode* extra_node = new BookmarkPermanentNode(100);
429 BookmarkPermanentNodeList extra_nodes; 429 BookmarkPermanentNodeList extra_nodes;
430 extra_nodes.push_back(extra_node); 430 extra_nodes.push_back(extra_node);
431 431
432 scoped_ptr<TestBookmarkClient> client(new TestBookmarkClient); 432 std::unique_ptr<TestBookmarkClient> client(new TestBookmarkClient);
433 client->SetExtraNodesToLoad(std::move(extra_nodes)); 433 client->SetExtraNodesToLoad(std::move(extra_nodes));
434 434
435 model_ = TestBookmarkClient::CreateModelWithClient(std::move(client)); 435 model_ = TestBookmarkClient::CreateModelWithClient(std::move(client));
436 model_->AddObserver(this); 436 model_->AddObserver(this);
437 ClearCounts(); 437 ClearCounts();
438 438
439 if (model_->root_node()->GetIndexOf(extra_node) == -1) 439 if (model_->root_node()->GetIndexOf(extra_node) == -1)
440 ADD_FAILURE(); 440 ADD_FAILURE();
441 441
442 return extra_node; 442 return extra_node;
443 } 443 }
444 444
445 protected: 445 protected:
446 scoped_ptr<BookmarkModel> model_; 446 std::unique_ptr<BookmarkModel> model_;
447 ObserverDetails observer_details_; 447 ObserverDetails observer_details_;
448 std::vector<NodeRemovalDetail> node_removal_details_; 448 std::vector<NodeRemovalDetail> node_removal_details_;
449 449
450 private: 450 private:
451 int added_count_; 451 int added_count_;
452 int moved_count_; 452 int moved_count_;
453 int removed_count_; 453 int removed_count_;
454 int changed_count_; 454 int changed_count_;
455 int reordered_count_; 455 int reordered_count_;
456 int extensive_changes_beginning_count_; 456 int extensive_changes_beginning_count_;
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 const std::string mobile_contents; 1226 const std::string mobile_contents;
1227 } data[] = { 1227 } data[] = {
1228 // See PopulateNodeFromString for a description of these strings. 1228 // See PopulateNodeFromString for a description of these strings.
1229 { "", "" }, 1229 { "", "" },
1230 { "a", "b" }, 1230 { "a", "b" },
1231 { "a [ b ]", "" }, 1231 { "a [ b ]", "" },
1232 { "", "[ b ] a [ c [ d e [ f ] ] ]" }, 1232 { "", "[ b ] a [ c [ d e [ f ] ] ]" },
1233 { "a [ b ]", "" }, 1233 { "a [ b ]", "" },
1234 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"}, 1234 { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
1235 }; 1235 };
1236 scoped_ptr<BookmarkModel> model; 1236 std::unique_ptr<BookmarkModel> model;
1237 for (size_t i = 0; i < arraysize(data); ++i) { 1237 for (size_t i = 0; i < arraysize(data); ++i) {
1238 model = TestBookmarkClient::CreateModel(); 1238 model = TestBookmarkClient::CreateModel();
1239 1239
1240 TestNode bbn; 1240 TestNode bbn;
1241 PopulateNodeFromString(data[i].bbn_contents, &bbn); 1241 PopulateNodeFromString(data[i].bbn_contents, &bbn);
1242 PopulateBookmarkNode(&bbn, model.get(), model->bookmark_bar_node()); 1242 PopulateBookmarkNode(&bbn, model.get(), model->bookmark_bar_node());
1243 1243
1244 TestNode other; 1244 TestNode other;
1245 PopulateNodeFromString(data[i].other_contents, &other); 1245 PopulateNodeFromString(data[i].other_contents, &other);
1246 PopulateBookmarkNode(&other, model.get(), model->other_node()); 1246 PopulateBookmarkNode(&other, model.get(), model->other_node());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 } 1319 }
1320 1320
1321 void BookmarkNodeChildrenReordered(BookmarkModel* model, 1321 void BookmarkNodeChildrenReordered(BookmarkModel* model,
1322 const BookmarkNode* node) override {} 1322 const BookmarkNode* node) override {}
1323 1323
1324 void BookmarkAllUserNodesRemoved( 1324 void BookmarkAllUserNodesRemoved(
1325 BookmarkModel* model, 1325 BookmarkModel* model,
1326 const std::set<GURL>& removed_urls) override { 1326 const std::set<GURL>& removed_urls) override {
1327 } 1327 }
1328 1328
1329 scoped_ptr<BookmarkModel> model_; 1329 std::unique_ptr<BookmarkModel> model_;
1330 std::vector<const BookmarkNode*> updated_nodes_; 1330 std::vector<const BookmarkNode*> updated_nodes_;
1331 1331
1332 private: 1332 private:
1333 DISALLOW_COPY_AND_ASSIGN(BookmarkModelFaviconTest); 1333 DISALLOW_COPY_AND_ASSIGN(BookmarkModelFaviconTest);
1334 }; 1334 };
1335 1335
1336 // Test that BookmarkModel::OnFaviconsChanged() sends a notification that the 1336 // Test that BookmarkModel::OnFaviconsChanged() sends a notification that the
1337 // favicon changed to each BookmarkNode which has either a matching page URL 1337 // favicon changed to each BookmarkNode which has either a matching page URL
1338 // (e.g. http://www.google.com) or a matching icon URL 1338 // (e.g. http://www.google.com) or a matching icon URL
1339 // (e.g. http://www.google.com/favicon.ico). 1339 // (e.g. http://www.google.com/favicon.ico).
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 std::set<GURL> changed_page_urls; 1394 std::set<GURL> changed_page_urls;
1395 changed_page_urls.insert(kPageURL1); 1395 changed_page_urls.insert(kPageURL1);
1396 model_->OnFaviconsChanged(changed_page_urls, kFaviconURL12); 1396 model_->OnFaviconsChanged(changed_page_urls, kFaviconURL12);
1397 ASSERT_EQ(2u, updated_nodes_.size()); 1397 ASSERT_EQ(2u, updated_nodes_.size());
1398 EXPECT_TRUE(WasNodeUpdated(node1)); 1398 EXPECT_TRUE(WasNodeUpdated(node1));
1399 EXPECT_TRUE(WasNodeUpdated(node2)); 1399 EXPECT_TRUE(WasNodeUpdated(node2));
1400 } 1400 }
1401 } 1401 }
1402 1402
1403 } // namespace bookmarks 1403 } // namespace bookmarks
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_model.cc ('k') | components/bookmarks/browser/bookmark_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698