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

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

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