OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_driver/sync_prefs.h" | 5 #include "components/sync/driver/sync_prefs.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "components/pref_registry/testing_pref_service_syncable.h" | 14 #include "components/pref_registry/testing_pref_service_syncable.h" |
15 #include "components/prefs/pref_notifier_impl.h" | 15 #include "components/prefs/pref_notifier_impl.h" |
16 #include "components/prefs/pref_value_store.h" | 16 #include "components/prefs/pref_value_store.h" |
17 #include "components/prefs/testing_pref_service.h" | 17 #include "components/prefs/testing_pref_service.h" |
18 #include "components/sync/base/model_type.h" | 18 #include "components/sync/base/model_type.h" |
19 #include "components/sync_driver/pref_names.h" | 19 #include "components/sync/driver/pref_names.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace sync_driver { | 23 namespace sync_driver { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 using ::testing::InSequence; | 27 using ::testing::InSequence; |
28 using ::testing::StrictMock; | 28 using ::testing::StrictMock; |
29 | 29 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 TEST_F(SyncPrefsTest, PreferredTypesKeepEverythingSynced) { | 112 TEST_F(SyncPrefsTest, PreferredTypesKeepEverythingSynced) { |
113 SyncPrefs sync_prefs(&pref_service_); | 113 SyncPrefs sync_prefs(&pref_service_); |
114 | 114 |
115 EXPECT_TRUE(sync_prefs.HasKeepEverythingSynced()); | 115 EXPECT_TRUE(sync_prefs.HasKeepEverythingSynced()); |
116 | 116 |
117 const syncer::ModelTypeSet user_types = syncer::UserTypes(); | 117 const syncer::ModelTypeSet user_types = syncer::UserTypes(); |
118 EXPECT_EQ(user_types, sync_prefs.GetPreferredDataTypes(user_types)); | 118 EXPECT_EQ(user_types, sync_prefs.GetPreferredDataTypes(user_types)); |
119 const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); | 119 const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); |
120 for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); | 120 for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); |
121 it.Good(); | 121 it.Good(); it.Inc()) { |
122 it.Inc()) { | |
123 syncer::ModelTypeSet preferred_types; | 122 syncer::ModelTypeSet preferred_types; |
124 preferred_types.Put(it.Get()); | 123 preferred_types.Put(it.Get()); |
125 sync_prefs.SetPreferredDataTypes(user_types, preferred_types); | 124 sync_prefs.SetPreferredDataTypes(user_types, preferred_types); |
126 EXPECT_EQ(user_types, sync_prefs.GetPreferredDataTypes(user_types)); | 125 EXPECT_EQ(user_types, sync_prefs.GetPreferredDataTypes(user_types)); |
127 } | 126 } |
128 } | 127 } |
129 | 128 |
130 TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) { | 129 TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) { |
131 SyncPrefs sync_prefs(&pref_service_); | 130 SyncPrefs sync_prefs(&pref_service_); |
132 | 131 |
133 sync_prefs.SetKeepEverythingSynced(false); | 132 sync_prefs.SetKeepEverythingSynced(false); |
134 | 133 |
135 const syncer::ModelTypeSet user_types = syncer::UserTypes(); | 134 const syncer::ModelTypeSet user_types = syncer::UserTypes(); |
136 EXPECT_NE(user_types, sync_prefs.GetPreferredDataTypes(user_types)); | 135 EXPECT_NE(user_types, sync_prefs.GetPreferredDataTypes(user_types)); |
137 const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); | 136 const syncer::ModelTypeSet user_visible_types = syncer::UserSelectableTypes(); |
138 for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); | 137 for (syncer::ModelTypeSet::Iterator it = user_visible_types.First(); |
139 it.Good(); | 138 it.Good(); it.Inc()) { |
140 it.Inc()) { | |
141 syncer::ModelTypeSet preferred_types; | 139 syncer::ModelTypeSet preferred_types; |
142 preferred_types.Put(it.Get()); | 140 preferred_types.Put(it.Get()); |
143 syncer::ModelTypeSet expected_preferred_types(preferred_types); | 141 syncer::ModelTypeSet expected_preferred_types(preferred_types); |
144 if (it.Get() == syncer::AUTOFILL) { | 142 if (it.Get() == syncer::AUTOFILL) { |
145 expected_preferred_types.Put(syncer::AUTOFILL_PROFILE); | 143 expected_preferred_types.Put(syncer::AUTOFILL_PROFILE); |
146 expected_preferred_types.Put(syncer::AUTOFILL_WALLET_DATA); | 144 expected_preferred_types.Put(syncer::AUTOFILL_WALLET_DATA); |
147 expected_preferred_types.Put(syncer::AUTOFILL_WALLET_METADATA); | 145 expected_preferred_types.Put(syncer::AUTOFILL_WALLET_METADATA); |
148 } | 146 } |
149 if (it.Get() == syncer::PREFERENCES) { | 147 if (it.Get() == syncer::PREFERENCES) { |
150 expected_preferred_types.Put(syncer::DICTIONARY); | 148 expected_preferred_types.Put(syncer::DICTIONARY); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 253 |
256 EXPECT_EQ(versions.size(), versions2.size()); | 254 EXPECT_EQ(versions.size(), versions2.size()); |
257 for (auto map_iter : versions2) { | 255 for (auto map_iter : versions2) { |
258 EXPECT_EQ(versions[map_iter.first], map_iter.second); | 256 EXPECT_EQ(versions[map_iter.first], map_iter.second); |
259 } | 257 } |
260 } | 258 } |
261 | 259 |
262 } // namespace | 260 } // namespace |
263 | 261 |
264 } // namespace sync_driver | 262 } // namespace sync_driver |
OLD | NEW |