OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_driver/glue/sync_backend_registrar.h" | 5 #include "components/sync_driver/glue/sync_backend_registrar.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "components/sync_driver/change_processor_mock.h" | 10 #include "components/sync_driver/change_processor_mock.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; | 170 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; |
171 registrar_->GetWorkers(&workers); | 171 registrar_->GetWorkers(&workers); |
172 EXPECT_EQ(4u, workers.size()); | 172 EXPECT_EQ(4u, workers.size()); |
173 } | 173 } |
174 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); | 174 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); |
175 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); | 175 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); |
176 } | 176 } |
177 | 177 |
178 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { | 178 TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) { |
179 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS); | 179 const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS); |
| 180 registrar_->RegisterNonBlockingType(BOOKMARKS); |
180 registrar_->SetInitialTypes(initial_types); | 181 registrar_->SetInitialTypes(initial_types); |
181 EXPECT_TRUE(registrar_->IsNigoriEnabled()); | 182 EXPECT_TRUE(registrar_->IsNigoriEnabled()); |
182 { | 183 { |
183 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; | 184 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; |
184 registrar_->GetWorkers(&workers); | 185 registrar_->GetWorkers(&workers); |
185 EXPECT_EQ(4u, workers.size()); | 186 EXPECT_EQ(4u, workers.size()); |
186 } | 187 } |
187 { | 188 { |
188 syncer::ModelSafeRoutingInfo expected_routing_info; | 189 syncer::ModelSafeRoutingInfo expected_routing_info; |
189 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; | 190 expected_routing_info[BOOKMARKS] = syncer::GROUP_NON_BLOCKING; |
190 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; | 191 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; |
191 // Passwords dropped because of no password store. | 192 // Passwords dropped because of no password store. |
192 ExpectRoutingInfo(registrar_.get(), expected_routing_info); | 193 ExpectRoutingInfo(registrar_.get(), expected_routing_info); |
193 } | 194 } |
194 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); | 195 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); |
195 } | 196 } |
196 | 197 |
197 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { | 198 TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) { |
| 199 registrar_->RegisterNonBlockingType(BOOKMARKS); |
198 registrar_->SetInitialTypes(ModelTypeSet()); | 200 registrar_->SetInitialTypes(ModelTypeSet()); |
199 | 201 |
200 // Add. | 202 // Add. |
201 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL); | 203 const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL); |
202 EXPECT_TRUE( | 204 EXPECT_TRUE( |
203 registrar_->ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1)); | 205 registrar_->ConfigureDataTypes(types1, ModelTypeSet()).Equals(types1)); |
204 { | 206 { |
205 syncer::ModelSafeRoutingInfo expected_routing_info; | 207 syncer::ModelSafeRoutingInfo expected_routing_info; |
206 expected_routing_info[BOOKMARKS] = syncer::GROUP_PASSIVE; | 208 expected_routing_info[BOOKMARKS] = syncer::GROUP_NON_BLOCKING; |
207 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; | 209 expected_routing_info[NIGORI] = syncer::GROUP_PASSIVE; |
208 expected_routing_info[AUTOFILL] = syncer::GROUP_PASSIVE; | 210 expected_routing_info[AUTOFILL] = syncer::GROUP_PASSIVE; |
209 ExpectRoutingInfo(registrar_.get(), expected_routing_info); | 211 ExpectRoutingInfo(registrar_.get(), expected_routing_info); |
210 } | 212 } |
211 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); | 213 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); |
212 EXPECT_TRUE(types1.Equals(registrar_->GetLastConfiguredTypes())); | 214 EXPECT_TRUE(types1.Equals(registrar_->GetLastConfiguredTypes())); |
213 | 215 |
214 // Add and remove. | 216 // Add and remove. |
215 const ModelTypeSet types2(PREFERENCES, THEMES); | 217 const ModelTypeSet types2(PREFERENCES, THEMES); |
216 EXPECT_TRUE(registrar_->ConfigureDataTypes(types2, types1).Equals(types2)); | 218 EXPECT_TRUE(registrar_->ConfigureDataTypes(types2, types1).Equals(types2)); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 db_thread_lock_.Release(); | 429 db_thread_lock_.Release(); |
428 | 430 |
429 // Run the main thread loop until all workers have been removed and the | 431 // Run the main thread loop until all workers have been removed and the |
430 // registrar destroyed. | 432 // registrar destroyed. |
431 run_loop_.Run(); | 433 run_loop_.Run(); |
432 } | 434 } |
433 | 435 |
434 } // namespace | 436 } // namespace |
435 | 437 |
436 } // namespace browser_sync | 438 } // namespace browser_sync |
OLD | NEW |