| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); | 285 EXPECT_CALL(change_processor_mock, ApplyChangesFromSyncModel(NULL, _, _)); |
| 286 EXPECT_CALL(change_processor_mock, IsRunning()) | 286 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 287 .WillRepeatedly(Return(true)); | 287 .WillRepeatedly(Return(true)); |
| 288 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); | 288 EXPECT_CALL(change_processor_mock, CommitChangesFromSyncModel()); |
| 289 EXPECT_CALL(change_processor_mock, IsRunning()) | 289 EXPECT_CALL(change_processor_mock, IsRunning()) |
| 290 .WillRepeatedly(Return(false)); | 290 .WillRepeatedly(Return(false)); |
| 291 | 291 |
| 292 const ModelTypeSet types(AUTOFILL); | 292 const ModelTypeSet types(AUTOFILL); |
| 293 EXPECT_EQ(types, registrar_->ConfigureDataTypes(types, ModelTypeSet())); | 293 EXPECT_EQ(types, registrar_->ConfigureDataTypes(types, ModelTypeSet())); |
| 294 | 294 |
| 295 base::WaitableEvent done(false, false); | 295 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 296 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 296 db_task_runner()->PostTask( | 297 db_task_runner()->PostTask( |
| 297 FROM_HERE, | 298 FROM_HERE, |
| 298 base::Bind(&SyncBackendRegistrarTest::TestNonUIDataTypeActivationAsync, | 299 base::Bind(&SyncBackendRegistrarTest::TestNonUIDataTypeActivationAsync, |
| 299 base::Unretained(this), &change_processor_mock, &done)); | 300 base::Unretained(this), &change_processor_mock, &done)); |
| 300 done.Wait(); | 301 done.Wait(); |
| 301 | 302 |
| 302 registrar_->DeactivateDataType(AUTOFILL); | 303 registrar_->DeactivateDataType(AUTOFILL); |
| 303 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); | 304 ExpectRoutingInfo(registrar_.get(), syncer::ModelSafeRoutingInfo()); |
| 304 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); | 305 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet()); |
| 305 | 306 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 db_thread_blocked_.Signal(); | 348 db_thread_blocked_.Signal(); |
| 348 base::AutoLock l(db_thread_lock_); | 349 base::AutoLock l(db_thread_lock_); |
| 349 } | 350 } |
| 350 | 351 |
| 351 protected: | 352 protected: |
| 352 friend class TestRegistrar; | 353 friend class TestRegistrar; |
| 353 | 354 |
| 354 SyncBackendRegistrarShutdownTest() | 355 SyncBackendRegistrarShutdownTest() |
| 355 : db_thread_("DBThreadForTest"), | 356 : db_thread_("DBThreadForTest"), |
| 356 file_thread_("FileThreadForTest"), | 357 file_thread_("FileThreadForTest"), |
| 357 db_thread_blocked_(false, false) { | 358 db_thread_blocked_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 359 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
| 358 quit_closure_ = run_loop_.QuitClosure(); | 360 quit_closure_ = run_loop_.QuitClosure(); |
| 359 } | 361 } |
| 360 | 362 |
| 361 ~SyncBackendRegistrarShutdownTest() override {} | 363 ~SyncBackendRegistrarShutdownTest() override {} |
| 362 | 364 |
| 363 void SetUp() override { | 365 void SetUp() override { |
| 364 db_thread_.StartAndWaitForTesting(); | 366 db_thread_.StartAndWaitForTesting(); |
| 365 file_thread_.StartAndWaitForTesting(); | 367 file_thread_.StartAndWaitForTesting(); |
| 366 sync_client_.reset(new RegistrarSyncClient( | 368 sync_client_.reset(new RegistrarSyncClient( |
| 367 ui_task_runner(), db_task_runner(), file_task_runner())); | 369 ui_task_runner(), db_task_runner(), file_task_runner())); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 db_thread_lock_.Release(); | 460 db_thread_lock_.Release(); |
| 459 | 461 |
| 460 // Run the main thread loop until all workers have been removed and the | 462 // Run the main thread loop until all workers have been removed and the |
| 461 // registrar destroyed. | 463 // registrar destroyed. |
| 462 run_loop_.Run(); | 464 run_loop_.Run(); |
| 463 } | 465 } |
| 464 | 466 |
| 465 } // namespace | 467 } // namespace |
| 466 | 468 |
| 467 } // namespace browser_sync | 469 } // namespace browser_sync |
| OLD | NEW |