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

Side by Side Diff: components/sync/engine_impl/sync_manager_impl_unittest.cc

Issue 2641523004: [Sync] Make directory types registration explicit in ModelTypeRegistry (Closed)
Patch Set: Address comments Created 3 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sync/engine_impl/sync_manager_impl.h" 5 #include "components/sync/engine_impl/sync_manager_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 credentials.scope_set = scope_set; 1010 credentials.scope_set = scope_set;
1011 1011
1012 sync_manager_.AddObserver(&manager_observer_); 1012 sync_manager_.AddObserver(&manager_observer_);
1013 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _)) 1013 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _, _))
1014 .WillOnce(DoAll(SaveArg<0>(&js_backend_), 1014 .WillOnce(DoAll(SaveArg<0>(&js_backend_),
1015 SaveArg<2>(&initialization_succeeded_))); 1015 SaveArg<2>(&initialization_succeeded_)));
1016 1016
1017 EXPECT_FALSE(js_backend_.IsInitialized()); 1017 EXPECT_FALSE(js_backend_.IsInitialized());
1018 1018
1019 std::vector<scoped_refptr<ModelSafeWorker>> workers; 1019 std::vector<scoped_refptr<ModelSafeWorker>> workers;
1020 ModelSafeRoutingInfo routing_info;
1021 GetModelSafeRoutingInfo(&routing_info);
1022 1020
1023 // This works only because all routing info types are GROUP_PASSIVE. 1021 // This works only because all routing info types are GROUP_PASSIVE.
1024 // If we had types in other groups, we would need additional workers 1022 // If we had types in other groups, we would need additional workers
1025 // to support them. 1023 // to support them.
1026 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(GROUP_PASSIVE); 1024 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(GROUP_PASSIVE);
1027 workers.push_back(worker); 1025 workers.push_back(worker);
1028 1026
1029 SyncManager::InitArgs args; 1027 SyncManager::InitArgs args;
1030 args.database_location = temp_dir_.GetPath(); 1028 args.database_location = temp_dir_.GetPath();
1031 args.service_url = GURL("https://example.com/"); 1029 args.service_url = GURL("https://example.com/");
(...skipping 13 matching lines...) Expand all
1045 MakeWeakHandle(mock_unrecoverable_error_handler_.GetWeakPtr()); 1043 MakeWeakHandle(mock_unrecoverable_error_handler_.GetWeakPtr());
1046 args.cancelation_signal = &cancelation_signal_; 1044 args.cancelation_signal = &cancelation_signal_;
1047 sync_manager_.Init(&args); 1045 sync_manager_.Init(&args);
1048 1046
1049 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_); 1047 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_);
1050 1048
1051 EXPECT_TRUE(js_backend_.IsInitialized()); 1049 EXPECT_TRUE(js_backend_.IsInitialized());
1052 EXPECT_EQ(EngineComponentsFactory::STORAGE_ON_DISK, storage_used_); 1050 EXPECT_EQ(EngineComponentsFactory::STORAGE_ON_DISK, storage_used_);
1053 1051
1054 if (initialization_succeeded_) { 1052 if (initialization_succeeded_) {
1055 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 1053 ModelTypeSet enabled_types = GetEnabledTypes();
1056 i != routing_info.end(); ++i) { 1054 for (auto it = enabled_types.First(); it.Good(); it.Inc()) {
1057 type_roots_[i->first] = 1055 type_roots_[it.Get()] =
1058 MakeTypeRoot(sync_manager_.GetUserShare(), i->first); 1056 MakeTypeRoot(sync_manager_.GetUserShare(), it.Get());
1059 } 1057 }
1060 } 1058 }
1061 1059
1062 PumpLoop(); 1060 PumpLoop();
1063 } 1061 }
1064 1062
1065 // Test implementation. 1063 // Test implementation.
1066 void SetUp() { DoSetUp(false); } 1064 void SetUp() { DoSetUp(false); }
1067 1065
1068 void TearDown() { 1066 void TearDown() {
1069 sync_manager_.RemoveObserver(&manager_observer_); 1067 sync_manager_.RemoveObserver(&manager_observer_);
1070 sync_manager_.ShutdownOnSyncThread(STOP_SYNC); 1068 sync_manager_.ShutdownOnSyncThread(STOP_SYNC);
1071 PumpLoop(); 1069 PumpLoop();
1072 } 1070 }
1073 1071
1074 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { 1072 ModelTypeSet GetEnabledTypes() {
1075 (*out)[NIGORI] = GROUP_PASSIVE; 1073 ModelTypeSet enabled_types;
1076 (*out)[DEVICE_INFO] = GROUP_PASSIVE; 1074 enabled_types.Put(NIGORI);
1077 (*out)[EXPERIMENTS] = GROUP_PASSIVE; 1075 enabled_types.Put(DEVICE_INFO);
1078 (*out)[BOOKMARKS] = GROUP_PASSIVE; 1076 enabled_types.Put(EXPERIMENTS);
1079 (*out)[THEMES] = GROUP_PASSIVE; 1077 enabled_types.Put(BOOKMARKS);
1080 (*out)[SESSIONS] = GROUP_PASSIVE; 1078 enabled_types.Put(THEMES);
1081 (*out)[PASSWORDS] = GROUP_PASSIVE; 1079 enabled_types.Put(SESSIONS);
1082 (*out)[PREFERENCES] = GROUP_PASSIVE; 1080 enabled_types.Put(PASSWORDS);
1083 (*out)[PRIORITY_PREFERENCES] = GROUP_PASSIVE; 1081 enabled_types.Put(PREFERENCES);
1084 (*out)[ARTICLES] = GROUP_PASSIVE; 1082 enabled_types.Put(PRIORITY_PREFERENCES);
1085 } 1083 enabled_types.Put(ARTICLES);
1086 1084
1087 ModelTypeSet GetEnabledTypes() { 1085 return enabled_types;
1088 ModelSafeRoutingInfo routing_info;
1089 GetModelSafeRoutingInfo(&routing_info);
1090 return GetRoutingInfoTypes(routing_info);
1091 } 1086 }
1092 1087
1093 void OnChangesApplied(ModelType model_type, 1088 void OnChangesApplied(ModelType model_type,
1094 int64_t model_version, 1089 int64_t model_version,
1095 const BaseTransaction* trans, 1090 const BaseTransaction* trans,
1096 const ImmutableChangeRecordList& changes) override {} 1091 const ImmutableChangeRecordList& changes) override {}
1097 1092
1098 void OnChangesComplete(ModelType model_type) override {} 1093 void OnChangesComplete(ModelType model_type) override {}
1099 1094
1100 // Helper methods. 1095 // Helper methods.
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 const syncable::Entry* node_entry = node.GetEntry(); 2651 const syncable::Entry* node_entry = node.GetEntry();
2657 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName()); 2652 EXPECT_EQ(kEncryptedString, node_entry->GetNonUniqueName());
2658 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics(); 2653 const sync_pb::EntitySpecifics& specifics = node_entry->GetSpecifics();
2659 EXPECT_TRUE(specifics.has_encrypted()); 2654 EXPECT_TRUE(specifics.has_encrypted());
2660 } 2655 }
2661 } 2656 }
2662 2657
2663 // Verify transaction version of a model type is incremented when node of 2658 // Verify transaction version of a model type is incremented when node of
2664 // that type is updated. 2659 // that type is updated.
2665 TEST_F(SyncManagerTest, IncrementTransactionVersion) { 2660 TEST_F(SyncManagerTest, IncrementTransactionVersion) {
2666 ModelSafeRoutingInfo routing_info;
2667 GetModelSafeRoutingInfo(&routing_info);
2668
2669 { 2661 {
2670 ReadTransaction read_trans(FROM_HERE, sync_manager_.GetUserShare()); 2662 ReadTransaction read_trans(FROM_HERE, sync_manager_.GetUserShare());
2671 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 2663 ModelTypeSet enabled_types = GetEnabledTypes();
2672 i != routing_info.end(); ++i) { 2664 for (auto it = enabled_types.First(); it.Good(); it.Inc()) {
2673 // Transaction version is incremented when SyncManagerTest::SetUp() 2665 // Transaction version is incremented when SyncManagerTest::SetUp()
2674 // creates a node of each type. 2666 // creates a node of each type.
2675 EXPECT_EQ(1, 2667 EXPECT_EQ(1,
2676 sync_manager_.GetUserShare()->directory->GetTransactionVersion( 2668 sync_manager_.GetUserShare()->directory->GetTransactionVersion(
2677 i->first)); 2669 it.Get()));
2678 } 2670 }
2679 } 2671 }
2680 2672
2681 // Create bookmark node to increment transaction version of bookmark model. 2673 // Create bookmark node to increment transaction version of bookmark model.
2682 std::string client_tag = "title"; 2674 std::string client_tag = "title";
2683 sync_pb::EntitySpecifics entity_specifics; 2675 sync_pb::EntitySpecifics entity_specifics;
2684 entity_specifics.mutable_bookmark()->set_url("url"); 2676 entity_specifics.mutable_bookmark()->set_url("url");
2685 entity_specifics.mutable_bookmark()->set_title("title"); 2677 entity_specifics.mutable_bookmark()->set_title("title");
2686 MakeServerNode(sync_manager_.GetUserShare(), BOOKMARKS, client_tag, 2678 MakeServerNode(sync_manager_.GetUserShare(), BOOKMARKS, client_tag,
2687 GenerateSyncableHash(BOOKMARKS, client_tag), entity_specifics); 2679 GenerateSyncableHash(BOOKMARKS, client_tag), entity_specifics);
2688 2680
2689 { 2681 {
2690 ReadTransaction read_trans(FROM_HERE, sync_manager_.GetUserShare()); 2682 ReadTransaction read_trans(FROM_HERE, sync_manager_.GetUserShare());
2691 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 2683 ModelTypeSet enabled_types = GetEnabledTypes();
2692 i != routing_info.end(); ++i) { 2684 for (auto it = enabled_types.First(); it.Good(); it.Inc()) {
2693 EXPECT_EQ(i->first == BOOKMARKS ? 2 : 1, 2685 EXPECT_EQ(it.Get() == BOOKMARKS ? 2 : 1,
2694 sync_manager_.GetUserShare()->directory->GetTransactionVersion( 2686 sync_manager_.GetUserShare()->directory->GetTransactionVersion(
2695 i->first)); 2687 it.Get()));
2696 } 2688 }
2697 } 2689 }
2698 } 2690 }
2699 2691
2700 class SyncManagerWithLocalBackendTest : public SyncManagerTest { 2692 class SyncManagerWithLocalBackendTest : public SyncManagerTest {
2701 protected: 2693 protected:
2702 void SetUp() override { DoSetUp(true); } 2694 void SetUp() override { DoSetUp(true); }
2703 }; 2695 };
2704 2696
2705 // This test checks that we can successfully initialize without credentials in 2697 // This test checks that we can successfully initialize without credentials in
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 2768
2777 MockSyncScheduler* scheduler() { return scheduler_; } 2769 MockSyncScheduler* scheduler() { return scheduler_; }
2778 SyncCycleContext* cycle_context() { return cycle_context_; } 2770 SyncCycleContext* cycle_context() { return cycle_context_; }
2779 2771
2780 private: 2772 private:
2781 MockSyncScheduler* scheduler_; 2773 MockSyncScheduler* scheduler_;
2782 SyncCycleContext* cycle_context_; 2774 SyncCycleContext* cycle_context_;
2783 }; 2775 };
2784 2776
2785 // Test that the configuration params are properly created and sent to 2777 // Test that the configuration params are properly created and sent to
2786 // ScheduleConfigure. No callback should be invoked. Any disabled datatypes 2778 // ScheduleConfigure. No callback should be invoked.
2787 // should be purged.
2788 TEST_F(SyncManagerTestWithMockScheduler, BasicConfiguration) { 2779 TEST_F(SyncManagerTestWithMockScheduler, BasicConfiguration) {
2789 ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION; 2780 ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION;
2790 ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES); 2781 ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES);
2791 ModelSafeRoutingInfo new_routing_info;
2792 GetModelSafeRoutingInfo(&new_routing_info);
2793 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info);
2794 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types);
2795 2782
2796 ConfigurationParams params; 2783 ConfigurationParams params;
2797 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE, _)); 2784 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE, _));
2798 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_)) 2785 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_))
2799 .WillOnce(SaveArg<0>(&params)); 2786 .WillOnce(SaveArg<0>(&params));
2800 2787
2801 // Set data for all types.
2802 ModelTypeSet protocol_types = ProtocolTypes();
2803 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
2804 iter.Inc()) {
2805 SetProgressMarkerForType(iter.Get(), true);
2806 }
2807
2808 sync_manager_.PurgeDisabledTypes(disabled_types, ModelTypeSet(),
2809 ModelTypeSet());
2810 CallbackCounter ready_task_counter, retry_task_counter; 2788 CallbackCounter ready_task_counter, retry_task_counter;
2811 sync_manager_.ConfigureSyncer( 2789 sync_manager_.ConfigureSyncer(
2812 reason, types_to_download, new_routing_info, 2790 reason, types_to_download,
2813 base::Bind(&CallbackCounter::Callback, 2791 base::Bind(&CallbackCounter::Callback,
2814 base::Unretained(&ready_task_counter)), 2792 base::Unretained(&ready_task_counter)),
2815 base::Bind(&CallbackCounter::Callback, 2793 base::Bind(&CallbackCounter::Callback,
2816 base::Unretained(&retry_task_counter))); 2794 base::Unretained(&retry_task_counter)));
2817 EXPECT_EQ(0, ready_task_counter.times_called()); 2795 EXPECT_EQ(0, ready_task_counter.times_called());
2818 EXPECT_EQ(0, retry_task_counter.times_called()); 2796 EXPECT_EQ(0, retry_task_counter.times_called());
2819 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, params.source); 2797 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, params.source);
2820 EXPECT_EQ(types_to_download, params.types_to_download); 2798 EXPECT_EQ(types_to_download, params.types_to_download);
2821 EXPECT_EQ(new_routing_info, params.routing_info); 2799 }
2822 2800
2801 // Test that PurgeDisabledTypes only purges recently disabled types leaving
2802 // others intact.
2803 TEST_F(SyncManagerTestWithMockScheduler, PurgeDisabledTypes) {
2804 ModelTypeSet enabled_types = GetEnabledTypes();
2805 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types);
2806 // Set data for all types.
2807 ModelTypeSet protocol_types = ProtocolTypes();
2808 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
2809 iter.Inc()) {
2810 SetProgressMarkerForType(iter.Get(), true);
2811 }
2812
2813 sync_manager_.PurgeDisabledTypes(disabled_types, ModelTypeSet(),
2814 ModelTypeSet());
2823 // Verify all the disabled types were purged. 2815 // Verify all the disabled types were purged.
2824 EXPECT_EQ(enabled_types, 2816 EXPECT_EQ(enabled_types,
2825 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes()); 2817 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes());
2826 EXPECT_EQ(disabled_types, sync_manager_.GetTypesWithEmptyProgressMarkerToken( 2818 EXPECT_EQ(disabled_types, sync_manager_.GetTypesWithEmptyProgressMarkerToken(
2827 ModelTypeSet::All())); 2819 ModelTypeSet::All()));
2828 } 2820 }
2829 2821
2830 // Test that on a reconfiguration (configuration where the session context
2831 // already has routing info), only those recently disabled types are purged.
2832 TEST_F(SyncManagerTestWithMockScheduler, ReConfiguration) {
2833 ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION;
2834 ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES);
2835 ModelTypeSet disabled_types = ModelTypeSet(THEMES, SESSIONS);
2836 ModelSafeRoutingInfo old_routing_info;
2837 ModelSafeRoutingInfo new_routing_info;
2838 GetModelSafeRoutingInfo(&old_routing_info);
2839 new_routing_info = old_routing_info;
2840 new_routing_info.erase(THEMES);
2841 new_routing_info.erase(SESSIONS);
2842 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info);
2843
2844 ConfigurationParams params;
2845 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE, _));
2846 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_))
2847 .WillOnce(SaveArg<0>(&params));
2848
2849 // Set data for all types except those recently disabled (so we can verify
2850 // only those recently disabled are purged) .
2851 ModelTypeSet protocol_types = ProtocolTypes();
2852 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
2853 iter.Inc()) {
2854 if (!disabled_types.Has(iter.Get())) {
2855 SetProgressMarkerForType(iter.Get(), true);
2856 } else {
2857 SetProgressMarkerForType(iter.Get(), false);
2858 }
2859 }
2860
2861 // Set the context to have the old routing info.
2862 cycle_context()->SetRoutingInfo(old_routing_info);
2863
2864 CallbackCounter ready_task_counter, retry_task_counter;
2865 sync_manager_.PurgeDisabledTypes(ModelTypeSet(), ModelTypeSet(),
2866 ModelTypeSet());
2867 sync_manager_.ConfigureSyncer(
2868 reason, types_to_download, new_routing_info,
2869 base::Bind(&CallbackCounter::Callback,
2870 base::Unretained(&ready_task_counter)),
2871 base::Bind(&CallbackCounter::Callback,
2872 base::Unretained(&retry_task_counter)));
2873 EXPECT_EQ(0, ready_task_counter.times_called());
2874 EXPECT_EQ(0, retry_task_counter.times_called());
2875 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, params.source);
2876 EXPECT_EQ(types_to_download, params.types_to_download);
2877 EXPECT_EQ(new_routing_info, params.routing_info);
2878
2879 // Verify only the recently disabled types were purged.
2880 EXPECT_EQ(disabled_types, sync_manager_.GetTypesWithEmptyProgressMarkerToken(
2881 ProtocolTypes()));
2882 }
2883
2884 // Test that SyncManager::ClearServerData invokes the scheduler. 2822 // Test that SyncManager::ClearServerData invokes the scheduler.
2885 TEST_F(SyncManagerTestWithMockScheduler, ClearServerData) { 2823 TEST_F(SyncManagerTestWithMockScheduler, ClearServerData) {
2886 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, _)); 2824 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, _));
2887 CallbackCounter callback_counter; 2825 CallbackCounter callback_counter;
2888 sync_manager_.ClearServerData(base::Bind( 2826 sync_manager_.ClearServerData(base::Bind(
2889 &CallbackCounter::Callback, base::Unretained(&callback_counter))); 2827 &CallbackCounter::Callback, base::Unretained(&callback_counter)));
2890 PumpLoop(); 2828 PumpLoop();
2891 EXPECT_EQ(1, callback_counter.times_called()); 2829 EXPECT_EQ(1, callback_counter.times_called());
2892 } 2830 }
2893 2831
2894 // Test that PurgePartiallySyncedTypes purges only those types that have not 2832 // Test that PurgePartiallySyncedTypes purges only those types that have not
2895 // fully completed their initial download and apply. 2833 // fully completed their initial download and apply.
2896 TEST_F(SyncManagerTest, PurgePartiallySyncedTypes) { 2834 TEST_F(SyncManagerTest, PurgePartiallySyncedTypes) {
2897 ModelSafeRoutingInfo routing_info; 2835 ModelTypeSet enabled_types = GetEnabledTypes();
2898 GetModelSafeRoutingInfo(&routing_info);
2899 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
2900 2836
2901 UserShare* share = sync_manager_.GetUserShare(); 2837 UserShare* share = sync_manager_.GetUserShare();
2902 2838
2903 // The test harness automatically initializes all types in the routing info. 2839 // The test harness automatically initializes all types in the routing info.
2904 // Check that autofill is not among them. 2840 // Check that autofill is not among them.
2905 ASSERT_FALSE(enabled_types.Has(AUTOFILL)); 2841 ASSERT_FALSE(enabled_types.Has(AUTOFILL));
2906 2842
2907 // Further ensure that the test harness did not create its root node. 2843 // Further ensure that the test harness did not create its root node.
2908 { 2844 {
2909 syncable::ReadTransaction trans(FROM_HERE, share->directory.get()); 2845 syncable::ReadTransaction trans(FROM_HERE, share->directory.get());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2964 syncable::Entry autofill_node(&trans, GET_BY_HANDLE, autofill_meta); 2900 syncable::Entry autofill_node(&trans, GET_BY_HANDLE, autofill_meta);
2965 syncable::Entry pref_node(&trans, GET_BY_HANDLE, pref_meta); 2901 syncable::Entry pref_node(&trans, GET_BY_HANDLE, pref_meta);
2966 EXPECT_FALSE(autofill_node.good()); 2902 EXPECT_FALSE(autofill_node.good());
2967 EXPECT_TRUE(pref_node.good()); 2903 EXPECT_TRUE(pref_node.good());
2968 } 2904 }
2969 } 2905 }
2970 2906
2971 // Test CleanupDisabledTypes properly purges all disabled types as specified 2907 // Test CleanupDisabledTypes properly purges all disabled types as specified
2972 // by the previous and current enabled params. 2908 // by the previous and current enabled params.
2973 TEST_F(SyncManagerTest, PurgeDisabledTypes) { 2909 TEST_F(SyncManagerTest, PurgeDisabledTypes) {
2974 ModelSafeRoutingInfo routing_info; 2910 ModelTypeSet enabled_types = GetEnabledTypes();
2975 GetModelSafeRoutingInfo(&routing_info);
2976 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
2977 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); 2911 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types);
2978 2912
2979 // The harness should have initialized the enabled_types for us. 2913 // The harness should have initialized the enabled_types for us.
2980 EXPECT_EQ(enabled_types, 2914 EXPECT_EQ(enabled_types,
2981 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes()); 2915 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes());
2982 2916
2983 // Set progress markers for all types. 2917 // Set progress markers for all types.
2984 ModelTypeSet protocol_types = ProtocolTypes(); 2918 ModelTypeSet protocol_types = ProtocolTypes();
2985 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good(); 2919 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
2986 iter.Inc()) { 2920 iter.Inc()) {
(...skipping 20 matching lines...) Expand all
3007 ModelTypeSet()); 2941 ModelTypeSet());
3008 EXPECT_EQ(new_enabled_types, 2942 EXPECT_EQ(new_enabled_types,
3009 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes()); 2943 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes());
3010 EXPECT_EQ(disabled_types, sync_manager_.GetTypesWithEmptyProgressMarkerToken( 2944 EXPECT_EQ(disabled_types, sync_manager_.GetTypesWithEmptyProgressMarkerToken(
3011 ModelTypeSet::All())); 2945 ModelTypeSet::All()));
3012 } 2946 }
3013 2947
3014 // Test PurgeDisabledTypes properly unapplies types by deleting their local data 2948 // Test PurgeDisabledTypes properly unapplies types by deleting their local data
3015 // and preserving their server data and progress marker. 2949 // and preserving their server data and progress marker.
3016 TEST_F(SyncManagerTest, PurgeUnappliedTypes) { 2950 TEST_F(SyncManagerTest, PurgeUnappliedTypes) {
3017 ModelSafeRoutingInfo routing_info;
3018 GetModelSafeRoutingInfo(&routing_info);
3019 ModelTypeSet unapplied_types = ModelTypeSet(BOOKMARKS, PREFERENCES); 2951 ModelTypeSet unapplied_types = ModelTypeSet(BOOKMARKS, PREFERENCES);
3020 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info); 2952 ModelTypeSet enabled_types = GetEnabledTypes();
3021 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); 2953 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types);
3022 2954
3023 // The harness should have initialized the enabled_types for us. 2955 // The harness should have initialized the enabled_types for us.
3024 EXPECT_EQ(enabled_types, 2956 EXPECT_EQ(enabled_types,
3025 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes()); 2957 sync_manager_.GetUserShare()->directory->InitialSyncEndedTypes());
3026 2958
3027 // Set progress markers for all types. 2959 // Set progress markers for all types.
3028 ModelTypeSet protocol_types = ProtocolTypes(); 2960 ModelTypeSet protocol_types = ProtocolTypes();
3029 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good(); 2961 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
3030 iter.Inc()) { 2962 iter.Inc()) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 // SyncManagerInitInvalidStorageTest::GetFactory will return 3484 // SyncManagerInitInvalidStorageTest::GetFactory will return
3553 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3485 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3554 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3486 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3555 // task is to ensure that SyncManagerImpl reported initialization failure in 3487 // task is to ensure that SyncManagerImpl reported initialization failure in
3556 // OnInitializationComplete callback. 3488 // OnInitializationComplete callback.
3557 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3489 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3558 EXPECT_FALSE(initialization_succeeded_); 3490 EXPECT_FALSE(initialization_succeeded_);
3559 } 3491 }
3560 3492
3561 } // namespace syncer 3493 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/sync_manager_impl.cc ('k') | components/sync/engine_impl/sync_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698