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 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2819 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); | 2819 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); |
2820 | 2820 |
2821 ConfigurationParams params; | 2821 ConfigurationParams params; |
2822 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE)); | 2822 EXPECT_CALL(*scheduler(), Start(SyncScheduler::CONFIGURATION_MODE)); |
2823 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_)). | 2823 EXPECT_CALL(*scheduler(), ScheduleConfiguration(_)). |
2824 WillOnce(DoAll(SaveArg<0>(¶ms), Return(true))); | 2824 WillOnce(DoAll(SaveArg<0>(¶ms), Return(true))); |
2825 | 2825 |
2826 // Set data for all types. | 2826 // Set data for all types. |
2827 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); | 2827 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); |
2828 iter.Inc()) { | 2828 iter.Inc()) { |
| 2829 if (LocalTypes().Has(iter.Get())) |
| 2830 continue; |
2829 SetProgressMarkerForType(iter.Get(), true); | 2831 SetProgressMarkerForType(iter.Get(), true); |
2830 } | 2832 } |
2831 | 2833 |
2832 CallbackCounter ready_task_counter, retry_task_counter; | 2834 CallbackCounter ready_task_counter, retry_task_counter; |
2833 sync_manager_.ConfigureSyncer( | 2835 sync_manager_.ConfigureSyncer( |
2834 reason, | 2836 reason, |
2835 types_to_download, | 2837 types_to_download, |
2836 new_routing_info, | 2838 new_routing_info, |
2837 base::Bind(&CallbackCounter::Callback, | 2839 base::Bind(&CallbackCounter::Callback, |
2838 base::Unretained(&ready_task_counter)), | 2840 base::Unretained(&ready_task_counter)), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3021 GetModelSafeRoutingInfo(&routing_info); | 3023 GetModelSafeRoutingInfo(&routing_info); |
3022 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info); | 3024 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info); |
3023 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); | 3025 ModelTypeSet disabled_types = Difference(ModelTypeSet::All(), enabled_types); |
3024 | 3026 |
3025 // The harness should have initialized the enabled_types for us. | 3027 // The harness should have initialized the enabled_types for us. |
3026 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3028 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3027 | 3029 |
3028 // Set progress markers for all types. | 3030 // Set progress markers for all types. |
3029 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); | 3031 for (ModelTypeSet::Iterator iter = ModelTypeSet::All().First(); iter.Good(); |
3030 iter.Inc()) { | 3032 iter.Inc()) { |
| 3033 if (LocalTypes().Has(iter.Get())) |
| 3034 continue; |
3031 SetProgressMarkerForType(iter.Get(), true); | 3035 SetProgressMarkerForType(iter.Get(), true); |
3032 } | 3036 } |
3033 | 3037 |
3034 // Verify all the enabled types remain after cleanup, and all the disabled | 3038 // Verify all the enabled types remain after cleanup, and all the disabled |
3035 // types were purged. | 3039 // types were purged. |
3036 sync_manager_.PurgeDisabledTypes(ModelTypeSet::All(), enabled_types); | 3040 sync_manager_.PurgeDisabledTypes(ModelTypeSet::All(), enabled_types); |
3037 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3041 EXPECT_TRUE(enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3038 EXPECT_TRUE(disabled_types.Equals( | 3042 EXPECT_TRUE(disabled_types.Equals( |
3039 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 3043 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
3040 | 3044 |
3041 // Disable some more types. | 3045 // Disable some more types. |
3042 disabled_types.Put(BOOKMARKS); | 3046 disabled_types.Put(BOOKMARKS); |
3043 disabled_types.Put(PREFERENCES); | 3047 disabled_types.Put(PREFERENCES); |
3044 ModelTypeSet new_enabled_types = | 3048 ModelTypeSet new_enabled_types = |
3045 Difference(ModelTypeSet::All(), disabled_types); | 3049 Difference(ModelTypeSet::All(), disabled_types); |
3046 | 3050 |
3047 // Verify only the non-disabled types remain after cleanup. | 3051 // Verify only the non-disabled types remain after cleanup. |
3048 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); | 3052 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); |
3049 EXPECT_TRUE(new_enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); | 3053 EXPECT_TRUE(new_enabled_types.Equals(sync_manager_.InitialSyncEndedTypes())); |
3050 EXPECT_TRUE(disabled_types.Equals( | 3054 EXPECT_TRUE(disabled_types.Equals( |
3051 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); | 3055 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); |
3052 } | 3056 } |
3053 | 3057 |
3054 } // namespace | 3058 } // namespace |
OLD | NEW |