OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 6 |
| 7 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
| 8 |
| 9 namespace browser_sync { |
| 10 |
| 11 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
| 12 TestProfileSyncService* service, |
| 13 Profile* profile, |
| 14 const FilePath& profile_path, |
| 15 const DataTypeController::TypeMap& data_type_controllers, |
| 16 Task* initial_condition_setup_task, |
| 17 int num_expected_resumes, |
| 18 int num_expected_pauses, |
| 19 bool set_initial_sync_ended_on_init, |
| 20 bool synchronous_init) |
| 21 : browser_sync::SyncBackendHost(service, profile, profile_path, |
| 22 data_type_controllers), |
| 23 initial_condition_setup_task_(initial_condition_setup_task), |
| 24 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), |
| 25 synchronous_init_(synchronous_init), |
| 26 test_service_(service) { |
| 27 // By default, the RequestPause and RequestResume methods will |
| 28 // send the confirmation notification and return true. |
| 29 ON_CALL(*this, RequestPause()). |
| 30 WillByDefault(testing::DoAll(CallOnPaused(core_), |
| 31 testing::Return(true))); |
| 32 ON_CALL(*this, RequestResume()). |
| 33 WillByDefault(testing::DoAll(CallOnResumed(core_), |
| 34 testing::Return(true))); |
| 35 ON_CALL(*this, RequestNudge()).WillByDefault( |
| 36 testing::Invoke(this, |
| 37 &SyncBackendHostForProfileSyncTest:: |
| 38 SimulateSyncCycleCompletedInitialSyncEnded)); |
| 39 |
| 40 EXPECT_CALL(*this, RequestPause()).Times(num_expected_pauses); |
| 41 EXPECT_CALL(*this, RequestResume()).Times(num_expected_resumes); |
| 42 EXPECT_CALL(*this, RequestNudge()).Times(set_initial_sync_ended_on_init ? 0 :
1); |
| 43 } |
| 44 |
| 45 void |
| 46 SyncBackendHostForProfileSyncTest::HandleInitializationCompletedOnFrontendLoop()
{ |
| 47 set_syncapi_initialized(); // Need to do this asap so task below works. |
| 48 |
| 49 // Set up any nodes the test wants around before model association. |
| 50 if (initial_condition_setup_task_) { |
| 51 initial_condition_setup_task_->Run(); |
| 52 } |
| 53 |
| 54 // Pretend we downloaded initial updates and set initial sync ended bits |
| 55 // if we were asked to. |
| 56 if (set_initial_sync_ended_on_init_) { |
| 57 UserShare* user_share = core_->syncapi()->GetUserShare(); |
| 58 DirectoryManager* dir_manager = user_share->dir_manager.get(); |
| 59 |
| 60 ScopedDirLookup dir(dir_manager, user_share->name); |
| 61 if (!dir.good()) |
| 62 FAIL(); |
| 63 |
| 64 if (!dir->initial_sync_ended_for_type(syncable::NIGORI)) { |
| 65 ProfileSyncServiceTestHelper::CreateRoot( |
| 66 syncable::NIGORI, test_service_, test_service_->id_factory()); |
| 67 } |
| 68 |
| 69 SetInitialSyncEndedForEnabledTypes(); |
| 70 } |
| 71 |
| 72 SyncBackendHost::HandleInitializationCompletedOnFrontendLoop(); |
| 73 } |
| 74 |
| 75 |
| 76 |
| 77 } // namespace |
OLD | NEW |