| 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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const T& specifics(T::default_instance()); | 48 const T& specifics(T::default_instance()); |
| 49 scoped_ptr<base::DictionaryValue> value(specifics_to_value(specifics)); | 49 scoped_ptr<base::DictionaryValue> value(specifics_to_value(specifics)); |
| 50 // We can't do much but make sure that this doesn't crash. | 50 // We can't do much but make sure that this doesn't crash. |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 54 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
| 55 // If this number changes, that means we added or removed a data | 55 // If this number changes, that means we added or removed a data |
| 56 // type. Don't forget to add a unit test for {New | 56 // type. Don't forget to add a unit test for {New |
| 57 // type}SpecificsToValue below. | 57 // type}SpecificsToValue below. |
| 58 EXPECT_EQ(31, MODEL_TYPE_COUNT); | 58 EXPECT_EQ(32, MODEL_TYPE_COUNT); |
| 59 | 59 |
| 60 // We'd also like to check if we changed any field in our messages. | 60 // We'd also like to check if we changed any field in our messages. |
| 61 // However, that's hard to do: sizeof could work, but it's | 61 // However, that's hard to do: sizeof could work, but it's |
| 62 // platform-dependent. default_instance().ByteSize() won't change | 62 // platform-dependent. default_instance().ByteSize() won't change |
| 63 // for most changes, since most of our fields are optional. So we | 63 // for most changes, since most of our fields are optional. So we |
| 64 // just settle for comments in the proto files. | 64 // just settle for comments in the proto files. |
| 65 } | 65 } |
| 66 | 66 |
| 67 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 67 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
| 68 TestSpecificsToValue(EncryptedDataToValue); | 68 TestSpecificsToValue(EncryptedDataToValue); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 TEST_F(ProtoValueConversionsTest, SearchEngineSpecificsToValue) { | 231 TEST_F(ProtoValueConversionsTest, SearchEngineSpecificsToValue) { |
| 232 TestSpecificsToValue(SearchEngineSpecificsToValue); | 232 TestSpecificsToValue(SearchEngineSpecificsToValue); |
| 233 } | 233 } |
| 234 | 234 |
| 235 TEST_F(ProtoValueConversionsTest, SessionSpecificsToValue) { | 235 TEST_F(ProtoValueConversionsTest, SessionSpecificsToValue) { |
| 236 TestSpecificsToValue(SessionSpecificsToValue); | 236 TestSpecificsToValue(SessionSpecificsToValue); |
| 237 } | 237 } |
| 238 | 238 |
| 239 TEST_F(ProtoValueConversionsTest, SyncedNotificationAppInfoSpecificsToValue) { |
| 240 TestSpecificsToValue(SyncedNotificationAppInfoSpecificsToValue); |
| 241 } |
| 242 |
| 239 TEST_F(ProtoValueConversionsTest, SyncedNotificationSpecificsToValue) { | 243 TEST_F(ProtoValueConversionsTest, SyncedNotificationSpecificsToValue) { |
| 240 TestSpecificsToValue(SyncedNotificationSpecificsToValue); | 244 TestSpecificsToValue(SyncedNotificationSpecificsToValue); |
| 241 } | 245 } |
| 242 | 246 |
| 243 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { | 247 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { |
| 244 TestSpecificsToValue(ThemeSpecificsToValue); | 248 TestSpecificsToValue(ThemeSpecificsToValue); |
| 245 } | 249 } |
| 246 | 250 |
| 247 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { | 251 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { |
| 248 TestSpecificsToValue(TypedUrlSpecificsToValue); | 252 TestSpecificsToValue(TypedUrlSpecificsToValue); |
| 249 } | 253 } |
| 250 | 254 |
| 251 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) { | 255 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) { |
| 252 TestSpecificsToValue(DictionarySpecificsToValue); | 256 TestSpecificsToValue(DictionarySpecificsToValue); |
| 253 } | 257 } |
| 254 | 258 |
| 255 TEST_F(ProtoValueConversionsTest, ArticleSpecificsToValue) { | 259 TEST_F(ProtoValueConversionsTest, ArticleSpecificsToValue) { |
| 256 TestSpecificsToValue(ArticleSpecificsToValue); | 260 TestSpecificsToValue(ArticleSpecificsToValue); |
| 257 } | 261 } |
| 258 | 262 |
| 259 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. | 263 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. |
| 260 | 264 |
| 261 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { | 265 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { |
| 262 sync_pb::EntitySpecifics specifics; | 266 sync_pb::EntitySpecifics specifics; |
| 263 // Touch the extensions to make sure it shows up in the generated | 267 // Touch the extensions to make sure it shows up in the generated |
| 264 // value. | 268 // value. |
| 265 #define SET_FIELD(key) (void)specifics.mutable_##key() | 269 #define SET_FIELD(key) (void)specifics.mutable_##key() |
| 266 | 270 |
| 267 SET_FIELD(app); | 271 SET_FIELD(app); |
| 272 SET_FIELD(app_info); |
| 268 SET_FIELD(app_list); | 273 SET_FIELD(app_list); |
| 269 SET_FIELD(app_notification); | 274 SET_FIELD(app_notification); |
| 270 SET_FIELD(app_setting); | 275 SET_FIELD(app_setting); |
| 271 SET_FIELD(article); | 276 SET_FIELD(article); |
| 272 SET_FIELD(autofill); | 277 SET_FIELD(autofill); |
| 273 SET_FIELD(autofill_profile); | 278 SET_FIELD(autofill_profile); |
| 274 SET_FIELD(bookmark); | 279 SET_FIELD(bookmark); |
| 275 SET_FIELD(device_info); | 280 SET_FIELD(device_info); |
| 276 SET_FIELD(dictionary); | 281 SET_FIELD(dictionary); |
| 277 SET_FIELD(experiments); | 282 SET_FIELD(experiments); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 367 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
| 363 "get_updates.entries")); | 368 "get_updates.entries")); |
| 364 } | 369 } |
| 365 | 370 |
| 366 TEST_F(ProtoValueConversionsTest, SyncAttachmentIdToValue) { | 371 TEST_F(ProtoValueConversionsTest, SyncAttachmentIdToValue) { |
| 367 TestSpecificsToValue(SyncAttachmentIdToValue); | 372 TestSpecificsToValue(SyncAttachmentIdToValue); |
| 368 } | 373 } |
| 369 | 374 |
| 370 } // namespace | 375 } // namespace |
| 371 } // namespace syncer | 376 } // namespace syncer |
| OLD | NEW |