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

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

Issue 14053004: Add ManagedUserSettings Sync data type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 8 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
« no previous file with comments | « sync/protocol/proto_value_conversions.cc ('k') | sync/protocol/sync.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/protocol/app_notification_specifics.pb.h" 14 #include "sync/protocol/app_notification_specifics.pb.h"
15 #include "sync/protocol/app_setting_specifics.pb.h" 15 #include "sync/protocol/app_setting_specifics.pb.h"
16 #include "sync/protocol/app_specifics.pb.h" 16 #include "sync/protocol/app_specifics.pb.h"
17 #include "sync/protocol/autofill_specifics.pb.h" 17 #include "sync/protocol/autofill_specifics.pb.h"
18 #include "sync/protocol/bookmark_specifics.pb.h" 18 #include "sync/protocol/bookmark_specifics.pb.h"
19 #include "sync/protocol/device_info_specifics.pb.h" 19 #include "sync/protocol/device_info_specifics.pb.h"
20 #include "sync/protocol/encryption.pb.h" 20 #include "sync/protocol/encryption.pb.h"
21 #include "sync/protocol/experiments_specifics.pb.h" 21 #include "sync/protocol/experiments_specifics.pb.h"
22 #include "sync/protocol/extension_setting_specifics.pb.h" 22 #include "sync/protocol/extension_setting_specifics.pb.h"
23 #include "sync/protocol/extension_specifics.pb.h" 23 #include "sync/protocol/extension_specifics.pb.h"
24 #include "sync/protocol/favicon_image_specifics.pb.h" 24 #include "sync/protocol/favicon_image_specifics.pb.h"
25 #include "sync/protocol/favicon_tracking_specifics.pb.h" 25 #include "sync/protocol/favicon_tracking_specifics.pb.h"
26 #include "sync/protocol/managed_user_setting_specifics.pb.h"
26 #include "sync/protocol/nigori_specifics.pb.h" 27 #include "sync/protocol/nigori_specifics.pb.h"
27 #include "sync/protocol/password_specifics.pb.h" 28 #include "sync/protocol/password_specifics.pb.h"
28 #include "sync/protocol/preference_specifics.pb.h" 29 #include "sync/protocol/preference_specifics.pb.h"
29 #include "sync/protocol/priority_preference_specifics.pb.h" 30 #include "sync/protocol/priority_preference_specifics.pb.h"
30 #include "sync/protocol/search_engine_specifics.pb.h" 31 #include "sync/protocol/search_engine_specifics.pb.h"
31 #include "sync/protocol/session_specifics.pb.h" 32 #include "sync/protocol/session_specifics.pb.h"
32 #include "sync/protocol/sync.pb.h" 33 #include "sync/protocol/sync.pb.h"
33 #include "sync/protocol/theme_specifics.pb.h" 34 #include "sync/protocol/theme_specifics.pb.h"
34 #include "sync/protocol/typed_url_specifics.pb.h" 35 #include "sync/protocol/typed_url_specifics.pb.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 37
37 namespace syncer { 38 namespace syncer {
38 namespace { 39 namespace {
39 40
40 class ProtoValueConversionsTest : public testing::Test { 41 class ProtoValueConversionsTest : public testing::Test {
41 protected: 42 protected:
42 template <class T> 43 template <class T>
43 void TestSpecificsToValue( 44 void TestSpecificsToValue(
44 DictionaryValue* (*specifics_to_value)(const T&)) { 45 DictionaryValue* (*specifics_to_value)(const T&)) {
45 const T& specifics(T::default_instance()); 46 const T& specifics(T::default_instance());
46 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics)); 47 scoped_ptr<DictionaryValue> value(specifics_to_value(specifics));
47 // We can't do much but make sure that this doesn't crash. 48 // We can't do much but make sure that this doesn't crash.
48 } 49 }
49 }; 50 };
50 51
51 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { 52 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
52 // If this number changes, that means we added or removed a data 53 // If this number changes, that means we added or removed a data
53 // type. Don't forget to add a unit test for {New 54 // type. Don't forget to add a unit test for {New
54 // type}SpecificsToValue below. 55 // type}SpecificsToValue below.
55 EXPECT_EQ(26, MODEL_TYPE_COUNT); 56 EXPECT_EQ(27, MODEL_TYPE_COUNT);
56 57
57 // We'd also like to check if we changed any field in our messages. 58 // We'd also like to check if we changed any field in our messages.
58 // However, that's hard to do: sizeof could work, but it's 59 // However, that's hard to do: sizeof could work, but it's
59 // platform-dependent. default_instance().ByteSize() won't change 60 // platform-dependent. default_instance().ByteSize() won't change
60 // for most changes, since most of our fields are optional. So we 61 // for most changes, since most of our fields are optional. So we
61 // just settle for comments in the proto files. 62 // just settle for comments in the proto files.
62 } 63 }
63 64
64 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { 65 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) {
65 TestSpecificsToValue(EncryptedDataToValue); 66 TestSpecificsToValue(EncryptedDataToValue);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 TEST_F(ProtoValueConversionsTest, FaviconTrackingSpecificsToValue) { 169 TEST_F(ProtoValueConversionsTest, FaviconTrackingSpecificsToValue) {
169 TestSpecificsToValue(FaviconTrackingSpecificsToValue); 170 TestSpecificsToValue(FaviconTrackingSpecificsToValue);
170 } 171 }
171 172
172 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { 173 TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) {
173 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); 174 TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue);
174 } 175 }
175 176
177 TEST_F(ProtoValueConversionsTest, ManagedUserSettingSpecificsToValue) {
178 TestSpecificsToValue(ManagedUserSettingSpecificsToValue);
179 }
180
176 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { 181 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) {
177 TestSpecificsToValue(NigoriSpecificsToValue); 182 TestSpecificsToValue(NigoriSpecificsToValue);
178 } 183 }
179 184
180 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { 185 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) {
181 TestSpecificsToValue(PasswordSpecificsToValue); 186 TestSpecificsToValue(PasswordSpecificsToValue);
182 } 187 }
183 188
184 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { 189 TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) {
185 TestSpecificsToValue(PreferenceSpecificsToValue); 190 TestSpecificsToValue(PreferenceSpecificsToValue);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 SET_FIELD(autofill_profile); 229 SET_FIELD(autofill_profile);
225 SET_FIELD(bookmark); 230 SET_FIELD(bookmark);
226 SET_FIELD(device_info); 231 SET_FIELD(device_info);
227 SET_FIELD(dictionary); 232 SET_FIELD(dictionary);
228 SET_FIELD(experiments); 233 SET_FIELD(experiments);
229 SET_FIELD(extension); 234 SET_FIELD(extension);
230 SET_FIELD(extension_setting); 235 SET_FIELD(extension_setting);
231 SET_FIELD(favicon_image); 236 SET_FIELD(favicon_image);
232 SET_FIELD(favicon_tracking); 237 SET_FIELD(favicon_tracking);
233 SET_FIELD(history_delete_directive); 238 SET_FIELD(history_delete_directive);
239 SET_FIELD(managed_user_setting);
234 SET_FIELD(nigori); 240 SET_FIELD(nigori);
235 SET_FIELD(password); 241 SET_FIELD(password);
236 SET_FIELD(preference); 242 SET_FIELD(preference);
237 SET_FIELD(priority_preference); 243 SET_FIELD(priority_preference);
238 SET_FIELD(search_engine); 244 SET_FIELD(search_engine);
239 SET_FIELD(session); 245 SET_FIELD(session);
240 SET_FIELD(synced_notification); 246 SET_FIELD(synced_notification);
241 SET_FIELD(theme); 247 SET_FIELD(theme);
242 SET_FIELD(typed_url); 248 SET_FIELD(typed_url);
243 249
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 312
307 scoped_ptr<DictionaryValue> value_without_specifics( 313 scoped_ptr<DictionaryValue> value_without_specifics(
308 ClientToServerResponseToValue(message, false /* include_specifics */)); 314 ClientToServerResponseToValue(message, false /* include_specifics */));
309 EXPECT_FALSE(value_without_specifics->empty()); 315 EXPECT_FALSE(value_without_specifics->empty());
310 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), 316 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()),
311 "get_updates.entries")); 317 "get_updates.entries"));
312 } 318 }
313 319
314 } // namespace 320 } // namespace
315 } // namespace syncer 321 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/protocol/proto_value_conversions.cc ('k') | sync/protocol/sync.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698