OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // TODO(akalin): This file is basically just a unit test for | 5 // TODO(akalin): This file is basically just a unit test for |
6 // BookmarkChangeProcessor. Write unit tests for | 6 // BookmarkChangeProcessor. Write unit tests for |
7 // BookmarkModelAssociator separately. | 7 // BookmarkModelAssociator separately. |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 node.SetTitle(title); | 430 node.SetTitle(title); |
431 node.SetBookmarkSpecifics(specifics); | 431 node.SetBookmarkSpecifics(specifics); |
432 | 432 |
433 return node.GetId(); | 433 return node.GetId(); |
434 } | 434 } |
435 | 435 |
436 // Create a BookmarkModel. If |delete_bookmarks| is true, the bookmarks file | 436 // Create a BookmarkModel. If |delete_bookmarks| is true, the bookmarks file |
437 // will be deleted before starting up the BookmarkModel. | 437 // will be deleted before starting up the BookmarkModel. |
438 std::unique_ptr<BookmarkModel> CreateBookmarkModel(bool delete_bookmarks) { | 438 std::unique_ptr<BookmarkModel> CreateBookmarkModel(bool delete_bookmarks) { |
439 const base::FilePath& data_path = data_dir_.path(); | 439 const base::FilePath& data_path = data_dir_.path(); |
440 auto model = base::WrapUnique(new BookmarkModel( | 440 auto model = base::MakeUnique<BookmarkModel>( |
441 base::WrapUnique(new bookmarks::TestBookmarkClient()))); | 441 base::WrapUnique(new bookmarks::TestBookmarkClient())); |
442 managed_bookmark_service_->BookmarkModelCreated(model.get()); | 442 managed_bookmark_service_->BookmarkModelCreated(model.get()); |
443 int64_t next_id = 0; | 443 int64_t next_id = 0; |
444 static_cast<bookmarks::TestBookmarkClient*>(model->client()) | 444 static_cast<bookmarks::TestBookmarkClient*>(model->client()) |
445 ->SetExtraNodesToLoad( | 445 ->SetExtraNodesToLoad( |
446 managed_bookmark_service_->GetLoadExtraNodesCallback().Run( | 446 managed_bookmark_service_->GetLoadExtraNodesCallback().Run( |
447 &next_id)); | 447 &next_id)); |
448 if (delete_bookmarks) { | 448 if (delete_bookmarks) { |
449 base::DeleteFile(data_path.Append(FILE_PATH_LITERAL("dummy_bookmarks")), | 449 base::DeleteFile(data_path.Append(FILE_PATH_LITERAL("dummy_bookmarks")), |
450 false); | 450 false); |
451 } | 451 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 780 |
781 syncer::TestUserShare* test_user_share() { return &test_user_share_; } | 781 syncer::TestUserShare* test_user_share() { return &test_user_share_; } |
782 | 782 |
783 BookmarkChangeProcessor* change_processor() { | 783 BookmarkChangeProcessor* change_processor() { |
784 return change_processor_.get(); | 784 return change_processor_.get(); |
785 } | 785 } |
786 | 786 |
787 void delete_change_processor() { change_processor_.reset(); } | 787 void delete_change_processor() { change_processor_.reset(); } |
788 | 788 |
789 void ResetChangeProcessor() { | 789 void ResetChangeProcessor() { |
790 change_processor_ = base::WrapUnique(new BookmarkChangeProcessor( | 790 change_processor_ = base::MakeUnique<BookmarkChangeProcessor>( |
791 sync_client_.get(), model_associator_.get(), &mock_error_handler_)); | 791 sync_client_.get(), model_associator_.get(), &mock_error_handler_); |
792 } | 792 } |
793 | 793 |
794 syncer::DataTypeErrorHandlerMock* mock_error_handler() { | 794 syncer::DataTypeErrorHandlerMock* mock_error_handler() { |
795 return &mock_error_handler_; | 795 return &mock_error_handler_; |
796 } | 796 } |
797 | 797 |
798 void delete_model_associator() { model_associator_.reset(); } | 798 void delete_model_associator() { model_associator_.reset(); } |
799 | 799 |
800 BookmarkModelAssociator* model_associator() { | 800 BookmarkModelAssociator* model_associator() { |
801 return model_associator_.get(); | 801 return model_associator_.get(); |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 EXPECT_EQ(syncer::kInvalidId, sync_id); | 2585 EXPECT_EQ(syncer::kInvalidId, sync_id); |
2586 | 2586 |
2587 // Verify that Sync ignores deleting this node. | 2587 // Verify that Sync ignores deleting this node. |
2588 model()->Remove(node); | 2588 model()->Remove(node); |
2589 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount()); | 2589 EXPECT_EQ(sync_bookmark_count, GetSyncBookmarkCount()); |
2590 } | 2590 } |
2591 | 2591 |
2592 } // namespace | 2592 } // namespace |
2593 | 2593 |
2594 } // namespace browser_sync | 2594 } // namespace browser_sync |
OLD | NEW |