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

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

Issue 11043012: [Sync] Notify invalidation handlers when sync is disabled/enabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 2 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') | no next file » | 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // recreate it. This test is useful mainly when it is run under valgrind. Its 392 // recreate it. This test is useful mainly when it is run under valgrind. Its
393 // expectations are not very interesting. 393 // expectations are not very interesting.
394 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { 394 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) {
395 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, 395 harness_.StartSyncServiceAndSetInitialSyncEnded(false, true, true, true,
396 syncer::STORAGE_INVALID); 396 syncer::STORAGE_INVALID);
397 397
398 // The backend is not ready. Ensure the PSS knows this. 398 // The backend is not ready. Ensure the PSS knows this.
399 EXPECT_FALSE(harness_.service->sync_initialized()); 399 EXPECT_FALSE(harness_.service->sync_initialized());
400 } 400 }
401 401
402 // Register a handler with the ProfileSyncService, and disable and
403 // reenable sync. The handler should get notified of the state
404 // changes.
405 TEST_F(ProfileSyncServiceTest, DisableInvalidationsOnStop) {
406 harness_.StartSyncService();
407
408 syncer::FakeInvalidationHandler handler;
409 harness_.service->RegisterInvalidationHandler(&handler);
410
411 SyncBackendHostForProfileSyncTest* const backend =
412 harness_.service->GetBackendForTest();
413
414 backend->EmitOnInvalidatorStateChange(syncer::INVALIDATIONS_ENABLED);
415 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState());
416
417 harness_.service->StopAndSuppress();
418 EXPECT_EQ(syncer::TRANSIENT_INVALIDATION_ERROR,
419 handler.GetInvalidatorState());
420
421 harness_.service->UnsuppressAndStart();
422 EXPECT_EQ(syncer::INVALIDATIONS_ENABLED, handler.GetInvalidatorState());
423
424 harness_.service->UnregisterInvalidationHandler(&handler);
425 }
426
402 // Register for some IDs with the ProfileSyncService, restart sync, 427 // Register for some IDs with the ProfileSyncService, restart sync,
403 // and trigger some invalidation messages. They should still be 428 // and trigger some invalidation messages. They should still be
404 // received by the handler. 429 // received by the handler.
405 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) { 430 TEST_F(ProfileSyncServiceTest, UpdateRegisteredInvalidationIdsPersistence) {
406 harness_.StartSyncService(); 431 harness_.StartSyncService();
407 432
408 syncer::ObjectIdSet ids; 433 syncer::ObjectIdSet ids;
409 ids.insert(invalidation::ObjectId(3, "id3")); 434 ids.insert(invalidation::ObjectId(3, "id3"));
410 const syncer::ObjectIdInvalidationMap& states = 435 const syncer::ObjectIdInvalidationMap& states =
411 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); 436 syncer::ObjectIdSetToInvalidationMap(ids, "payload");
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 namespace syncer { 573 namespace syncer {
549 namespace { 574 namespace {
550 575
551 // ProfileSyncService should behave just like an invalidator. 576 // ProfileSyncService should behave just like an invalidator.
552 INSTANTIATE_TYPED_TEST_CASE_P( 577 INSTANTIATE_TYPED_TEST_CASE_P(
553 ProfileSyncServiceInvalidatorTest, InvalidatorTest, 578 ProfileSyncServiceInvalidatorTest, InvalidatorTest,
554 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); 579 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate);
555 580
556 } // namespace 581 } // namespace
557 } // namespace syncer 582 } // namespace syncer
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698