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

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: Work around brittle unit test 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);
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));
426 // This may get called more than once, as a real notifier is
427 // created.
425 EXPECT_CALL(observer, OnNotificationsDisabled( 428 EXPECT_CALL(observer, OnNotificationsDisabled(
426 syncer::TRANSIENT_NOTIFICATION_ERROR)); 429 syncer::TRANSIENT_NOTIFICATION_ERROR)).Times(AtLeast(1));
427 430
431 service_->RegisterInvalidationHandler(&observer);
428 service_->UpdateRegisteredInvalidationIds(&observer, ids); 432 service_->UpdateRegisteredInvalidationIds(&observer, ids);
429 433
430 service_->StopAndSuppress(); 434 service_->StopAndSuppress();
431 service_->UnsuppressAndStart(); 435 service_->UnsuppressAndStart();
432 436
433 SyncBackendHostForProfileSyncTest* const backend = 437 SyncBackendHostForProfileSyncTest* const backend =
434 service_->GetBackendForTest(); 438 service_->GetBackendForTest();
435 439
436 backend->EmitOnNotificationsEnabled(); 440 backend->EmitOnNotificationsEnabled();
437 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 441 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
438 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
439 } 443 }
440 444
441 } // namespace 445 } // namespace
442 } // namespace browser_sync 446 } // 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