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