| 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/glue/sync_backend_host.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 MOCK_METHOD1(OnMigrationNeededForTypes, void(syncer::ModelTypeSet)); | 82 MOCK_METHOD1(OnMigrationNeededForTypes, void(syncer::ModelTypeSet)); |
| 83 MOCK_METHOD1(OnExperimentsChanged, | 83 MOCK_METHOD1(OnExperimentsChanged, |
| 84 void(const syncer::Experiments&)); | 84 void(const syncer::Experiments&)); |
| 85 MOCK_METHOD1(OnActionableError, | 85 MOCK_METHOD1(OnActionableError, |
| 86 void(const syncer::SyncProtocolError& sync_error)); | 86 void(const syncer::SyncProtocolError& sync_error)); |
| 87 MOCK_METHOD0(OnSyncConfigureRetry, void()); | 87 MOCK_METHOD0(OnSyncConfigureRetry, void()); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class FakeSyncManagerFactory : public syncer::SyncManagerFactory { | 90 class FakeSyncManagerFactory : public syncer::SyncManagerFactory { |
| 91 public: | 91 public: |
| 92 FakeSyncManagerFactory() : manager_(NULL) {} | 92 FakeSyncManagerFactory() : fake_manager_(NULL) {} |
| 93 virtual ~FakeSyncManagerFactory() {} | 93 virtual ~FakeSyncManagerFactory() {} |
| 94 | 94 |
| 95 // Takes ownership of |manager|. | 95 // SyncManagerFactory implementation. Called on the sync thread. |
| 96 void SetSyncManager(FakeSyncManager* manager) { | 96 virtual scoped_ptr<SyncManager> CreateSyncManager( |
| 97 DCHECK(!manager_.get()); | 97 std::string name) OVERRIDE { |
| 98 manager_.reset(manager); | 98 DCHECK(!fake_manager_); |
| 99 fake_manager_ = new FakeSyncManager(initial_sync_ended_types_, |
| 100 progress_marker_types_, |
| 101 configure_fail_types_); |
| 102 return scoped_ptr<SyncManager>(fake_manager_); |
| 99 } | 103 } |
| 100 | 104 |
| 101 // Passes ownership of |manager_|. | 105 // Returns NULL until CreateSyncManager() is called on the sync |
| 102 // SyncManagerFactory implementation. | 106 // thread. Called on the main thread, but only after |
| 103 virtual scoped_ptr<SyncManager> CreateSyncManager(std::string name) OVERRIDE { | 107 // OnBackendInitialized() is called (which is strictly after |
| 104 DCHECK(manager_.get()); | 108 // CreateSyncManager is called on the sync thread). |
| 105 return manager_.Pass(); | 109 FakeSyncManager* fake_manager() { |
| 110 return fake_manager_; |
| 111 } |
| 112 |
| 113 void set_initial_sync_ended_types(syncer::ModelTypeSet types) { |
| 114 initial_sync_ended_types_ = types; |
| 115 } |
| 116 |
| 117 void set_progress_marker_types(syncer::ModelTypeSet types) { |
| 118 progress_marker_types_ = types; |
| 119 } |
| 120 |
| 121 void set_configure_fail_types(syncer::ModelTypeSet types) { |
| 122 configure_fail_types_ = types; |
| 106 } | 123 } |
| 107 | 124 |
| 108 private: | 125 private: |
| 109 scoped_ptr<SyncManager> manager_; | 126 syncer::ModelTypeSet initial_sync_ended_types_; |
| 127 syncer::ModelTypeSet progress_marker_types_; |
| 128 syncer::ModelTypeSet configure_fail_types_; |
| 129 FakeSyncManager* fake_manager_; |
| 110 }; | 130 }; |
| 111 | 131 |
| 112 class SyncBackendHostTest : public testing::Test { | 132 class SyncBackendHostTest : public testing::Test { |
| 113 protected: | 133 protected: |
| 114 SyncBackendHostTest() | 134 SyncBackendHostTest() |
| 115 : ui_thread_(BrowserThread::UI, &ui_loop_), | 135 : ui_thread_(BrowserThread::UI, &ui_loop_), |
| 116 io_thread_(BrowserThread::IO), | 136 io_thread_(BrowserThread::IO), |
| 117 fake_manager_(NULL) {} | 137 fake_manager_(NULL) {} |
| 118 | 138 |
| 119 virtual ~SyncBackendHostTest() {} | 139 virtual ~SyncBackendHostTest() {} |
| 120 | 140 |
| 121 virtual void SetUp() OVERRIDE { | 141 virtual void SetUp() OVERRIDE { |
| 122 io_thread_.StartIOThread(); | 142 io_thread_.StartIOThread(); |
| 123 profile_.reset(new TestingProfile()); | 143 profile_.reset(new TestingProfile()); |
| 124 profile_->CreateRequestContext(); | 144 profile_->CreateRequestContext(); |
| 125 sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); | 145 sync_prefs_.reset(new SyncPrefs(profile_->GetPrefs())); |
| 126 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 146 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 127 backend_.reset(new SyncBackendHost( | 147 backend_.reset(new SyncBackendHost( |
| 128 profile_->GetDebugName(), | 148 profile_->GetDebugName(), |
| 129 profile_.get(), | 149 profile_.get(), |
| 130 sync_prefs_->AsWeakPtr(), | 150 sync_prefs_->AsWeakPtr(), |
| 131 invalidator_storage_->AsWeakPtr())); | 151 invalidator_storage_->AsWeakPtr())); |
| 132 credentials_.email = "user@example.com"; | 152 credentials_.email = "user@example.com"; |
| 133 credentials_.sync_token = "sync_token"; | 153 credentials_.sync_token = "sync_token"; |
| 134 fake_manager_ = new FakeSyncManager(); | |
| 135 fake_sync_manager_factory_.SetSyncManager(fake_manager_); | |
| 136 | 154 |
| 137 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend | 155 // NOTE: We can't include Passwords or Typed URLs due to the Sync Backend |
| 138 // Registrar removing them if it can't find their model workers. | 156 // Registrar removing them if it can't find their model workers. |
| 139 enabled_types_.Put(syncer::BOOKMARKS); | 157 enabled_types_.Put(syncer::BOOKMARKS); |
| 140 enabled_types_.Put(syncer::NIGORI); | 158 enabled_types_.Put(syncer::NIGORI); |
| 141 enabled_types_.Put(syncer::PREFERENCES); | 159 enabled_types_.Put(syncer::PREFERENCES); |
| 142 enabled_types_.Put(syncer::SESSIONS); | 160 enabled_types_.Put(syncer::SESSIONS); |
| 143 enabled_types_.Put(syncer::SEARCH_ENGINES); | 161 enabled_types_.Put(syncer::SEARCH_ENGINES); |
| 144 enabled_types_.Put(syncer::AUTOFILL); | 162 enabled_types_.Put(syncer::AUTOFILL); |
| 145 } | 163 } |
| 146 | 164 |
| 147 virtual void TearDown() OVERRIDE { | 165 virtual void TearDown() OVERRIDE { |
| 148 backend_->StopSyncingForShutdown(); | 166 if (backend_.get()) { |
| 149 backend_->Shutdown(false); | 167 backend_->StopSyncingForShutdown(); |
| 168 backend_->Shutdown(false); |
| 169 } |
| 150 backend_.reset(); | 170 backend_.reset(); |
| 151 sync_prefs_.reset(); | 171 sync_prefs_.reset(); |
| 152 invalidator_storage_.reset(); | 172 invalidator_storage_.reset(); |
| 153 profile_.reset(); | 173 profile_.reset(); |
| 154 // Pump messages posted by the sync thread (which may end up | 174 // Pump messages posted by the sync thread (which may end up |
| 155 // posting on the IO thread). | 175 // posting on the IO thread). |
| 156 ui_loop_.RunAllPending(); | 176 ui_loop_.RunAllPending(); |
| 157 io_thread_.Stop(); | 177 io_thread_.Stop(); |
| 158 // Pump any messages posted by the IO thread. | 178 // Pump any messages posted by the IO thread. |
| 159 ui_loop_.RunAllPending(); | 179 ui_loop_.RunAllPending(); |
| 160 } | 180 } |
| 161 | 181 |
| 162 // Synchronously initializes the backend. | 182 // Synchronously initializes the backend. |
| 163 void InitializeBackend() { | 183 void InitializeBackend() { |
| 164 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, true)). | 184 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, true)). |
| 165 WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 185 WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
| 166 backend_->Initialize(&mock_frontend_, | 186 backend_->Initialize(&mock_frontend_, |
| 167 syncer::WeakHandle<syncer::JsEventHandler>(), | 187 syncer::WeakHandle<syncer::JsEventHandler>(), |
| 168 GURL(""), | 188 GURL(""), |
| 169 credentials_, | 189 credentials_, |
| 170 true, | 190 true, |
| 171 &fake_sync_manager_factory_, | 191 &fake_manager_factory_, |
| 172 &handler_, | 192 &handler_, |
| 173 NULL); | 193 NULL); |
| 174 ui_loop_.PostDelayedTask(FROM_HERE, | 194 ui_loop_.PostDelayedTask(FROM_HERE, |
| 175 ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); | 195 ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); |
| 176 ui_loop_.Run(); | 196 ui_loop_.Run(); |
| 197 // |fake_manager_factory_|'s fake_manager() is set on the sync |
| 198 // thread, but we can rely on the message loop barriers to |
| 199 // guarantee that we see the updated value. |
| 200 fake_manager_ = fake_manager_factory_.fake_manager(); |
| 201 DCHECK(fake_manager_); |
| 177 } | 202 } |
| 178 | 203 |
| 179 // Synchronously configures the backend's datatypes. | 204 // Synchronously configures the backend's datatypes. |
| 180 void ConfigureDataTypes(syncer::ModelTypeSet types_to_add, | 205 void ConfigureDataTypes(syncer::ModelTypeSet types_to_add, |
| 181 syncer::ModelTypeSet types_to_remove, | 206 syncer::ModelTypeSet types_to_remove, |
| 182 BackendDataTypeConfigurer::NigoriState nigori_state) { | 207 BackendDataTypeConfigurer::NigoriState nigori_state) { |
| 183 backend_->ConfigureDataTypes( | 208 backend_->ConfigureDataTypes( |
| 184 syncer::CONFIGURE_REASON_RECONFIGURATION, | 209 syncer::CONFIGURE_REASON_RECONFIGURATION, |
| 185 types_to_add, | 210 types_to_add, |
| 186 types_to_remove, | 211 types_to_remove, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 199 MessageLoop::current()->Quit(); | 224 MessageLoop::current()->Quit(); |
| 200 } | 225 } |
| 201 | 226 |
| 202 void OnDownloadRetry() { | 227 void OnDownloadRetry() { |
| 203 NOTIMPLEMENTED(); | 228 NOTIMPLEMENTED(); |
| 204 } | 229 } |
| 205 | 230 |
| 206 MessageLoop ui_loop_; | 231 MessageLoop ui_loop_; |
| 207 content::TestBrowserThread ui_thread_; | 232 content::TestBrowserThread ui_thread_; |
| 208 content::TestBrowserThread io_thread_; | 233 content::TestBrowserThread io_thread_; |
| 209 MockSyncFrontend mock_frontend_; | 234 StrictMock<MockSyncFrontend> mock_frontend_; |
| 210 syncer::SyncCredentials credentials_; | 235 syncer::SyncCredentials credentials_; |
| 211 syncer::TestUnrecoverableErrorHandler handler_; | 236 syncer::TestUnrecoverableErrorHandler handler_; |
| 212 scoped_ptr<TestingProfile> profile_; | 237 scoped_ptr<TestingProfile> profile_; |
| 213 scoped_ptr<SyncPrefs> sync_prefs_; | 238 scoped_ptr<SyncPrefs> sync_prefs_; |
| 214 scoped_ptr<InvalidatorStorage> invalidator_storage_; | 239 scoped_ptr<InvalidatorStorage> invalidator_storage_; |
| 215 scoped_ptr<SyncBackendHost> backend_; | 240 scoped_ptr<SyncBackendHost> backend_; |
| 216 FakeSyncManagerFactory fake_sync_manager_factory_; | |
| 217 FakeSyncManager* fake_manager_; | 241 FakeSyncManager* fake_manager_; |
| 242 FakeSyncManagerFactory fake_manager_factory_; |
| 218 syncer::ModelTypeSet enabled_types_; | 243 syncer::ModelTypeSet enabled_types_; |
| 219 }; | 244 }; |
| 220 | 245 |
| 221 // Test basic initialization with no initial types (first time initialization). | 246 // Test basic initialization with no initial types (first time initialization). |
| 222 // Only the nigori should be configured. | 247 // Only the nigori should be configured. |
| 223 TEST_F(SyncBackendHostTest, InitShutdown) { | 248 TEST_F(SyncBackendHostTest, InitShutdown) { |
| 224 InitializeBackend(); | 249 InitializeBackend(); |
| 225 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( | 250 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
| 226 syncer::ModelTypeSet(syncer::NIGORI))); | 251 syncer::ModelTypeSet(syncer::NIGORI))); |
| 227 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( | 252 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 250 EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_)); | 275 EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_)); |
| 251 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( | 276 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
| 252 enabled_types_).Empty()); | 277 enabled_types_).Empty()); |
| 253 } | 278 } |
| 254 | 279 |
| 255 // Test the restart after setting up sync scenario. No enabled types should be | 280 // Test the restart after setting up sync scenario. No enabled types should be |
| 256 // downloaded or cleaned. | 281 // downloaded or cleaned. |
| 257 TEST_F(SyncBackendHostTest, Restart) { | 282 TEST_F(SyncBackendHostTest, Restart) { |
| 258 sync_prefs_->SetSyncSetupCompleted(); | 283 sync_prefs_->SetSyncSetupCompleted(); |
| 259 syncer::ModelTypeSet all_but_nigori = enabled_types_; | 284 syncer::ModelTypeSet all_but_nigori = enabled_types_; |
| 260 fake_manager_->set_progress_marker_types(enabled_types_); | 285 fake_manager_factory_.set_progress_marker_types(enabled_types_); |
| 261 fake_manager_->set_initial_sync_ended_types(enabled_types_); | 286 fake_manager_factory_.set_initial_sync_ended_types(enabled_types_); |
| 262 InitializeBackend(); | 287 InitializeBackend(); |
| 263 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); | 288 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
| 264 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), | 289 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
| 265 enabled_types_).Empty()); | 290 enabled_types_).Empty()); |
| 266 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_)); | 291 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_)); |
| 267 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( | 292 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
| 268 enabled_types_).Empty()); | 293 enabled_types_).Empty()); |
| 269 | 294 |
| 270 ConfigureDataTypes(enabled_types_, | 295 ConfigureDataTypes(enabled_types_, |
| 271 Difference(syncer::ModelTypeSet::All(), | 296 Difference(syncer::ModelTypeSet::All(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 282 | 307 |
| 283 // Test a sync restart scenario where some types had never finished configuring. | 308 // Test a sync restart scenario where some types had never finished configuring. |
| 284 // The partial types should be purged, then reconfigured properly. | 309 // The partial types should be purged, then reconfigured properly. |
| 285 TEST_F(SyncBackendHostTest, PartialTypes) { | 310 TEST_F(SyncBackendHostTest, PartialTypes) { |
| 286 sync_prefs_->SetSyncSetupCompleted(); | 311 sync_prefs_->SetSyncSetupCompleted(); |
| 287 // Set sync manager behavior before passing it down. All types have progress | 312 // Set sync manager behavior before passing it down. All types have progress |
| 288 // markers, but nigori and bookmarks are missing initial sync ended. | 313 // markers, but nigori and bookmarks are missing initial sync ended. |
| 289 syncer::ModelTypeSet partial_types(syncer::NIGORI, syncer::BOOKMARKS); | 314 syncer::ModelTypeSet partial_types(syncer::NIGORI, syncer::BOOKMARKS); |
| 290 syncer::ModelTypeSet full_types = | 315 syncer::ModelTypeSet full_types = |
| 291 Difference(enabled_types_, partial_types); | 316 Difference(enabled_types_, partial_types); |
| 292 fake_manager_->set_progress_marker_types(enabled_types_); | 317 fake_manager_factory_.set_progress_marker_types(enabled_types_); |
| 293 fake_manager_->set_initial_sync_ended_types(full_types); | 318 fake_manager_factory_.set_initial_sync_ended_types(full_types); |
| 294 | 319 |
| 295 // Bringing up the backend should purge all partial types, then proceed to | 320 // Bringing up the backend should purge all partial types, then proceed to |
| 296 // download the Nigori. | 321 // download the Nigori. |
| 297 InitializeBackend(); | 322 InitializeBackend(); |
| 298 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( | 323 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
| 299 syncer::ModelTypeSet(syncer::NIGORI))); | 324 syncer::ModelTypeSet(syncer::NIGORI))); |
| 300 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); | 325 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); |
| 301 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( | 326 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals( |
| 302 Union(full_types, syncer::ModelTypeSet(syncer::NIGORI)))); | 327 Union(full_types, syncer::ModelTypeSet(syncer::NIGORI)))); |
| 303 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( | 328 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 old_types).Equals(disabled_types)); | 494 old_types).Equals(disabled_types)); |
| 470 } | 495 } |
| 471 | 496 |
| 472 // Test restarting the browser to newly supported datatypes. The new datatypes | 497 // Test restarting the browser to newly supported datatypes. The new datatypes |
| 473 // should be downloaded on the configuration after backend initialization. | 498 // should be downloaded on the configuration after backend initialization. |
| 474 TEST_F(SyncBackendHostTest, NewlySupportedTypes) { | 499 TEST_F(SyncBackendHostTest, NewlySupportedTypes) { |
| 475 sync_prefs_->SetSyncSetupCompleted(); | 500 sync_prefs_->SetSyncSetupCompleted(); |
| 476 // Set sync manager behavior before passing it down. All types have progress | 501 // Set sync manager behavior before passing it down. All types have progress |
| 477 // markers and initial sync ended except the new types. | 502 // markers and initial sync ended except the new types. |
| 478 syncer::ModelTypeSet old_types = enabled_types_; | 503 syncer::ModelTypeSet old_types = enabled_types_; |
| 479 fake_manager_->set_progress_marker_types(old_types); | 504 fake_manager_factory_.set_progress_marker_types(old_types); |
| 480 fake_manager_->set_initial_sync_ended_types(old_types); | 505 fake_manager_factory_.set_initial_sync_ended_types(old_types); |
| 481 syncer::ModelTypeSet new_types(syncer::APP_SETTINGS, | 506 syncer::ModelTypeSet new_types(syncer::APP_SETTINGS, |
| 482 syncer::EXTENSION_SETTINGS); | 507 syncer::EXTENSION_SETTINGS); |
| 483 enabled_types_.PutAll(new_types); | 508 enabled_types_.PutAll(new_types); |
| 484 | 509 |
| 485 // Does nothing. | 510 // Does nothing. |
| 486 InitializeBackend(); | 511 InitializeBackend(); |
| 487 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); | 512 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty()); |
| 488 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), | 513 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), |
| 489 old_types).Empty()); | 514 old_types).Empty()); |
| 490 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(old_types)); | 515 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(old_types)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 510 // types as well. Both partial and newly supported types should be downloaded | 535 // types as well. Both partial and newly supported types should be downloaded |
| 511 // the configuration. | 536 // the configuration. |
| 512 TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) { | 537 TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) { |
| 513 sync_prefs_->SetSyncSetupCompleted(); | 538 sync_prefs_->SetSyncSetupCompleted(); |
| 514 // Set sync manager behavior before passing it down. All types have progress | 539 // Set sync manager behavior before passing it down. All types have progress |
| 515 // markers and initial sync ended except the new types. | 540 // markers and initial sync ended except the new types. |
| 516 syncer::ModelTypeSet old_types = enabled_types_; | 541 syncer::ModelTypeSet old_types = enabled_types_; |
| 517 syncer::ModelTypeSet partial_types(syncer::NIGORI, syncer::BOOKMARKS); | 542 syncer::ModelTypeSet partial_types(syncer::NIGORI, syncer::BOOKMARKS); |
| 518 syncer::ModelTypeSet full_types = | 543 syncer::ModelTypeSet full_types = |
| 519 Difference(enabled_types_, partial_types); | 544 Difference(enabled_types_, partial_types); |
| 520 fake_manager_->set_progress_marker_types(old_types); | 545 fake_manager_factory_.set_progress_marker_types(old_types); |
| 521 fake_manager_->set_initial_sync_ended_types(full_types); | 546 fake_manager_factory_.set_initial_sync_ended_types(full_types); |
| 522 syncer::ModelTypeSet new_types(syncer::APP_SETTINGS, | 547 syncer::ModelTypeSet new_types(syncer::APP_SETTINGS, |
| 523 syncer::EXTENSION_SETTINGS); | 548 syncer::EXTENSION_SETTINGS); |
| 524 enabled_types_.PutAll(new_types); | 549 enabled_types_.PutAll(new_types); |
| 525 | 550 |
| 526 // Purge the partial types. The nigori will be among the purged types, but | 551 // Purge the partial types. The nigori will be among the purged types, but |
| 527 // the syncer will re-download it by the time the initialization is complete. | 552 // the syncer will re-download it by the time the initialization is complete. |
| 528 InitializeBackend(); | 553 InitializeBackend(); |
| 529 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( | 554 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( |
| 530 syncer::ModelTypeSet(syncer::NIGORI))); | 555 syncer::ModelTypeSet(syncer::NIGORI))); |
| 531 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); | 556 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 627 |
| 603 syncer::ObjectIdSet ids; | 628 syncer::ObjectIdSet ids; |
| 604 ids.insert(invalidation::ObjectId(4, "id4")); | 629 ids.insert(invalidation::ObjectId(4, "id4")); |
| 605 backend_->UpdateRegisteredInvalidationIds(ids); | 630 backend_->UpdateRegisteredInvalidationIds(ids); |
| 606 fake_manager_->DisableNotifications(syncer::TRANSIENT_NOTIFICATION_ERROR); | 631 fake_manager_->DisableNotifications(syncer::TRANSIENT_NOTIFICATION_ERROR); |
| 607 ui_loop_.PostDelayedTask( | 632 ui_loop_.PostDelayedTask( |
| 608 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); | 633 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); |
| 609 ui_loop_.Run(); | 634 ui_loop_.Run(); |
| 610 } | 635 } |
| 611 | 636 |
| 637 // Call StopSyncingForShutdown() on the backend and fire some notifications |
| 638 // before calling Shutdown(). Then start up and shut down the backend again. |
| 639 // Those notifications shouldn't propagate to the frontend. |
| 640 TEST_F(SyncBackendHostTest, NotificationsAfterStopSyncingForShutdown) { |
| 641 InitializeBackend(); |
| 642 |
| 643 syncer::ObjectIdSet ids; |
| 644 ids.insert(invalidation::ObjectId(5, "id5")); |
| 645 backend_->UpdateRegisteredInvalidationIds(ids); |
| 646 |
| 647 backend_->StopSyncingForShutdown(); |
| 648 |
| 649 // Should not trigger anything. |
| 650 fake_manager_->DisableNotifications(syncer::TRANSIENT_NOTIFICATION_ERROR); |
| 651 fake_manager_->EnableNotifications(); |
| 652 const syncer::ObjectIdPayloadMap& id_payloads = |
| 653 syncer::ObjectIdSetToPayloadMap(ids, "payload"); |
| 654 fake_manager_->Invalidate(id_payloads, syncer::REMOTE_NOTIFICATION); |
| 655 |
| 656 // Make sure the above calls take effect before we continue. |
| 657 fake_manager_->WaitForSyncThread(); |
| 658 |
| 659 backend_->Shutdown(false); |
| 660 backend_.reset(); |
| 661 |
| 662 TearDown(); |
| 663 SetUp(); |
| 664 } |
| 665 |
| 612 } // namespace | 666 } // namespace |
| 613 | 667 |
| 614 } // namespace browser_sync | 668 } // namespace browser_sync |
| OLD | NEW |