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

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

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use new API 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 "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);
392 service_->UpdateRegisteredInvalidationIds(&observer, ids); 393 service_->UpdateRegisteredInvalidationIds(&observer, ids);
393 394
394 SyncBackendHostForProfileSyncTest* const backend = 395 SyncBackendHostForProfileSyncTest* const backend =
395 service_->GetBackendForTest(); 396 service_->GetBackendForTest();
396 397
397 backend->EmitOnNotificationsEnabled(); 398 backend->EmitOnNotificationsEnabled();
398 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 399 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
399 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 400 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
400 401
401 Mock::VerifyAndClearExpectations(&observer); 402 Mock::VerifyAndClearExpectations(&observer);
402 403
403 service_->UpdateRegisteredInvalidationIds(&observer, syncer::ObjectIdSet()); 404 service_->UnregisterInvalidationHandler(&observer);
404 405
405 backend->EmitOnNotificationsEnabled(); 406 backend->EmitOnNotificationsEnabled();
406 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 407 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
407 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 408 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
408 } 409 }
409 410
410 // Register for some IDs with the ProfileSyncService, restart sync, 411 // Register for some IDs with the ProfileSyncService, restart sync,
411 // and trigger some invalidation messages. They should still be 412 // and trigger some invalidation messages. They should still be
412 // received by the observer. 413 // received by the observer.
413 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) { 414 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
414 StartSyncService(); 415 StartSyncService();
415 416
416 syncer::ObjectIdSet ids; 417 syncer::ObjectIdSet ids;
417 ids.insert(invalidation::ObjectId(3, "id3")); 418 ids.insert(invalidation::ObjectId(3, "id3"));
418 const syncer::ObjectIdPayloadMap& payloads = 419 const syncer::ObjectIdPayloadMap& payloads =
419 syncer::ObjectIdSetToPayloadMap(ids, "payload"); 420 syncer::ObjectIdSetToPayloadMap(ids, "payload");
420 421
421 StrictMock<syncer::MockSyncNotifierObserver> observer; 422 StrictMock<syncer::MockSyncNotifierObserver> observer;
422 EXPECT_CALL(observer, OnNotificationsEnabled()); 423 EXPECT_CALL(observer, OnNotificationsEnabled());
423 EXPECT_CALL(observer, OnIncomingNotification( 424 EXPECT_CALL(observer, OnIncomingNotification(
424 payloads, syncer::REMOTE_NOTIFICATION)); 425 payloads, syncer::REMOTE_NOTIFICATION));
425 EXPECT_CALL(observer, OnNotificationsDisabled( 426 EXPECT_CALL(observer, OnNotificationsDisabled(
426 syncer::TRANSIENT_NOTIFICATION_ERROR)); 427 syncer::TRANSIENT_NOTIFICATION_ERROR));
427 428
429 service_->RegisterInvalidationHandler(&observer);
428 service_->UpdateRegisteredInvalidationIds(&observer, ids); 430 service_->UpdateRegisteredInvalidationIds(&observer, ids);
429 431
430 service_->StopAndSuppress(); 432 service_->StopAndSuppress();
431 service_->UnsuppressAndStart(); 433 service_->UnsuppressAndStart();
432 434
433 SyncBackendHostForProfileSyncTest* const backend = 435 SyncBackendHostForProfileSyncTest* const backend =
434 service_->GetBackendForTest(); 436 service_->GetBackendForTest();
435 437
436 backend->EmitOnNotificationsEnabled(); 438 backend->EmitOnNotificationsEnabled();
437 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 439 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
438 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 440 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
439 } 441 }
440 442
441 } // namespace 443 } // namespace
442 } // namespace browser_sync 444 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698