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

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

Issue 10828158: [Sync] Address msw's comments for r149747 (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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::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(
388 payloads, syncer::REMOTE_NOTIFICATION));
387 EXPECT_CALL(observer, OnNotificationsDisabled( 389 EXPECT_CALL(observer, OnNotificationsDisabled(
388 syncer::TRANSIENT_NOTIFICATION_ERROR)); 390 syncer::TRANSIENT_NOTIFICATION_ERROR));
389 EXPECT_CALL(observer, OnIncomingNotification(
390 payloads, syncer::REMOTE_NOTIFICATION));
391 391
392 service_->UpdateRegisteredInvalidationIds(&observer, ids); 392 service_->UpdateRegisteredInvalidationIds(&observer, ids);
393 393
394 SyncBackendHostForProfileSyncTest* const backend = 394 SyncBackendHostForProfileSyncTest* const backend =
395 service_->GetBackendForTest(); 395 service_->GetBackendForTest();
396 396
397 backend->EmitOnNotificationsEnabled(); 397 backend->EmitOnNotificationsEnabled();
398 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
398 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 399 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
akalin 2012/08/03 20:08:49 Done.
399 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
400 400
401 Mock::VerifyAndClearExpectations(&observer); 401 Mock::VerifyAndClearExpectations(&observer);
402 402
403 service_->UpdateRegisteredInvalidationIds(&observer, syncer::ObjectIdSet()); 403 service_->UpdateRegisteredInvalidationIds(&observer, syncer::ObjectIdSet());
404 404
405 backend->EmitOnNotificationsEnabled(); 405 backend->EmitOnNotificationsEnabled();
406 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
406 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); 407 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
407 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
408 } 408 }
409 409
410 // Register for some IDs with the ProfileSyncService, restart sync, 410 // Register for some IDs with the ProfileSyncService, restart sync,
411 // and trigger some invalidation messages. They should still be 411 // and trigger some invalidation messages. They should still be
412 // received by the observer. 412 // received by the observer.
413 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) { 413 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
414 StartSyncService(); 414 StartSyncService();
415 415
416 syncer::ObjectIdSet ids;
417 ids.insert(invalidation::ObjectId(3, "id3"));
418 const syncer::ObjectIdPayloadMap& payloads =
419 syncer::ObjectIdSetToPayloadMap(ids, "payload");
420
416 StrictMock<syncer::MockSyncNotifierObserver> observer; 421 StrictMock<syncer::MockSyncNotifierObserver> observer;
417 EXPECT_CALL(observer, OnNotificationsEnabled()); 422 EXPECT_CALL(observer, OnNotificationsEnabled());
423 EXPECT_CALL(observer, OnIncomingNotification(
akalin 2012/08/03 20:08:49 Done.
424 payloads, syncer::REMOTE_NOTIFICATION));
425 EXPECT_CALL(observer, OnNotificationsDisabled(
426 syncer::TRANSIENT_NOTIFICATION_ERROR));
418 427
419 syncer::ObjectIdSet ids;
420 ids.insert(invalidation::ObjectId(3, "id3"));
421 service_->UpdateRegisteredInvalidationIds(&observer, ids); 428 service_->UpdateRegisteredInvalidationIds(&observer, ids);
422 429
423 service_->StopAndSuppress(); 430 service_->StopAndSuppress();
424 service_->UnsuppressAndStart(); 431 service_->UnsuppressAndStart();
425 432
426 service_->GetBackendForTest()->EmitOnNotificationsEnabled(); 433 SyncBackendHostForProfileSyncTest* const backend =
434 service_->GetBackendForTest();
435
436 backend->EmitOnNotificationsEnabled();
437 backend->EmitOnIncomingNotification(payloads, syncer::REMOTE_NOTIFICATION);
438 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR);
427 } 439 }
428 440
429 } // namespace 441 } // namespace
430 } // namespace browser_sync 442 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698