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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_impl_unittest.cc

Issue 566623003: Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - part 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More CR feedback addressed in DeviceInfoSyncService. Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync/glue/sync_backend_host_impl.h" 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/test/test_timeouts.h" 14 #include "base/test/test_timeouts.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
17 #include "chrome/browser/prefs/pref_service_syncable.h" 17 #include "chrome/browser/prefs/pref_service_syncable.h"
18 #include "chrome/browser/sync/glue/device_info.h" 18 #include "chrome/browser/sync/glue/device_info.h"
19 #include "chrome/browser/sync/glue/synced_device_tracker.h"
20 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
22 #include "chrome/test/base/testing_profile_manager.h" 21 #include "chrome/test/base/testing_profile_manager.h"
23 #include "components/invalidation/invalidator_state.h" 22 #include "components/invalidation/invalidator_state.h"
24 #include "components/invalidation/invalidator_storage.h" 23 #include "components/invalidation/invalidator_storage.h"
25 #include "components/invalidation/profile_invalidation_provider.h" 24 #include "components/invalidation/profile_invalidation_provider.h"
26 #include "components/sync_driver/sync_frontend.h" 25 #include "components/sync_driver/sync_frontend.h"
27 #include "components/sync_driver/sync_prefs.h" 26 #include "components/sync_driver/sync_prefs.h"
28 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals( 622 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
624 Union(new_types, partial_types))); 623 Union(new_types, partial_types)));
625 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(), 624 EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
626 enabled_types_).Empty()); 625 enabled_types_).Empty());
627 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_)); 626 EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
628 EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_)); 627 EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
629 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( 628 EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
630 enabled_types_).Empty()); 629 enabled_types_).Empty());
631 } 630 }
632 631
633 // Ensure the device info tracker is initialized properly on startup.
634 TEST_F(SyncBackendHostTest, InitializeDeviceInfo) {
635 ASSERT_EQ(NULL, backend_->GetSyncedDeviceTracker());
636
637 InitializeBackend(true);
638 const SyncedDeviceTracker* device_tracker =
639 backend_->GetSyncedDeviceTracker();
640 ASSERT_TRUE(device_tracker->ReadLocalDeviceInfo());
641 }
642
643 // Verify that downloading control types only downloads those types that do 632 // Verify that downloading control types only downloads those types that do
644 // not have initial sync ended set. 633 // not have initial sync ended set.
645 TEST_F(SyncBackendHostTest, DownloadControlTypes) { 634 TEST_F(SyncBackendHostTest, DownloadControlTypes) {
646 sync_prefs_->SetSyncSetupCompleted(); 635 sync_prefs_->SetSyncSetupCompleted();
647 // Set sync manager behavior before passing it down. Experiments and device 636 // Set sync manager behavior before passing it down. Experiments and device
648 // info are new types without progress markers or initial sync ended, while 637 // info are new types without progress markers or initial sync ended, while
649 // all other types have been fully downloaded and applied. 638 // all other types have been fully downloaded and applied.
650 syncer::ModelTypeSet new_types(syncer::EXPERIMENTS, syncer::DEVICE_INFO); 639 syncer::ModelTypeSet new_types(syncer::EXPERIMENTS, syncer::NIGORI);
651 syncer::ModelTypeSet old_types = 640 syncer::ModelTypeSet old_types =
652 Difference(enabled_types_, new_types); 641 Difference(enabled_types_, new_types);
653 fake_manager_factory_->set_progress_marker_types(old_types); 642 fake_manager_factory_->set_progress_marker_types(old_types);
654 fake_manager_factory_->set_initial_sync_ended_types(old_types); 643 fake_manager_factory_->set_initial_sync_ended_types(old_types);
655 644
656 // Bringing up the backend should download the new types without downloading 645 // Bringing up the backend should download the new types without downloading
657 // any old types. 646 // any old types.
658 InitializeBackend(true); 647 InitializeBackend(true);
659 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(new_types)); 648 EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(new_types));
660 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().Equals( 649 EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().Equals(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 Difference(syncer::ModelTypeSet::All(), 768 Difference(syncer::ModelTypeSet::All(),
780 enabled_types_), 769 enabled_types_),
781 syncer::ModelTypeSet()); 770 syncer::ModelTypeSet());
782 EXPECT_FALSE(fake_manager_->GetTypesWithEmptyProgressMarkerToken( 771 EXPECT_FALSE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
783 error_types).Empty()); 772 error_types).Empty());
784 } 773 }
785 774
786 } // namespace 775 } // namespace
787 776
788 } // namespace browser_sync 777 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_impl.cc ('k') | chrome/browser/sync/glue/sync_backend_host_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698