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 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
6 | 6 |
7 #include "chrome/browser/sync/glue/ui_model_worker.h" | 7 #include "chrome/browser/sync/glue/ui_model_worker.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "components/sync_driver/change_processor_mock.h" | 9 #include "components/sync_driver/change_processor_mock.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 using syncer::ModelTypeFromInt; | 36 using syncer::ModelTypeFromInt; |
37 | 37 |
38 void TriggerChanges(SyncBackendRegistrar* registrar, ModelType type) { | 38 void TriggerChanges(SyncBackendRegistrar* registrar, ModelType type) { |
39 registrar->OnChangesApplied(type, 0, NULL, | 39 registrar->OnChangesApplied(type, 0, NULL, |
40 syncer::ImmutableChangeRecordList()); | 40 syncer::ImmutableChangeRecordList()); |
41 registrar->OnChangesComplete(type); | 41 registrar->OnChangesComplete(type); |
42 } | 42 } |
43 | 43 |
44 class SyncBackendRegistrarTest : public testing::Test { | 44 class SyncBackendRegistrarTest : public testing::Test { |
45 public: | 45 public: |
46 void TestNonUIDataTypeActivationAsync(ChangeProcessor* processor, | 46 void TestNonUIDataTypeActivationAsync(sync_driver::ChangeProcessor* processor, |
47 base::WaitableEvent* done) { | 47 base::WaitableEvent* done) { |
48 registrar_->ActivateDataType(AUTOFILL, | 48 registrar_->ActivateDataType(AUTOFILL, |
49 syncer::GROUP_DB, | 49 syncer::GROUP_DB, |
50 processor, | 50 processor, |
51 test_user_share_.user_share()); | 51 test_user_share_.user_share()); |
52 syncer::ModelSafeRoutingInfo expected_routing_info; | 52 syncer::ModelSafeRoutingInfo expected_routing_info; |
53 expected_routing_info[AUTOFILL] = syncer::GROUP_DB; | 53 expected_routing_info[AUTOFILL] = syncer::GROUP_DB; |
54 ExpectRoutingInfo(registrar_.get(), expected_routing_info); | 54 ExpectRoutingInfo(registrar_.get(), expected_routing_info); |
55 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet(AUTOFILL)); | 55 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet(AUTOFILL)); |
56 TriggerChanges(registrar_.get(), AUTOFILL); | 56 TriggerChanges(registrar_.get(), AUTOFILL); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 EXPECT_TRUE(ModelTypeSet().Equals(registrar_->GetLastConfiguredTypes())); | 175 EXPECT_TRUE(ModelTypeSet().Equals(registrar_->GetLastConfiguredTypes())); |
176 } | 176 } |
177 | 177 |
178 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) { | 178 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) { |
179 InSequence in_sequence; | 179 InSequence in_sequence; |
180 registrar_->SetInitialTypes(ModelTypeSet()); | 180 registrar_->SetInitialTypes(ModelTypeSet()); |
181 | 181 |
182 // Should do nothing. | 182 // Should do nothing. |
183 TriggerChanges(registrar_.get(), BOOKMARKS); | 183 TriggerChanges(registrar_.get(), BOOKMARKS); |
184 | 184 |
185 StrictMock<ChangeProcessorMock> change_processor_mock; | 185 StrictMock<sync_driver::ChangeProcessorMock> change_processor_mock; |
186 EXPECT_CALL(change_processor_mock, StartImpl()); | 186 EXPECT_CALL(change_processor_mock, StartImpl()); |
187 EXPECT_CALL(change_processor_mock, IsRunning()) | 187 EXPECT_CALL(change_processor_mock, IsRunning()) |
188 .WillRepeatedly(Return(true)); | 188 .WillRepeatedly(Return(true)); |
189 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); | 189 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); |
190 EXPECT_CALL(change_processor_mock, IsRunning()) | 190 EXPECT_CALL(change_processor_mock, IsRunning()) |
191 .WillRepeatedly(Return(true)); | 191 .WillRepeatedly(Return(true)); |
192 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); | 192 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); |
193 EXPECT_CALL(change_processor_mock, IsRunning()) | 193 EXPECT_CALL(change_processor_mock, IsRunning()) |
194 .WillRepeatedly(Return(false)); | 194 .WillRepeatedly(Return(false)); |
195 | 195 |
(...skipping 20 matching lines...) Expand all Loading... |
216 TriggerChanges(registrar_.get(), BOOKMARKS); | 216 TriggerChanges(registrar_.get(), BOOKMARKS); |
217 } | 217 } |
218 | 218 |
219 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) { | 219 TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) { |
220 InSequence in_sequence; | 220 InSequence in_sequence; |
221 registrar_->SetInitialTypes(ModelTypeSet()); | 221 registrar_->SetInitialTypes(ModelTypeSet()); |
222 | 222 |
223 // Should do nothing. | 223 // Should do nothing. |
224 TriggerChanges(registrar_.get(), AUTOFILL); | 224 TriggerChanges(registrar_.get(), AUTOFILL); |
225 | 225 |
226 StrictMock<ChangeProcessorMock> change_processor_mock; | 226 StrictMock<sync_driver::ChangeProcessorMock> change_processor_mock; |
227 EXPECT_CALL(change_processor_mock, StartImpl()); | 227 EXPECT_CALL(change_processor_mock, StartImpl()); |
228 EXPECT_CALL(change_processor_mock, IsRunning()) | 228 EXPECT_CALL(change_processor_mock, IsRunning()) |
229 .WillRepeatedly(Return(true)); | 229 .WillRepeatedly(Return(true)); |
230 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); | 230 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); |
231 EXPECT_CALL(change_processor_mock, IsRunning()) | 231 EXPECT_CALL(change_processor_mock, IsRunning()) |
232 .WillRepeatedly(Return(true)); | 232 .WillRepeatedly(Return(true)); |
233 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); | 233 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); |
234 EXPECT_CALL(change_processor_mock, IsRunning()) | 234 EXPECT_CALL(change_processor_mock, IsRunning()) |
235 .WillRepeatedly(Return(false)); | 235 .WillRepeatedly(Return(false)); |
236 | 236 |
(...skipping 15 matching lines...) Expand all Loading... |
252 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); | 252 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); |
253 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); | 253 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); |
254 | 254 |
255 // Should do nothing. | 255 // Should do nothing. |
256 TriggerChanges(registrar_.get(), AUTOFILL); | 256 TriggerChanges(registrar_.get(), AUTOFILL); |
257 } | 257 } |
258 | 258 |
259 } // namespace | 259 } // namespace |
260 | 260 |
261 } // namespace browser_sync | 261 } // namespace browser_sync |
OLD | NEW |