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

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

Issue 10837214: Refactor ModelTypePayloadMap and ObjectIdPayloadMap to StateMaps. (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
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // Register for some IDs with the ProfileSyncService and trigger some 372 // Register for some IDs with the ProfileSyncService and trigger some
373 // invalidation messages. They should be received by the observer. 373 // invalidation messages. They should be received by the observer.
374 // Then unregister and trigger the invalidation messages again. Those 374 // Then unregister and trigger the invalidation messages again. Those
375 // shouldn't be received by the observer. 375 // shouldn't be received by the observer.
376 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIds) { 376 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIds) {
377 StartSyncService(); 377 StartSyncService();
378 378
379 syncer::ObjectIdSet ids; 379 syncer::ObjectIdSet ids;
380 ids.insert(invalidation::ObjectId(1, "id1")); 380 ids.insert(invalidation::ObjectId(1, "id1"));
381 ids.insert(invalidation::ObjectId(2, "id2")); 381 ids.insert(invalidation::ObjectId(2, "id2"));
382 const syncer::ObjectIdPayloadMap& payloads = 382 const syncer::ObjectIdStateMap& states =
383 syncer::ObjectIdSetToPayloadMap(ids, "payload"); 383 syncer::ObjectIdSetToStateMap(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 states, 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_->RegisterInvalidationHandler(&observer);
393 service_->UpdateRegisteredInvalidationIds(&observer, ids); 393 service_->UpdateRegisteredInvalidationIds(&observer, ids);
394 394
395 SyncBackendHostForProfileSyncTest* const backend = 395 SyncBackendHostForProfileSyncTest* const backend =
396 service_->GetBackendForTest(); 396 service_->GetBackendForTest();
397 397
398 backend->EmitOnNotificationsEnabled(); 398 backend->EmitOnNotificationsEnabled();
399 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 399 backend->EmitOnIncomingNotification(states, syncer::REMOTE_NOTIFICATION);
400 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 400 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
401 401
402 Mock::VerifyAndClearExpectations(&observer); 402 Mock::VerifyAndClearExpectations(&observer);
403 403
404 service_->UnregisterInvalidationHandler(&observer); 404 service_->UnregisterInvalidationHandler(&observer);
405 405
406 backend->EmitOnNotificationsEnabled(); 406 backend->EmitOnNotificationsEnabled();
407 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 407 backend->EmitOnIncomingNotification(states, syncer::REMOTE_NOTIFICATION);
408 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 408 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
409 } 409 }
410 410
411 // Register for some IDs with the ProfileSyncService, restart sync, 411 // Register for some IDs with the ProfileSyncService, restart sync,
412 // and trigger some invalidation messages. They should still be 412 // and trigger some invalidation messages. They should still be
413 // received by the observer. 413 // received by the observer.
414 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) { 414 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
415 StartSyncService(); 415 StartSyncService();
416 416
417 syncer::ObjectIdSet ids; 417 syncer::ObjectIdSet ids;
418 ids.insert(invalidation::ObjectId(3, "id3")); 418 ids.insert(invalidation::ObjectId(3, "id3"));
419 const syncer::ObjectIdPayloadMap& payloads = 419 const syncer::ObjectIdStateMap& states =
420 syncer::ObjectIdSetToPayloadMap(ids, "payload"); 420 syncer::ObjectIdSetToStateMap(ids, "payload");
421 421
422 StrictMock<syncer::MockSyncNotifierObserver> observer; 422 StrictMock<syncer::MockSyncNotifierObserver> observer;
423 EXPECT_CALL(observer, OnNotificationsEnabled()); 423 EXPECT_CALL(observer, OnNotificationsEnabled());
424 EXPECT_CALL(observer, OnIncomingNotification( 424 EXPECT_CALL(observer, OnIncomingNotification(
425 payloads, syncer::REMOTE_NOTIFICATION)); 425 states, syncer::REMOTE_NOTIFICATION));
426 // This may get called more than once, as a real notifier is 426 // This may get called more than once, as a real notifier is
427 // created. 427 // created.
428 EXPECT_CALL(observer, OnNotificationsDisabled( 428 EXPECT_CALL(observer, OnNotificationsDisabled(
429 syncer::TRANSIENT_NOTIFICATION_ERROR)).Times(AtLeast(1)); 429 syncer::TRANSIENT_NOTIFICATION_ERROR)).Times(AtLeast(1));
430 430
431 service_->RegisterInvalidationHandler(&observer); 431 service_->RegisterInvalidationHandler(&observer);
432 service_->UpdateRegisteredInvalidationIds(&observer, ids); 432 service_->UpdateRegisteredInvalidationIds(&observer, ids);
433 433
434 service_->StopAndSuppress(); 434 service_->StopAndSuppress();
435 service_->UnsuppressAndStart(); 435 service_->UnsuppressAndStart();
436 436
437 SyncBackendHostForProfileSyncTest* const backend = 437 SyncBackendHostForProfileSyncTest* const backend =
438 service_->GetBackendForTest(); 438 service_->GetBackendForTest();
439 439
440 backend->EmitOnNotificationsEnabled(); 440 backend->EmitOnNotificationsEnabled();
441 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION); 441 backend->EmitOnIncomingNotification(states, syncer::REMOTE_NOTIFICATION);
442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 442 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
443 } 443 }
444 444
445 } // namespace 445 } // namespace
446 } // namespace browser_sync 446 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698