Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698