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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 base::Closure())); | 109 base::Closure())); |
110 if (!set_initial_sync_ended) | 110 if (!set_initial_sync_ended) |
111 service_->dont_set_initial_sync_ended_on_init(); | 111 service_->dont_set_initial_sync_ended_on_init(); |
112 if (synchronous_sync_configuration) | 112 if (synchronous_sync_configuration) |
113 service_->set_synchronous_sync_configuration(); | 113 service_->set_synchronous_sync_configuration(); |
114 service_->set_storage_option(storage_option); | 114 service_->set_storage_option(storage_option); |
115 if (!sync_setup_completed) | 115 if (!sync_setup_completed) |
116 profile_->GetPrefs()->SetBoolean(prefs::kSyncHasSetupCompleted, false); | 116 profile_->GetPrefs()->SetBoolean(prefs::kSyncHasSetupCompleted, false); |
117 | 117 |
118 // Register the bookmark data type. | 118 // Register the bookmark data type. |
119 ON_CALL(*factory, CreateDataTypeManager(_, _)). | 119 ON_CALL(*factory, CreateDataTypeManager(_, _, _)). |
120 WillByDefault(ReturnNewDataTypeManager()); | 120 WillByDefault(ReturnNewDataTypeManager()); |
121 | 121 |
122 if (issue_auth_token) { | 122 if (issue_auth_token) { |
123 IssueTestTokens(); | 123 IssueTestTokens(); |
124 } | 124 } |
125 service_->Initialize(); | 125 service_->Initialize(); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 void IssueTestTokens() { | 129 void IssueTestTokens() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 signin->SetAuthenticatedUsername("test"); | 185 signin->SetAuthenticatedUsername("test"); |
186 ProfileSyncComponentsFactoryMock* factory = | 186 ProfileSyncComponentsFactoryMock* factory = |
187 new ProfileSyncComponentsFactoryMock(); | 187 new ProfileSyncComponentsFactoryMock(); |
188 service_.reset(new TestProfileSyncService( | 188 service_.reset(new TestProfileSyncService( |
189 factory, | 189 factory, |
190 profile_.get(), | 190 profile_.get(), |
191 signin, | 191 signin, |
192 ProfileSyncService::AUTO_START, | 192 ProfileSyncService::AUTO_START, |
193 true, | 193 true, |
194 base::Closure())); | 194 base::Closure())); |
195 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)).Times(0); | 195 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _)).Times(0); |
196 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). | 196 EXPECT_CALL(*factory, CreateBookmarkSyncComponents(_, _)). |
197 Times(0); | 197 Times(0); |
198 service_->RegisterDataTypeController( | 198 service_->RegisterDataTypeController( |
199 new BookmarkDataTypeController(service_->factory(), | 199 new BookmarkDataTypeController(service_->factory(), |
200 profile_.get(), | 200 profile_.get(), |
201 service_.get())); | 201 service_.get())); |
202 | 202 |
203 service_->Initialize(); | 203 service_->Initialize(); |
204 service_.reset(); | 204 service_.reset(); |
205 } | 205 } |
206 | 206 |
207 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { | 207 TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) { |
208 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get()); | 208 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get()); |
209 signin->SetAuthenticatedUsername("test"); | 209 signin->SetAuthenticatedUsername("test"); |
210 ProfileSyncComponentsFactoryMock* factory = | 210 ProfileSyncComponentsFactoryMock* factory = |
211 new ProfileSyncComponentsFactoryMock(); | 211 new ProfileSyncComponentsFactoryMock(); |
212 service_.reset(new TestProfileSyncService( | 212 service_.reset(new TestProfileSyncService( |
213 factory, | 213 factory, |
214 profile_.get(), | 214 profile_.get(), |
215 signin, | 215 signin, |
216 ProfileSyncService::AUTO_START, | 216 ProfileSyncService::AUTO_START, |
217 true, | 217 true, |
218 base::Closure())); | 218 base::Closure())); |
219 // Register the bookmark data type. | 219 // Register the bookmark data type. |
220 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)). | 220 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _)). |
221 WillRepeatedly(ReturnNewDataTypeManager()); | 221 WillRepeatedly(ReturnNewDataTypeManager()); |
222 | 222 |
223 IssueTestTokens(); | 223 IssueTestTokens(); |
224 | 224 |
225 service_->Initialize(); | 225 service_->Initialize(); |
226 EXPECT_TRUE(service_->sync_initialized()); | 226 EXPECT_TRUE(service_->sync_initialized()); |
227 EXPECT_TRUE(service_->GetBackendForTest() != NULL); | 227 EXPECT_TRUE(service_->GetBackendForTest() != NULL); |
228 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); | 228 EXPECT_FALSE(profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)); |
229 | 229 |
230 service_->StopAndSuppress(); | 230 service_->StopAndSuppress(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 SyncBackendHostForProfileSyncTest* const backend = | 437 SyncBackendHostForProfileSyncTest* const backend = |
438 service_->GetBackendForTest(); | 438 service_->GetBackendForTest(); |
439 | 439 |
440 backend->EmitOnNotificationsEnabled(); | 440 backend->EmitOnNotificationsEnabled(); |
441 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); | 441 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); |
442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); | 442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); |
443 } | 443 } |
444 | 444 |
445 } // namespace | 445 } // namespace |
446 } // namespace browser_sync | 446 } // namespace browser_sync |
OLD | NEW |