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