| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const T& specifics(T::default_instance()); | 46 const T& specifics(T::default_instance()); |
| 47 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); | 47 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); |
| 48 // We can't do much but make sure that this doesn't crash. | 48 // We can't do much but make sure that this doesn't crash. |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 52 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
| 53 // If this number changes, that means we added or removed a data | 53 // If this number changes, that means we added or removed a data |
| 54 // type. Don't forget to add a unit test for {New | 54 // type. Don't forget to add a unit test for {New |
| 55 // type}SpecificsToValue below. | 55 // type}SpecificsToValue below. |
| 56 EXPECT_EQ(27, MODEL_TYPE_COUNT); | 56 EXPECT_EQ(28, MODEL_TYPE_COUNT); |
| 57 | 57 |
| 58 // We'd also like to check if we changed any field in our messages. | 58 // We'd also like to check if we changed any field in our messages. |
| 59 // However, that's hard to do: sizeof could work, but it's | 59 // However, that's hard to do: sizeof could work, but it's |
| 60 // platform-dependent. default_instance().ByteSize() won't change | 60 // platform-dependent. default_instance().ByteSize() won't change |
| 61 // for most changes, since most of our fields are optional. So we | 61 // for most changes, since most of our fields are optional. So we |
| 62 // just settle for comments in the proto files. | 62 // just settle for comments in the proto files. |
| 63 } | 63 } |
| 64 | 64 |
| 65 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 65 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
| 66 TestSpecificsToValue(EncryptedDataToValue); | 66 TestSpecificsToValue(EncryptedDataToValue); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { | 173 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { |
| 174 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); | 174 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); |
| 175 } | 175 } |
| 176 | 176 |
| 177 TEST_F(ProtoValueConversionsTest, ManagedUserSettingSpecificsToValue) { | 177 TEST_F(ProtoValueConversionsTest, ManagedUserSettingSpecificsToValue) { |
| 178 TestSpecificsToValue(ManagedUserSettingSpecificsToValue); | 178 TestSpecificsToValue(ManagedUserSettingSpecificsToValue); |
| 179 } | 179 } |
| 180 | 180 |
| 181 TEST_F(ProtoValueConversionsTest, ManagedUserSpecificsToValue) { |
| 182 TestSpecificsToValue(ManagedUserSpecificsToValue); |
| 183 } |
| 184 |
| 181 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { | 185 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { |
| 182 TestSpecificsToValue(NigoriSpecificsToValue); | 186 TestSpecificsToValue(NigoriSpecificsToValue); |
| 183 } | 187 } |
| 184 | 188 |
| 185 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { | 189 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { |
| 186 TestSpecificsToValue(PasswordSpecificsToValue); | 190 TestSpecificsToValue(PasswordSpecificsToValue); |
| 187 } | 191 } |
| 188 | 192 |
| 189 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { | 193 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { |
| 190 TestSpecificsToValue(PreferenceSpecificsToValue); | 194 TestSpecificsToValue(PreferenceSpecificsToValue); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 SET_FIELD(bookmark); | 234 SET_FIELD(bookmark); |
| 231 SET_FIELD(device_info); | 235 SET_FIELD(device_info); |
| 232 SET_FIELD(dictionary); | 236 SET_FIELD(dictionary); |
| 233 SET_FIELD(experiments); | 237 SET_FIELD(experiments); |
| 234 SET_FIELD(extension); | 238 SET_FIELD(extension); |
| 235 SET_FIELD(extension_setting); | 239 SET_FIELD(extension_setting); |
| 236 SET_FIELD(favicon_image); | 240 SET_FIELD(favicon_image); |
| 237 SET_FIELD(favicon_tracking); | 241 SET_FIELD(favicon_tracking); |
| 238 SET_FIELD(history_delete_directive); | 242 SET_FIELD(history_delete_directive); |
| 239 SET_FIELD(managed_user_setting); | 243 SET_FIELD(managed_user_setting); |
| 244 SET_FIELD(managed_user); |
| 240 SET_FIELD(nigori); | 245 SET_FIELD(nigori); |
| 241 SET_FIELD(password); | 246 SET_FIELD(password); |
| 242 SET_FIELD(preference); | 247 SET_FIELD(preference); |
| 243 SET_FIELD(priority_preference); | 248 SET_FIELD(priority_preference); |
| 244 SET_FIELD(search_engine); | 249 SET_FIELD(search_engine); |
| 245 SET_FIELD(session); | 250 SET_FIELD(session); |
| 246 SET_FIELD(synced_notification); | 251 SET_FIELD(synced_notification); |
| 247 SET_FIELD(theme); | 252 SET_FIELD(theme); |
| 248 SET_FIELD(typed_url); | 253 SET_FIELD(typed_url); |
| 249 | 254 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 317 |
| 313 scoped_ptr<DictionaryValue> value_without_specifics( | 318 scoped_ptr<DictionaryValue> value_without_specifics( |
| 314 ClientToServerResponseToValue(message, false /* include_specifics */)); | 319 ClientToServerResponseToValue(message, false /* include_specifics */)); |
| 315 EXPECT_FALSE(value_without_specifics->empty()); | 320 EXPECT_FALSE(value_without_specifics->empty()); |
| 316 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 321 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
| 317 "get_updates.entries")); | 322 "get_updates.entries")); |
| 318 } | 323 } |
| 319 | 324 |
| 320 } // namespace | 325 } // namespace |
| 321 } // namespace syncer | 326 } // namespace syncer |
| OLD | NEW |