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

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: Cleanup Created 7 years, 10 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(23, MODEL_TYPE_COUNT); 53 EXPECT_EQ(24, 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 SET_FIELD(priority_preference); 225 SET_FIELD(priority_preference);
226 SET_FIELD(search_engine); 226 SET_FIELD(search_engine);
227 SET_FIELD(session); 227 SET_FIELD(session);
228 SET_FIELD(synced_notification); 228 SET_FIELD(synced_notification);
229 SET_FIELD(theme); 229 SET_FIELD(theme);
230 SET_FIELD(typed_url); 230 SET_FIELD(typed_url);
231 231
232 #undef SET_FIELD 232 #undef SET_FIELD
233 233
234 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); 234 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics));
235 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE, 235 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE -
236 (LAST_PROXY_TYPE - FIRST_PROXY_TYPE + 1),
236 static_cast<int>(value->size())); 237 static_cast<int>(value->size()));
237 } 238 }
238 239
239 namespace { 240 namespace {
240 // Returns whether the given value has specifics under the entries in the given 241 // Returns whether the given value has specifics under the entries in the given
241 // path. 242 // path.
242 bool ValueHasSpecifics(const DictionaryValue& value, 243 bool ValueHasSpecifics(const DictionaryValue& value,
243 const std::string& path) { 244 const std::string& path) {
244 const ListValue* entities_list = NULL; 245 const ListValue* entities_list = NULL;
245 const DictionaryValue* entry_dictionary = NULL; 246 const DictionaryValue* entry_dictionary = NULL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 294
294 scoped_ptr<DictionaryValue> value_without_specifics( 295 scoped_ptr<DictionaryValue> value_without_specifics(
295 ClientToServerResponseToValue(message, false /* include_specifics */)); 296 ClientToServerResponseToValue(message, false /* include_specifics */));
296 EXPECT_FALSE(value_without_specifics->empty()); 297 EXPECT_FALSE(value_without_specifics->empty());
297 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), 298 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()),
298 "get_updates.entries")); 299 "get_updates.entries"));
299 } 300 }
300 301
301 } // namespace 302 } // namespace
302 } // namespace syncer 303 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698