OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/sync/abstract_profile_sync_service_test.h" | 7 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
8 #include "chrome/browser/sync/glue/data_type_controller.h" | 8 #include "chrome/browser/sync/glue/data_type_controller.h" |
9 #include "chrome/browser/sync/glue/sync_backend_host.h" | 9 #include "chrome/browser/sync/glue/sync_backend_host.h" |
10 #include "chrome/browser/sync/internal_api/user_share.h" | 10 #include "chrome/browser/sync/internal_api/user_share.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 60 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
61 | 61 |
62 void SyncBackendHostForProfileSyncTest:: | 62 void SyncBackendHostForProfileSyncTest:: |
63 SimulateSyncCycleCompletedInitialSyncEnded( | 63 SimulateSyncCycleCompletedInitialSyncEnded( |
64 const tracked_objects::Location& location) { | 64 const tracked_objects::Location& location) { |
65 syncable::ModelTypeSet sync_ended; | 65 syncable::ModelTypeSet sync_ended; |
66 if (!fail_initial_download_) | 66 if (!fail_initial_download_) |
67 sync_ended = syncable::ModelTypeSet::All(); | 67 sync_ended = syncable::ModelTypeSet::All(); |
68 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 68 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; |
69 core_->HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( | 69 HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( |
70 SyncerStatus(), ErrorCounters(), 0, false, | 70 SyncerStatus(), ErrorCounters(), 0, false, |
71 sync_ended, download_progress_markers, false, false, 0, 0, 0, false, | 71 sync_ended, download_progress_markers, false, false, 0, 0, 0, false, |
72 SyncSourceInfo(), 0, base::Time::Now())); | 72 SyncSourceInfo(), 0, base::Time::Now())); |
73 } | 73 } |
74 | 74 |
75 sync_api::HttpPostProviderFactory* | 75 namespace { |
76 SyncBackendHostForProfileSyncTest::MakeHttpBridgeFactory( | 76 |
77 const scoped_refptr<net::URLRequestContextGetter>& getter) { | 77 sync_api::HttpPostProviderFactory* MakeTestHttpBridgeFactory() { |
78 return new browser_sync::TestHttpBridgeFactory; | 78 return new browser_sync::TestHttpBridgeFactory(); |
79 } | 79 } |
80 | 80 |
| 81 } // namespace |
| 82 |
81 void SyncBackendHostForProfileSyncTest::InitCore( | 83 void SyncBackendHostForProfileSyncTest::InitCore( |
82 const Core::DoInitializeOptions& options) { | 84 const DoInitializeOptions& options) { |
83 Core::DoInitializeOptions test_options = options; | 85 DoInitializeOptions test_options = options; |
| 86 test_options.make_http_bridge_factory_fn = |
| 87 base::Bind(&MakeTestHttpBridgeFactory); |
84 test_options.credentials.email = "testuser@gmail.com"; | 88 test_options.credentials.email = "testuser@gmail.com"; |
85 test_options.credentials.sync_token = "token"; | 89 test_options.credentials.sync_token = "token"; |
86 test_options.restored_key_for_bootstrapping = ""; | 90 test_options.restored_key_for_bootstrapping = ""; |
87 test_options.setup_for_test_mode = true; | 91 test_options.setup_for_test_mode = true; |
88 SyncBackendHost::InitCore(test_options); | 92 SyncBackendHost::InitCore(test_options); |
89 // TODO(akalin): Figure out a better way to do this. | 93 // TODO(akalin): Figure out a better way to do this. |
90 if (synchronous_init_) { | 94 if (synchronous_init_) { |
91 // The SyncBackend posts a task to the current loop when | 95 // The SyncBackend posts a task to the current loop when |
92 // initialization completes. | 96 // initialization completes. |
93 MessageLoop::current()->Run(); | 97 MessageLoop::current()->Run(); |
94 } | 98 } |
95 } | 99 } |
96 | 100 |
97 void SyncBackendHostForProfileSyncTest::StartConfiguration( | 101 void SyncBackendHostForProfileSyncTest::StartConfiguration( |
98 const base::Closure& callback) { | 102 const base::Closure& callback) { |
99 SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); | 103 SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); |
100 if (initialization_state_ == DOWNLOADING_NIGORI) { | 104 if (IsDownloadingNigoriForTest()) { |
101 syncable::ModelTypeSet sync_ended; | 105 syncable::ModelTypeSet sync_ended; |
102 | 106 |
103 if (!fail_initial_download_) | 107 if (!fail_initial_download_) |
104 sync_ended.Put(syncable::NIGORI); | 108 sync_ended.Put(syncable::NIGORI); |
105 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 109 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; |
106 core_->HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( | 110 HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot( |
107 SyncerStatus(), ErrorCounters(), 0, false, | 111 SyncerStatus(), ErrorCounters(), 0, false, |
108 sync_ended, download_progress_markers, false, false, 0, 0, 0, false, | 112 sync_ended, download_progress_markers, false, false, 0, 0, 0, false, |
109 SyncSourceInfo(), 0, base::Time::Now())); | 113 SyncSourceInfo(), 0, base::Time::Now())); |
110 } | 114 } |
111 } | 115 } |
112 | 116 |
113 void SyncBackendHostForProfileSyncTest:: | 117 void SyncBackendHostForProfileSyncTest:: |
114 SetDefaultExpectationsForWorkerCreation(ProfileMock* profile) { | 118 SetDefaultExpectationsForWorkerCreation(ProfileMock* profile) { |
115 EXPECT_CALL(*profile, GetPasswordStore(testing::_)). | 119 EXPECT_CALL(*profile, GetPasswordStore(testing::_)). |
116 WillOnce(testing::Return((PasswordStore*)NULL)); | 120 WillOnce(testing::Return((PasswordStore*)NULL)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 242 } |
239 | 243 |
240 void TestProfileSyncService::CreateBackend() { | 244 void TestProfileSyncService::CreateBackend() { |
241 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 245 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
242 profile(), | 246 profile(), |
243 sync_prefs_.AsWeakPtr(), | 247 sync_prefs_.AsWeakPtr(), |
244 set_initial_sync_ended_on_init_, | 248 set_initial_sync_ended_on_init_, |
245 synchronous_backend_initialization_, | 249 synchronous_backend_initialization_, |
246 fail_initial_download_)); | 250 fail_initial_download_)); |
247 } | 251 } |
OLD | NEW |