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

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 10824252: Revert 150990 - [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | sync/internal_api/public/sync_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/signin/signin_manager.h" 9 #include "chrome/browser/signin/signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 const syncer::ObjectIdPayloadMap& payloads = 382 const syncer::ObjectIdPayloadMap& payloads =
383 syncer::ObjectIdSetToPayloadMap(ids, "payload"); 383 syncer::ObjectIdSetToPayloadMap(ids, "payload");
384 384
385 StrictMock<syncer::MockSyncNotifierObserver> observer; 385 StrictMock<syncer::MockSyncNotifierObserver> observer;
386 EXPECT_CALL(observer, OnNotificationsEnabled()); 386 EXPECT_CALL(observer, OnNotificationsEnabled());
387 EXPECT_CALL(observer, OnIncomingNotification( 387 EXPECT_CALL(observer, OnIncomingNotification(
388 payloads, syncer::REMOTE_NOTIFICATION)); 388 payloads, syncer::REMOTE_NOTIFICATION));
389 EXPECT_CALL(observer, OnNotificationsDisabled( 389 EXPECT_CALL(observer, OnNotificationsDisabled(
390 syncer::TRANSIENT_NOTIFICATION_ERROR)); 390 syncer::TRANSIENT_NOTIFICATION_ERROR));
391 391
392 service_->RegisterInvalidationHandler(&observer);
393 service_->UpdateRegisteredInvalidationIds(&observer, ids); 392 service_->UpdateRegisteredInvalidationIds(&observer, ids);
394 393
395 SyncBackendHostForProfileSyncTest* const backend = 394 SyncBackendHostForProfileSyncTest* const backend =
396 service_->GetBackendForTest(); 395 service_->GetBackendForTest();
397 396
398 backend->EmitOnNotificationsEnabled(); 397 backend->EmitOnNotificationsEnabled();
399 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 398 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
400 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 399 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
401 400
402 Mock::VerifyAndClearExpectations(&observer); 401 Mock::VerifyAndClearExpectations(&observer);
403 402
404 service_->UnregisterInvalidationHandler(&observer); 403 service_->UpdateRegisteredInvalidationIds(&observer, syncer::ObjectIdSet());
405 404
406 backend->EmitOnNotificationsEnabled(); 405 backend->EmitOnNotificationsEnabled();
407 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 406 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
408 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 407 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
409 } 408 }
410 409
411 // Register for some IDs with the ProfileSyncService, restart sync, 410 // Register for some IDs with the ProfileSyncService, restart sync,
412 // and trigger some invalidation messages. They should still be 411 // and trigger some invalidation messages. They should still be
413 // received by the observer. 412 // received by the observer.
414 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) { 413 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
415 StartSyncService(); 414 StartSyncService();
416 415
417 syncer::ObjectIdSet ids; 416 syncer::ObjectIdSet ids;
418 ids.insert(invalidation::ObjectId(3, "id3")); 417 ids.insert(invalidation::ObjectId(3, "id3"));
419 const syncer::ObjectIdPayloadMap& payloads = 418 const syncer::ObjectIdPayloadMap& payloads =
420 syncer::ObjectIdSetToPayloadMap(ids, "payload"); 419 syncer::ObjectIdSetToPayloadMap(ids, "payload");
421 420
422 StrictMock<syncer::MockSyncNotifierObserver> observer; 421 StrictMock<syncer::MockSyncNotifierObserver> observer;
423 EXPECT_CALL(observer, OnNotificationsEnabled()); 422 EXPECT_CALL(observer, OnNotificationsEnabled());
424 EXPECT_CALL(observer, OnIncomingNotification( 423 EXPECT_CALL(observer, OnIncomingNotification(
425 payloads, syncer::REMOTE_NOTIFICATION)); 424 payloads, syncer::REMOTE_NOTIFICATION));
426 EXPECT_CALL(observer, OnNotificationsDisabled( 425 EXPECT_CALL(observer, OnNotificationsDisabled(
427 syncer::TRANSIENT_NOTIFICATION_ERROR)); 426 syncer::TRANSIENT_NOTIFICATION_ERROR));
428 427
429 service_->RegisterInvalidationHandler(&observer);
430 service_->UpdateRegisteredInvalidationIds(&observer, ids); 428 service_->UpdateRegisteredInvalidationIds(&observer, ids);
431 429
432 service_->StopAndSuppress(); 430 service_->StopAndSuppress();
433 service_->UnsuppressAndStart(); 431 service_->UnsuppressAndStart();
434 432
435 SyncBackendHostForProfileSyncTest* const backend = 433 SyncBackendHostForProfileSyncTest* const backend =
436 service_->GetBackendForTest(); 434 service_->GetBackendForTest();
437 435
438 backend->EmitOnNotificationsEnabled(); 436 backend->EmitOnNotificationsEnabled();
439 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 437 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
440 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 438 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
441 } 439 }
442 440
443 } // namespace 441 } // namespace
444 } // namespace browser_sync 442 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | sync/internal_api/public/sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698