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 30 matching lines...) Expand all Loading... |
41 const T& specifics(T::default_instance()); | 41 const T& specifics(T::default_instance()); |
42 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); | 42 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); |
43 // We can't do much but make sure that this doesn't crash. | 43 // We can't do much but make sure that this doesn't crash. |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 47 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
48 // If this number changes, that means we added or removed a data | 48 // If this number changes, that means we added or removed a data |
49 // type. Don't forget to add a unit test for {New | 49 // type. Don't forget to add a unit test for {New |
50 // type}SpecificsToValue below. | 50 // type}SpecificsToValue below. |
51 EXPECT_EQ(18, MODEL_TYPE_COUNT); | 51 EXPECT_EQ(19, MODEL_TYPE_COUNT); |
52 | 52 |
53 // We'd also like to check if we changed any field in our messages. | 53 // We'd also like to check if we changed any field in our messages. |
54 // However, that's hard to do: sizeof could work, but it's | 54 // However, that's hard to do: sizeof could work, but it's |
55 // platform-dependent. default_instance().ByteSize() won't change | 55 // platform-dependent. default_instance().ByteSize() won't change |
56 // for most changes, since most of our fields are optional. So we | 56 // for most changes, since most of our fields are optional. So we |
57 // just settle for comments in the proto files. | 57 // just settle for comments in the proto files. |
58 } | 58 } |
59 | 59 |
60 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 60 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
61 TestSpecificsToValue(EncryptedDataToValue); | 61 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { | 135 TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { |
136 TestSpecificsToValue(ExtensionSettingSpecificsToValue); | 136 TestSpecificsToValue(ExtensionSettingSpecificsToValue); |
137 } | 137 } |
138 | 138 |
139 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { | 139 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { |
140 TestSpecificsToValue(ExtensionSpecificsToValue); | 140 TestSpecificsToValue(ExtensionSpecificsToValue); |
141 } | 141 } |
142 | 142 |
| 143 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { |
| 144 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); |
| 145 } |
| 146 |
143 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { | 147 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { |
144 TestSpecificsToValue(NigoriSpecificsToValue); | 148 TestSpecificsToValue(NigoriSpecificsToValue); |
145 } | 149 } |
146 | 150 |
147 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { | 151 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { |
148 TestSpecificsToValue(PasswordSpecificsToValue); | 152 TestSpecificsToValue(PasswordSpecificsToValue); |
149 } | 153 } |
150 | 154 |
151 TEST_F(ProtoValueConversionsTest, DeviceInfoSpecificsToValue) { | 155 TEST_F(ProtoValueConversionsTest, DeviceInfoSpecificsToValue) { |
152 TestSpecificsToValue(DeviceInfoSpecificsToValue); | 156 TestSpecificsToValue(DeviceInfoSpecificsToValue); |
(...skipping 28 matching lines...) Expand all Loading... |
181 #define SET_FIELD(key) (void)specifics.mutable_##key() | 185 #define SET_FIELD(key) (void)specifics.mutable_##key() |
182 | 186 |
183 SET_FIELD(app); | 187 SET_FIELD(app); |
184 SET_FIELD(app_notification); | 188 SET_FIELD(app_notification); |
185 SET_FIELD(app_setting); | 189 SET_FIELD(app_setting); |
186 SET_FIELD(autofill); | 190 SET_FIELD(autofill); |
187 SET_FIELD(autofill_profile); | 191 SET_FIELD(autofill_profile); |
188 SET_FIELD(bookmark); | 192 SET_FIELD(bookmark); |
189 SET_FIELD(extension); | 193 SET_FIELD(extension); |
190 SET_FIELD(extension_setting); | 194 SET_FIELD(extension_setting); |
| 195 SET_FIELD(history_delete_directive); |
191 SET_FIELD(nigori); | 196 SET_FIELD(nigori); |
192 SET_FIELD(password); | 197 SET_FIELD(password); |
193 SET_FIELD(device_info); | 198 SET_FIELD(device_info); |
194 SET_FIELD(preference); | 199 SET_FIELD(preference); |
195 SET_FIELD(search_engine); | 200 SET_FIELD(search_engine); |
196 SET_FIELD(session); | 201 SET_FIELD(session); |
197 SET_FIELD(theme); | 202 SET_FIELD(theme); |
198 SET_FIELD(typed_url); | 203 SET_FIELD(typed_url); |
199 | 204 |
200 #undef SET_FIELD | 205 #undef SET_FIELD |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 266 |
262 scoped_ptr<DictionaryValue> value_without_specifics( | 267 scoped_ptr<DictionaryValue> value_without_specifics( |
263 ClientToServerResponseToValue(message, false /* include_specifics */)); | 268 ClientToServerResponseToValue(message, false /* include_specifics */)); |
264 EXPECT_FALSE(value_without_specifics->empty()); | 269 EXPECT_FALSE(value_without_specifics->empty()); |
265 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 270 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
266 "get_updates.entries")); | 271 "get_updates.entries")); |
267 } | 272 } |
268 | 273 |
269 } // namespace | 274 } // namespace |
270 } // namespace syncer | 275 } // namespace syncer |
OLD | NEW |