Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: sync/protocol/proto_value_conversions_unittest.cc

Issue 11445002: Sync user's custom spellcheck dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add browser tests for dictionary change notifications in settings Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const T& specifics(T::default_instance()); 42 const T& specifics(T::default_instance());
43 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); 43 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics));
44 // We can't do much but make sure that this doesn't crash. 44 // We can't do much but make sure that this doesn't crash.
45 } 45 }
46 }; 46 };
47 47
48 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { 48 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
49 // If this number changes, that means we added or removed a data 49 // If this number changes, that means we added or removed a data
50 // type. Don't forget to add a unit test for {New 50 // type. Don't forget to add a unit test for {New
51 // type}SpecificsToValue below. 51 // type}SpecificsToValue below.
52 EXPECT_EQ(20, MODEL_TYPE_COUNT); 52 EXPECT_EQ(21, MODEL_TYPE_COUNT);
53 53
54 // We'd also like to check if we changed any field in our messages. 54 // We'd also like to check if we changed any field in our messages.
55 // However, that's hard to do: sizeof could work, but it's 55 // However, that's hard to do: sizeof could work, but it's
56 // platform-dependent. default_instance().ByteSize() won't change 56 // platform-dependent. default_instance().ByteSize() won't change
57 // for most changes, since most of our fields are optional. So we 57 // for most changes, since most of our fields are optional. So we
58 // just settle for comments in the proto files. 58 // just settle for comments in the proto files.
59 } 59 }
60 60
61 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { 61 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) {
62 TestSpecificsToValue(EncryptedDataToValue); 62 TestSpecificsToValue(EncryptedDataToValue);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { 181 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) {
182 TestSpecificsToValue(ThemeSpecificsToValue); 182 TestSpecificsToValue(ThemeSpecificsToValue);
183 } 183 }
184 184
185 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { 185 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) {
186 TestSpecificsToValue(TypedUrlSpecificsToValue); 186 TestSpecificsToValue(TypedUrlSpecificsToValue);
187 } 187 }
188 188
189 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) {
190 TestSpecificsToValue(DictionarySpecificsToValue);
191 }
192
189 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. 193 // TODO(akalin): Figure out how to better test EntitySpecificsToValue.
190 194
191 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { 195 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
192 sync_pb::EntitySpecifics specifics; 196 sync_pb::EntitySpecifics specifics;
193 // Touch the extensions to make sure it shows up in the generated 197 // Touch the extensions to make sure it shows up in the generated
194 // value. 198 // value.
195 #define SET_FIELD(key) (void)specifics.mutable_##key() 199 #define SET_FIELD(key) (void)specifics.mutable_##key()
196 200
197 SET_FIELD(app); 201 SET_FIELD(app);
198 SET_FIELD(app_notification); 202 SET_FIELD(app_notification);
199 SET_FIELD(app_setting); 203 SET_FIELD(app_setting);
200 SET_FIELD(autofill); 204 SET_FIELD(autofill);
201 SET_FIELD(autofill_profile); 205 SET_FIELD(autofill_profile);
202 SET_FIELD(bookmark); 206 SET_FIELD(bookmark);
207 SET_FIELD(device_info);
208 SET_FIELD(dictionary);
203 SET_FIELD(experiments); 209 SET_FIELD(experiments);
204 SET_FIELD(extension); 210 SET_FIELD(extension);
205 SET_FIELD(extension_setting); 211 SET_FIELD(extension_setting);
206 SET_FIELD(history_delete_directive); 212 SET_FIELD(history_delete_directive);
207 SET_FIELD(nigori); 213 SET_FIELD(nigori);
208 SET_FIELD(password); 214 SET_FIELD(password);
209 SET_FIELD(device_info);
210 SET_FIELD(preference); 215 SET_FIELD(preference);
211 SET_FIELD(search_engine); 216 SET_FIELD(search_engine);
212 SET_FIELD(session); 217 SET_FIELD(session);
213 SET_FIELD(theme); 218 SET_FIELD(theme);
214 SET_FIELD(typed_url); 219 SET_FIELD(typed_url);
215 220
216 #undef SET_FIELD 221 #undef SET_FIELD
217 222
218 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); 223 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics));
219 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE, 224 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 282
278 scoped_ptr<DictionaryValue> value_without_specifics( 283 scoped_ptr<DictionaryValue> value_without_specifics(
279 ClientToServerResponseToValue(message, false /* include_specifics */)); 284 ClientToServerResponseToValue(message, false /* include_specifics */));
280 EXPECT_FALSE(value_without_specifics->empty()); 285 EXPECT_FALSE(value_without_specifics->empty());
281 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), 286 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()),
282 "get_updates.entries")); 287 "get_updates.entries"));
283 } 288 }
284 289
285 } // namespace 290 } // namespace
286 } // namespace syncer 291 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698