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/values.h" | 10 #include "base/values.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // We can't do much but make sure that the returned value has | 40 // We can't do much but make sure that the returned value has |
41 // something in it. | 41 // something in it. |
42 EXPECT_FALSE(value->empty()); | 42 EXPECT_FALSE(value->empty()); |
43 } | 43 } |
44 }; | 44 }; |
45 | 45 |
46 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 46 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
47 // If this number changes, that means we added or removed a data | 47 // If this number changes, that means we added or removed a data |
48 // type. Don't forget to add a unit test for {New | 48 // type. Don't forget to add a unit test for {New |
49 // type}SpecificsToValue below. | 49 // type}SpecificsToValue below. |
50 EXPECT_EQ(17, MODEL_TYPE_COUNT); | 50 EXPECT_EQ(18, MODEL_TYPE_COUNT); |
51 | 51 |
52 // We'd also like to check if we changed any field in our messages. | 52 // We'd also like to check if we changed any field in our messages. |
53 // However, that's hard to do: sizeof could work, but it's | 53 // However, that's hard to do: sizeof could work, but it's |
54 // platform-dependent. default_instance().ByteSize() won't change | 54 // platform-dependent. default_instance().ByteSize() won't change |
55 // for most changes, since most of our fields are optional. So we | 55 // for most changes, since most of our fields are optional. So we |
56 // just settle for comments in the proto files. | 56 // just settle for comments in the proto files. |
57 } | 57 } |
58 | 58 |
59 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 59 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
60 TestSpecificsToValue(EncryptedDataToValue); | 60 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { | 123 TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { |
124 TestSpecificsToValue(ExtensionSettingSpecificsToValue); | 124 TestSpecificsToValue(ExtensionSettingSpecificsToValue); |
125 } | 125 } |
126 | 126 |
127 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { | 127 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { |
128 TestSpecificsToValue(ExtensionSpecificsToValue); | 128 TestSpecificsToValue(ExtensionSpecificsToValue); |
129 } | 129 } |
130 | 130 |
| 131 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { |
| 132 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); |
| 133 } |
| 134 |
131 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { | 135 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { |
132 TestSpecificsToValue(NigoriSpecificsToValue); | 136 TestSpecificsToValue(NigoriSpecificsToValue); |
133 } | 137 } |
134 | 138 |
135 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { | 139 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { |
136 TestSpecificsToValue(PasswordSpecificsToValue); | 140 TestSpecificsToValue(PasswordSpecificsToValue); |
137 } | 141 } |
138 | 142 |
139 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { | 143 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { |
140 TestSpecificsToValue(PreferenceSpecificsToValue); | 144 TestSpecificsToValue(PreferenceSpecificsToValue); |
(...skipping 24 matching lines...) Expand all Loading... |
165 #define SET_FIELD(key) (void)specifics.mutable_##key() | 169 #define SET_FIELD(key) (void)specifics.mutable_##key() |
166 | 170 |
167 SET_FIELD(app); | 171 SET_FIELD(app); |
168 SET_FIELD(app_notification); | 172 SET_FIELD(app_notification); |
169 SET_FIELD(app_setting); | 173 SET_FIELD(app_setting); |
170 SET_FIELD(autofill); | 174 SET_FIELD(autofill); |
171 SET_FIELD(autofill_profile); | 175 SET_FIELD(autofill_profile); |
172 SET_FIELD(bookmark); | 176 SET_FIELD(bookmark); |
173 SET_FIELD(extension); | 177 SET_FIELD(extension); |
174 SET_FIELD(extension_setting); | 178 SET_FIELD(extension_setting); |
| 179 SET_FIELD(history_delete_directive); |
175 SET_FIELD(nigori); | 180 SET_FIELD(nigori); |
176 SET_FIELD(password); | 181 SET_FIELD(password); |
177 SET_FIELD(preference); | 182 SET_FIELD(preference); |
178 SET_FIELD(search_engine); | 183 SET_FIELD(search_engine); |
179 SET_FIELD(session); | 184 SET_FIELD(session); |
180 SET_FIELD(theme); | 185 SET_FIELD(theme); |
181 SET_FIELD(typed_url); | 186 SET_FIELD(typed_url); |
182 | 187 |
183 #undef SET_FIELD | 188 #undef SET_FIELD |
184 | 189 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 249 |
245 scoped_ptr<DictionaryValue> value_without_specifics( | 250 scoped_ptr<DictionaryValue> value_without_specifics( |
246 ClientToServerResponseToValue(message, false /* include_specifics */)); | 251 ClientToServerResponseToValue(message, false /* include_specifics */)); |
247 EXPECT_FALSE(value_without_specifics->empty()); | 252 EXPECT_FALSE(value_without_specifics->empty()); |
248 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 253 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
249 "get_updates.entries")); | 254 "get_updates.entries")); |
250 } | 255 } |
251 | 256 |
252 } // namespace | 257 } // namespace |
253 } // namespace syncer | 258 } // namespace syncer |
OLD | NEW |