| 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/test_profile_sync_service.h" | 5 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/signin/signin_manager.h" | 7 #include "chrome/browser/signin/signin_manager.h" |
| 8 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 8 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
| 9 #include "chrome/browser/sync/glue/data_type_controller.h" | 9 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 10 #include "chrome/browser/sync/glue/sync_backend_host.h" | 10 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool fail_initial_download, | 35 bool fail_initial_download, |
| 36 bool use_real_database) | 36 bool use_real_database) |
| 37 : browser_sync::SyncBackendHost( | 37 : browser_sync::SyncBackendHost( |
| 38 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), | 38 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), |
| 39 synchronous_init_(synchronous_init), | 39 synchronous_init_(synchronous_init), |
| 40 fail_initial_download_(fail_initial_download), | 40 fail_initial_download_(fail_initial_download), |
| 41 use_real_database_(use_real_database) {} | 41 use_real_database_(use_real_database) {} |
| 42 | 42 |
| 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
| 44 | 44 |
| 45 void SyncBackendHostForProfileSyncTest:: |
| 46 SimulateSyncCycleCompletedInitialSyncEnded( |
| 47 const tracked_objects::Location& location) { |
| 48 syncer::ModelTypeSet sync_ended; |
| 49 if (!fail_initial_download_) |
| 50 sync_ended = syncer::ModelTypeSet::All(); |
| 51 syncer::ModelTypePayloadMap download_progress_markers; |
| 52 HandleSyncCycleCompletedOnFrontendLoop( |
| 53 SyncSessionSnapshot( |
| 54 ModelNeutralState(), false, sync_ended, download_progress_markers, |
| 55 false, false, 0, 0, 0, 0, SyncSourceInfo(), false, 0, |
| 56 base::Time::Now(), false)); |
| 57 } |
| 58 |
| 45 namespace { | 59 namespace { |
| 46 | 60 |
| 47 syncer::HttpPostProviderFactory* MakeTestHttpBridgeFactory() { | 61 syncer::HttpPostProviderFactory* MakeTestHttpBridgeFactory() { |
| 48 return new browser_sync::TestHttpBridgeFactory(); | 62 return new browser_sync::TestHttpBridgeFactory(); |
| 49 } | 63 } |
| 50 | 64 |
| 51 } // namespace | 65 } // namespace |
| 52 | 66 |
| 53 void SyncBackendHostForProfileSyncTest::InitCore( | 67 void SyncBackendHostForProfileSyncTest::InitCore( |
| 54 const DoInitializeOptions& options) { | 68 const DoInitializeOptions& options) { |
| 55 DoInitializeOptions test_options = options; | 69 DoInitializeOptions test_options = options; |
| 56 test_options.make_http_bridge_factory_fn = | 70 test_options.make_http_bridge_factory_fn = |
| 57 base::Bind(&MakeTestHttpBridgeFactory); | 71 base::Bind(&MakeTestHttpBridgeFactory); |
| 58 test_options.credentials.email = "testuser@gmail.com"; | 72 test_options.credentials.email = "testuser@gmail.com"; |
| 59 test_options.credentials.sync_token = "token"; | 73 test_options.credentials.sync_token = "token"; |
| 60 test_options.restored_key_for_bootstrapping = ""; | 74 test_options.restored_key_for_bootstrapping = ""; |
| 61 test_options.testing_mode = | 75 test_options.testing_mode = |
| 62 use_real_database_ ? syncer::SyncManager::TEST_ON_DISK | 76 use_real_database_ ? syncer::SyncManager::TEST_ON_DISK |
| 63 : syncer::SyncManager::TEST_IN_MEMORY; | 77 : syncer::SyncManager::TEST_IN_MEMORY; |
| 64 SyncBackendHost::InitCore(test_options); | 78 SyncBackendHost::InitCore(test_options); |
| 65 // TODO(akalin): Figure out a better way to do this. | 79 // TODO(akalin): Figure out a better way to do this. |
| 66 if (synchronous_init_) { | 80 if (synchronous_init_) { |
| 67 // The SyncBackend posts a task to the current loop when | 81 // The SyncBackend posts a task to the current loop when |
| 68 // initialization completes. | 82 // initialization completes. |
| 69 MessageLoop::current()->Run(); | 83 MessageLoop::current()->Run(); |
| 70 } | 84 } |
| 71 } | 85 } |
| 72 | 86 |
| 73 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( | 87 void SyncBackendHostForProfileSyncTest::StartConfiguration( |
| 74 syncer::ConfigureReason reason, | 88 const base::Closure& callback) { |
| 75 syncer::ModelTypeSet types_to_config, | 89 SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); |
| 76 const syncer::ModelSafeRoutingInfo& routing_info, | 90 if (IsDownloadingNigoriForTest()) { |
| 77 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 91 syncer::ModelTypeSet sync_ended; |
| 78 const base::Closure& retry_callback) { | |
| 79 syncer::ModelTypeSet sync_ended; | |
| 80 if (!fail_initial_download_) | |
| 81 sync_ended.PutAll(types_to_config); | |
| 82 | 92 |
| 83 FinishConfigureDataTypesOnFrontendLoop(types_to_config, | 93 if (!fail_initial_download_) |
| 84 sync_ended, | 94 sync_ended.Put(syncer::NIGORI); |
| 85 ready_task); | 95 syncer::ModelTypePayloadMap download_progress_markers; |
| 96 HandleSyncCycleCompletedOnFrontendLoop( |
| 97 SyncSessionSnapshot( |
| 98 ModelNeutralState(), false, sync_ended, download_progress_markers, |
| 99 false, false, 0, 0, 0, 0, SyncSourceInfo(), false, 0, |
| 100 base::Time::Now(), false)); |
| 101 } |
| 86 } | 102 } |
| 87 | 103 |
| 88 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations( | 104 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations( |
| 89 ProfileMock* profile) { | 105 ProfileMock* profile) { |
| 90 EXPECT_CALL(*profile, GetHistoryService(testing::_)). | 106 EXPECT_CALL(*profile, GetHistoryService(testing::_)). |
| 91 WillOnce(testing::Return((HistoryService*)NULL)); | 107 WillOnce(testing::Return((HistoryService*)NULL)); |
| 92 } | 108 } |
| 93 | 109 |
| 94 } // namespace browser_sync | 110 } // namespace browser_sync |
| 95 | 111 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void TestProfileSyncService::CreateBackend() { | 225 void TestProfileSyncService::CreateBackend() { |
| 210 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 226 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
| 211 profile(), | 227 profile(), |
| 212 sync_prefs_.AsWeakPtr(), | 228 sync_prefs_.AsWeakPtr(), |
| 213 invalidator_storage_.AsWeakPtr(), | 229 invalidator_storage_.AsWeakPtr(), |
| 214 set_initial_sync_ended_on_init_, | 230 set_initial_sync_ended_on_init_, |
| 215 synchronous_backend_initialization_, | 231 synchronous_backend_initialization_, |
| 216 fail_initial_download_, | 232 fail_initial_download_, |
| 217 use_real_database_)); | 233 use_real_database_)); |
| 218 } | 234 } |
| OLD | NEW |