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

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

Issue 11441005: Create a fresh sync datatype for Synced Notifications (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: CR changes - name change for Daniel, Fred's CR fixes Created 8 years 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 TEST_F(ProtoValueConversionsTest, SearchEngineSpecificsToValue) { 173 TEST_F(ProtoValueConversionsTest, SearchEngineSpecificsToValue) {
174 TestSpecificsToValue(SearchEngineSpecificsToValue); 174 TestSpecificsToValue(SearchEngineSpecificsToValue);
175 } 175 }
176 176
177 TEST_F(ProtoValueConversionsTest, SessionSpecificsToValue) { 177 TEST_F(ProtoValueConversionsTest, SessionSpecificsToValue) {
178 TestSpecificsToValue(SessionSpecificsToValue); 178 TestSpecificsToValue(SessionSpecificsToValue);
179 } 179 }
180 180
181 TEST_F(ProtoValueConversionsTest, SyncedNotificationsSpecificsToValue) {
182 TestSpecificsToValue(SyncedNotificationsSpecificsToValue);
183 }
184
181 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { 185 TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) {
182 TestSpecificsToValue(ThemeSpecificsToValue); 186 TestSpecificsToValue(ThemeSpecificsToValue);
183 } 187 }
184 188
185 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { 189 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) {
186 TestSpecificsToValue(TypedUrlSpecificsToValue); 190 TestSpecificsToValue(TypedUrlSpecificsToValue);
187 } 191 }
188 192
189 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. 193 // TODO(akalin): Figure out how to better test EntitySpecificsToValue.
190 194
(...skipping 12 matching lines...) Expand all
203 SET_FIELD(experiments); 207 SET_FIELD(experiments);
204 SET_FIELD(extension); 208 SET_FIELD(extension);
205 SET_FIELD(extension_setting); 209 SET_FIELD(extension_setting);
206 SET_FIELD(history_delete_directive); 210 SET_FIELD(history_delete_directive);
207 SET_FIELD(nigori); 211 SET_FIELD(nigori);
208 SET_FIELD(password); 212 SET_FIELD(password);
209 SET_FIELD(device_info); 213 SET_FIELD(device_info);
210 SET_FIELD(preference); 214 SET_FIELD(preference);
211 SET_FIELD(search_engine); 215 SET_FIELD(search_engine);
212 SET_FIELD(session); 216 SET_FIELD(session);
217 SET_FIELD(synced_notifications);
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,
220 static_cast<int>(value->size())); 225 static_cast<int>(value->size()));
221 } 226 }
222 227
(...skipping 54 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