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

Side by Side Diff: components/sync_bookmarks/bookmark_data_type_controller_unittest.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 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 (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 #include "components/sync_bookmarks/bookmark_data_type_controller.h" 5 #include "components/sync_bookmarks/bookmark_data_type_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 12 matching lines...) Expand all
23 #include "components/sync/driver/data_type_controller_mock.h" 23 #include "components/sync/driver/data_type_controller_mock.h"
24 #include "components/sync/driver/fake_sync_client.h" 24 #include "components/sync/driver/fake_sync_client.h"
25 #include "components/sync/driver/fake_sync_service.h" 25 #include "components/sync/driver/fake_sync_service.h"
26 #include "components/sync/driver/model_associator_mock.h" 26 #include "components/sync/driver/model_associator_mock.h"
27 #include "components/sync/driver/sync_api_component_factory_mock.h" 27 #include "components/sync/driver/sync_api_component_factory_mock.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using bookmarks::BookmarkModel; 31 using bookmarks::BookmarkModel;
32 using sync_bookmarks::BookmarkDataTypeController; 32 using sync_bookmarks::BookmarkDataTypeController;
33 using syncer::ChangeProcessorMock; 33 using sync_driver::ChangeProcessorMock;
34 using syncer::DataTypeController; 34 using sync_driver::DataTypeController;
35 using syncer::ModelAssociatorMock; 35 using sync_driver::ModelAssociatorMock;
36 using syncer::ModelLoadCallbackMock; 36 using sync_driver::ModelLoadCallbackMock;
37 using syncer::StartCallbackMock; 37 using sync_driver::StartCallbackMock;
38 using testing::_; 38 using testing::_;
39 using testing::DoAll; 39 using testing::DoAll;
40 using testing::InvokeWithoutArgs; 40 using testing::InvokeWithoutArgs;
41 using testing::Return; 41 using testing::Return;
42 using testing::SetArgumentPointee; 42 using testing::SetArgumentPointee;
43 43
44 namespace { 44 namespace {
45 45
46 class HistoryMock : public history::HistoryService { 46 class HistoryMock : public history::HistoryService {
47 public: 47 public:
48 HistoryMock() : history::HistoryService() {} 48 HistoryMock() : history::HistoryService() {}
49 MOCK_METHOD0(BackendLoaded, bool(void)); 49 MOCK_METHOD0(BackendLoaded, bool(void));
50 50
51 ~HistoryMock() override {} 51 ~HistoryMock() override {}
52 }; 52 };
53 53
54 } // namespace 54 } // namespace
55 55
56 class SyncBookmarkDataTypeControllerTest : public testing::Test, 56 class SyncBookmarkDataTypeControllerTest : public testing::Test,
57 public syncer::FakeSyncClient { 57 public sync_driver::FakeSyncClient {
58 public: 58 public:
59 SyncBookmarkDataTypeControllerTest() {} 59 SyncBookmarkDataTypeControllerTest() {}
60 60
61 // FakeSyncClient overrides. 61 // FakeSyncClient overrides.
62 BookmarkModel* GetBookmarkModel() override { return bookmark_model_.get(); } 62 BookmarkModel* GetBookmarkModel() override { return bookmark_model_.get(); }
63 history::HistoryService* GetHistoryService() override { 63 history::HistoryService* GetHistoryService() override {
64 return history_service_.get(); 64 return history_service_.get();
65 } 65 }
66 syncer::SyncService* GetSyncService() override { return &service_; } 66 sync_driver::SyncService* GetSyncService() override {
67 syncer::SyncApiComponentFactory* GetSyncApiComponentFactory() override { 67 return &service_;
68 }
69 sync_driver::SyncApiComponentFactory* GetSyncApiComponentFactory() override {
68 return profile_sync_factory_.get(); 70 return profile_sync_factory_.get();
69 } 71 }
70 72
71 void SetUp() override { 73 void SetUp() override {
72 model_associator_ = new ModelAssociatorMock(); 74 model_associator_ = new ModelAssociatorMock();
73 change_processor_ = new ChangeProcessorMock(); 75 change_processor_ = new ChangeProcessorMock();
74 history_service_.reset(new HistoryMock()); 76 history_service_.reset(new HistoryMock());
75 profile_sync_factory_.reset(new syncer::SyncApiComponentFactoryMock( 77 profile_sync_factory_.reset(
76 model_associator_, change_processor_)); 78 new SyncApiComponentFactoryMock(model_associator_,
79 change_processor_));
77 bookmark_dtc_.reset( 80 bookmark_dtc_.reset(
78 new BookmarkDataTypeController(base::Bind(&base::DoNothing), this)); 81 new BookmarkDataTypeController(base::Bind(&base::DoNothing), this));
79 } 82 }
80 83
81 protected: 84 protected:
82 enum BookmarkLoadPolicy { 85 enum BookmarkLoadPolicy {
83 DONT_LOAD_MODEL, 86 DONT_LOAD_MODEL,
84 LOAD_MODEL, 87 LOAD_MODEL,
85 }; 88 };
86 89
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 base::Bind(&StartCallbackMock::Run, 127 base::Bind(&StartCallbackMock::Run,
125 base::Unretained(&start_callback_))); 128 base::Unretained(&start_callback_)));
126 base::RunLoop().RunUntilIdle(); 129 base::RunLoop().RunUntilIdle();
127 } 130 }
128 131
129 void NotifyHistoryServiceLoaded() { 132 void NotifyHistoryServiceLoaded() {
130 history_service_->NotifyHistoryServiceLoaded(); 133 history_service_->NotifyHistoryServiceLoaded();
131 } 134 }
132 135
133 base::MessageLoop message_loop_; 136 base::MessageLoop message_loop_;
134 std::unique_ptr<syncer::SyncApiComponentFactoryMock> profile_sync_factory_; 137 std::unique_ptr<SyncApiComponentFactoryMock> profile_sync_factory_;
135 std::unique_ptr<BookmarkModel> bookmark_model_; 138 std::unique_ptr<BookmarkModel> bookmark_model_;
136 std::unique_ptr<HistoryMock> history_service_; 139 std::unique_ptr<HistoryMock> history_service_;
137 std::unique_ptr<BookmarkDataTypeController> bookmark_dtc_; 140 std::unique_ptr<BookmarkDataTypeController> bookmark_dtc_;
138 syncer::FakeSyncService service_; 141 sync_driver::FakeSyncService service_;
139 ModelAssociatorMock* model_associator_; 142 ModelAssociatorMock* model_associator_;
140 ChangeProcessorMock* change_processor_; 143 ChangeProcessorMock* change_processor_;
141 StartCallbackMock start_callback_; 144 StartCallbackMock start_callback_;
142 ModelLoadCallbackMock model_load_callback_; 145 ModelLoadCallbackMock model_load_callback_;
143 }; 146 };
144 147
145 TEST_F(SyncBookmarkDataTypeControllerTest, StartDependentsReady) { 148 TEST_F(SyncBookmarkDataTypeControllerTest, StartDependentsReady) {
146 CreateBookmarkModel(LOAD_MODEL); 149 CreateBookmarkModel(LOAD_MODEL);
147 SetStartExpectations(); 150 SetStartExpectations();
148 SetAssociateExpectations(); 151 SetAssociateExpectations();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 SetStopExpectations(); 293 SetStopExpectations();
291 294
292 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); 295 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
293 296
294 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _, _)); 297 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _, _));
295 Start(); 298 Start();
296 EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state()); 299 EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state());
297 bookmark_dtc_->Stop(); 300 bookmark_dtc_->Stop();
298 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); 301 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state());
299 } 302 }
OLDNEW
« no previous file with comments | « components/sync_bookmarks/bookmark_data_type_controller.cc ('k') | components/sync_bookmarks/bookmark_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698