OLD | NEW |
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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2797 } | 2797 } |
2798 | 2798 |
2799 private: | 2799 private: |
2800 MockSyncScheduler* scheduler_; | 2800 MockSyncScheduler* scheduler_; |
2801 sessions::SyncSessionContext* session_context_; | 2801 sessions::SyncSessionContext* session_context_; |
2802 }; | 2802 }; |
2803 | 2803 |
2804 // Test that the configuration params are properly created and sent to | 2804 // Test that the configuration params are properly created and sent to |
2805 // ScheduleConfigure. No callback should be invoked. Any disabled datatypes | 2805 // ScheduleConfigure. No callback should be invoked. Any disabled datatypes |
2806 // should be purged. | 2806 // should be purged. |
2807 // Fails on Windows: crbug.com/139726 | 2807 TEST_F(SyncManagerTestWithMockScheduler, BasicConfiguration) { |
2808 #if defined(OS_WIN) | |
2809 #define MAYBE_BasicConfiguration DISABLED_BasicConfiguration | |
2810 #else | |
2811 #define MAYBE_BasicConfiguration BasicConfiguration | |
2812 #endif | |
2813 TEST_F(SyncManagerTestWithMockScheduler, MAYBE_BasicConfiguration) { | |
2814 ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION; | 2808 ConfigureReason reason = CONFIGURE_REASON_RECONFIGURATION; |
2815 ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES); | 2809 ModelTypeSet types_to_download(BOOKMARKS, PREFERENCES); |
2816 ModelSafeRoutingInfo new_routing_info; | 2810 ModelSafeRoutingInfo new_routing_info; |
2817 GetModelSafeRoutingInfo(&new_routing_info); | 2811 GetModelSafeRoutingInfo(&new_routing_info); |
2818 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); | 2812 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); |
2819 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); | 2813 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); |
2820 | 2814 |
2821 ConfigurationParams params; | 2815 ConfigurationParams params; |
2822 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE)); | 2816 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE)); |
2823 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_)). | 2817 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_)). |
2824 WillOnce(DoAll(SaveArg<0>(¶ms), Return(true))); | 2818 WillOnce(DoAll(SaveArg<0>(¶ms), Return(true))); |
2825 | 2819 |
2826 // Set data for all types. | 2820 // Set data for all types. |
2827 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); | 2821 ModelTypeSet real_types = ModelTypeSet::All(); |
| 2822 real_types.RemoveAll(VirtualTypes()); |
| 2823 for (ModelTypeSet::Iterator iter = real_types.First(); iter.Good(); |
2828 iter.Inc()) { | 2824 iter.Inc()) { |
2829 SetProgressMarkerForType(iter.Get(), true); | 2825 SetProgressMarkerForType(iter.Get(), true); |
2830 } | 2826 } |
2831 | 2827 |
2832 CallbackCounter ready_task_counter, retry_task_counter; | 2828 CallbackCounter ready_task_counter, retry_task_counter; |
2833 sync_manager_.ConfigureSyncer( | 2829 sync_manager_.ConfigureSyncer( |
2834 reason, | 2830 reason, |
2835 types_to_download, | 2831 types_to_download, |
2836 new_routing_info, | 2832 new_routing_info, |
2837 base::Bind(&CallbackCounter::Callback, | 2833 base::Bind(&CallbackCounter::Callback, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 syncable::ReadTransaction trans(FROM_HERE, share->directory.get()); | 2999 syncable::ReadTransaction trans(FROM_HERE, share->directory.get()); |
3004 syncable::Entry autofill_node(&trans, GET_BY_HANDLE, autofill_meta); | 3000 syncable::Entry autofill_node(&trans, GET_BY_HANDLE, autofill_meta); |
3005 syncable::Entry pref_node(&trans, GET_BY_HANDLE, pref_meta); | 3001 syncable::Entry pref_node(&trans, GET_BY_HANDLE, pref_meta); |
3006 EXPECT_FALSE(autofill_node.good()); | 3002 EXPECT_FALSE(autofill_node.good()); |
3007 EXPECT_TRUE(pref_node.good()); | 3003 EXPECT_TRUE(pref_node.good()); |
3008 } | 3004 } |
3009 } | 3005 } |
3010 | 3006 |
3011 // Test CleanupDisabledTypes properly purges all disabled types as specified | 3007 // Test CleanupDisabledTypes properly purges all disabled types as specified |
3012 // by the previous and current enabled params. | 3008 // by the previous and current enabled params. |
3013 // Fails on Windows: crbug.com/139726 | 3009 TEST_F(SyncManagerTest, PurgeDisabledTypes) { |
3014 #if defined(OS_WIN) | |
3015 #define MAYBE_PurgeDisabledTypes DISABLED_PurgeDisabledTypes | |
3016 #else | |
3017 #define MAYBE_PurgeDisabledTypes PurgeDisabledTypes | |
3018 #endif | |
3019 TEST_F(SyncManagerTest, MAYBE_PurgeDisabledTypes) { | |
3020 ModelSafeRoutingInfo routing_info; | 3010 ModelSafeRoutingInfo routing_info; |
3021 GetModelSafeRoutingInfo(&routing_info); | 3011 GetModelSafeRoutingInfo(&routing_info); |
3022 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info); | 3012 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info); |
3023 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); | 3013 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); |
3024 | 3014 |
3025 // The harness should have initialized the enabled_types for us. | 3015 // The harness should have initialized the enabled_types for us. |
3026 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3016 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3027 | 3017 |
3028 // Set progress markers for all types. | 3018 // Set progress markers for all types. |
3029 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); | 3019 ModelTypeSet real_types = ModelTypeSet::All(); |
| 3020 real_types.RemoveAll(VirtualTypes()); |
| 3021 for (ModelTypeSet::Iterator iter = real_types.First(); iter.Good(); |
3030 iter.Inc()) { | 3022 iter.Inc()) { |
3031 SetProgressMarkerForType(iter.Get(), true); | 3023 SetProgressMarkerForType(iter.Get(), true); |
3032 } | 3024 } |
3033 | 3025 |
3034 // Verify all the enabled types remain after cleanup, and all the disabled | 3026 // Verify all the enabled types remain after cleanup, and all the disabled |
3035 // types were purged. | 3027 // types were purged. |
3036 sync_manager_.PurgeDisabledTypes(ModelTypeSet::All(), enabled_types); | 3028 sync_manager_.PurgeDisabledTypes(ModelTypeSet::All(), enabled_types); |
3037 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3029 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3038 EXPECT_TRUE(disabled_types.Equals( | 3030 EXPECT_TRUE(disabled_types.Equals( |
3039 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 3031 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
3040 | 3032 |
3041 // Disable some more types. | 3033 // Disable some more types. |
3042 disabled_types.Put(BOOKMARKS); | 3034 disabled_types.Put(BOOKMARKS); |
3043 disabled_types.Put(PREFERENCES); | 3035 disabled_types.Put(PREFERENCES); |
3044 ModelTypeSet new_enabled_types = | 3036 ModelTypeSet new_enabled_types = |
3045 Difference(ModelTypeSet::All(), disabled_types); | 3037 Difference(ModelTypeSet::All(), disabled_types); |
3046 | 3038 |
3047 // Verify only the non-disabled types remain after cleanup. | 3039 // Verify only the non-disabled types remain after cleanup. |
3048 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); | 3040 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); |
3049 EXPECT_TRUE(new_enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3041 EXPECT_TRUE(new_enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3050 EXPECT_TRUE(disabled_types.Equals( | 3042 EXPECT_TRUE(disabled_types.Equals( |
3051 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 3043 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
3052 } | 3044 } |
3053 | 3045 |
3054 } // namespace | 3046 } // namespace |
OLD | NEW |