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 // Keep this file in sync with the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
6 | 6 |
7 #include "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const T& specifics(T::default_instance()); | 43 const T& specifics(T::default_instance()); |
44 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); | 44 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); |
45 // We can't do much but make sure that this doesn't crash. | 45 // We can't do much but make sure that this doesn't crash. |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 49 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
50 // If this number changes, that means we added or removed a data | 50 // If this number changes, that means we added or removed a data |
51 // type. Don't forget to add a unit test for {New | 51 // type. Don't forget to add a unit test for {New |
52 // type}SpecificsToValue below. | 52 // type}SpecificsToValue below. |
53 EXPECT_EQ(22, MODEL_TYPE_COUNT); | 53 EXPECT_EQ(23, MODEL_TYPE_COUNT); |
54 | 54 |
55 // We'd also like to check if we changed any field in our messages. | 55 // We'd also like to check if we changed any field in our messages. |
56 // However, that's hard to do: sizeof could work, but it's | 56 // However, that's hard to do: sizeof could work, but it's |
57 // platform-dependent. default_instance().ByteSize() won't change | 57 // platform-dependent. default_instance().ByteSize() won't change |
58 // for most changes, since most of our fields are optional. So we | 58 // for most changes, since most of our fields are optional. So we |
59 // just settle for comments in the proto files. | 59 // just settle for comments in the proto files. |
60 } | 60 } |
61 | 61 |
62 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 62 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
63 TestSpecificsToValue(EncryptedDataToValue); | 63 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { | 190 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { |
191 TestSpecificsToValue(ThemeSpecificsToValue); | 191 TestSpecificsToValue(ThemeSpecificsToValue); |
192 } | 192 } |
193 | 193 |
194 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { | 194 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { |
195 TestSpecificsToValue(TypedUrlSpecificsToValue); | 195 TestSpecificsToValue(TypedUrlSpecificsToValue); |
196 } | 196 } |
197 | 197 |
| 198 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) { |
| 199 TestSpecificsToValue(DictionarySpecificsToValue); |
| 200 } |
| 201 |
198 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. | 202 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. |
199 | 203 |
200 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { | 204 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { |
201 sync_pb::EntitySpecifics specifics; | 205 sync_pb::EntitySpecifics specifics; |
202 // Touch the extensions to make sure it shows up in the generated | 206 // Touch the extensions to make sure it shows up in the generated |
203 // value. | 207 // value. |
204 #define SET_FIELD(key) (void)specifics.mutable_##key() | 208 #define SET_FIELD(key) (void)specifics.mutable_##key() |
205 | 209 |
206 SET_FIELD(app); | 210 SET_FIELD(app); |
207 SET_FIELD(app_notification); | 211 SET_FIELD(app_notification); |
208 SET_FIELD(app_setting); | 212 SET_FIELD(app_setting); |
209 SET_FIELD(autofill); | 213 SET_FIELD(autofill); |
210 SET_FIELD(autofill_profile); | 214 SET_FIELD(autofill_profile); |
211 SET_FIELD(bookmark); | 215 SET_FIELD(bookmark); |
| 216 SET_FIELD(device_info); |
| 217 SET_FIELD(dictionary); |
212 SET_FIELD(experiments); | 218 SET_FIELD(experiments); |
213 SET_FIELD(extension); | 219 SET_FIELD(extension); |
214 SET_FIELD(extension_setting); | 220 SET_FIELD(extension_setting); |
215 SET_FIELD(history_delete_directive); | 221 SET_FIELD(history_delete_directive); |
216 SET_FIELD(nigori); | 222 SET_FIELD(nigori); |
217 SET_FIELD(password); | 223 SET_FIELD(password); |
218 SET_FIELD(device_info); | |
219 SET_FIELD(preference); | 224 SET_FIELD(preference); |
220 SET_FIELD(priority_preference); | 225 SET_FIELD(priority_preference); |
221 SET_FIELD(search_engine); | 226 SET_FIELD(search_engine); |
222 SET_FIELD(session); | 227 SET_FIELD(session); |
223 SET_FIELD(synced_notification); | 228 SET_FIELD(synced_notification); |
224 SET_FIELD(theme); | 229 SET_FIELD(theme); |
225 SET_FIELD(typed_url); | 230 SET_FIELD(typed_url); |
226 | 231 |
227 #undef SET_FIELD | 232 #undef SET_FIELD |
228 | 233 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 293 |
289 scoped_ptr<DictionaryValue> value_without_specifics( | 294 scoped_ptr<DictionaryValue> value_without_specifics( |
290 ClientToServerResponseToValue(message, false /* include_specifics */)); | 295 ClientToServerResponseToValue(message, false /* include_specifics */)); |
291 EXPECT_FALSE(value_without_specifics->empty()); | 296 EXPECT_FALSE(value_without_specifics->empty()); |
292 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 297 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
293 "get_updates.entries")); | 298 "get_updates.entries")); |
294 } | 299 } |
295 | 300 |
296 } // namespace | 301 } // namespace |
297 } // namespace syncer | 302 } // namespace syncer |
OLD | NEW |