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

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

Issue 11961030: [Sync] Make SESSIONS an implicit type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 11 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 | Annotate | Revision Log
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const T& specifics(T::default_instance()); 43 const T& specifics(T::default_instance());
44 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); 44 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics));
45 // We can't do much but make sure that this doesn't crash. 45 // We can't do much but make sure that this doesn't crash.
46 } 46 }
47 }; 47 };
48 48
49 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { 49 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
50 // If this number changes, that means we added or removed a data 50 // If this number changes, that means we added or removed a data
51 // type. Don't forget to add a unit test for {New 51 // type. Don't forget to add a unit test for {New
52 // type}SpecificsToValue below. 52 // type}SpecificsToValue below.
53 EXPECT_EQ(22, MODEL_TYPE_COUNT); 53 EXPECT_EQ(23, MODEL_TYPE_COUNT);
54 54
55 // We'd also like to check if we changed any field in our messages. 55 // We'd also like to check if we changed any field in our messages.
56 // However, that's hard to do: sizeof could work, but it's 56 // However, that's hard to do: sizeof could work, but it's
57 // platform-dependent. default_instance().ByteSize() won't change 57 // platform-dependent. default_instance().ByteSize() won't change
58 // for most changes, since most of our fields are optional. So we 58 // for most changes, since most of our fields are optional. So we
59 // just settle for comments in the proto files. 59 // just settle for comments in the proto files.
60 } 60 }
61 61
62 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { 62 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) {
63 TestSpecificsToValue(EncryptedDataToValue); 63 TestSpecificsToValue(EncryptedDataToValue);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 SET_FIELD(priority_preference); 220 SET_FIELD(priority_preference);
221 SET_FIELD(search_engine); 221 SET_FIELD(search_engine);
222 SET_FIELD(session); 222 SET_FIELD(session);
223 SET_FIELD(synced_notification); 223 SET_FIELD(synced_notification);
224 SET_FIELD(theme); 224 SET_FIELD(theme);
225 SET_FIELD(typed_url); 225 SET_FIELD(typed_url);
226 226
227 #undef SET_FIELD 227 #undef SET_FIELD
228 228
229 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); 229 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics));
230 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE, 230 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE -
231 (LAST_VIRTUAL_TYPE - FIRST_VIRTUAL_TYPE + 1),
231 static_cast<int>(value->size())); 232 static_cast<int>(value->size()));
232 } 233 }
233 234
234 namespace { 235 namespace {
235 // Returns whether the given value has specifics under the entries in the given 236 // Returns whether the given value has specifics under the entries in the given
236 // path. 237 // path.
237 bool ValueHasSpecifics(const DictionaryValue& value, 238 bool ValueHasSpecifics(const DictionaryValue& value,
238 const std::string& path) { 239 const std::string& path) {
239 const ListValue* entities_list = NULL; 240 const ListValue* entities_list = NULL;
240 const DictionaryValue* entry_dictionary = NULL; 241 const DictionaryValue* entry_dictionary = NULL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 289
289 scoped_ptr<DictionaryValue> value_without_specifics( 290 scoped_ptr<DictionaryValue> value_without_specifics(
290 ClientToServerResponseToValue(message, false /* include_specifics */)); 291 ClientToServerResponseToValue(message, false /* include_specifics */));
291 EXPECT_FALSE(value_without_specifics->empty()); 292 EXPECT_FALSE(value_without_specifics->empty());
292 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), 293 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()),
293 "get_updates.entries")); 294 "get_updates.entries"));
294 } 295 }
295 296
296 } // namespace 297 } // namespace
297 } // namespace syncer 298 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698