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

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

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/protocol/proto_value_conversions.h" 7 #include "chrome/browser/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/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h" 11 #include "chrome/browser/sync/protocol/app_notification_specifics.pb.h"
12 #include "chrome/browser/sync/protocol/app_setting_specifics.pb.h"
12 #include "chrome/browser/sync/protocol/app_specifics.pb.h" 13 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
13 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 14 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
14 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 15 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
15 #include "chrome/browser/sync/protocol/encryption.pb.h" 16 #include "chrome/browser/sync/protocol/encryption.pb.h"
16 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" 17 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h"
17 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 18 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
18 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 19 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
19 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 20 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
20 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" 21 #include "chrome/browser/sync/protocol/preference_specifics.pb.h"
21 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" 22 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h"
(...skipping 17 matching lines...) Expand all
39 // We can't do much but make sure that the returned value has 40 // We can't do much but make sure that the returned value has
40 // something in it. 41 // something in it.
41 EXPECT_FALSE(value->empty()); 42 EXPECT_FALSE(value->empty());
42 } 43 }
43 }; 44 };
44 45
45 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { 46 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) {
46 // If this number changes, that means we added or removed a data 47 // If this number changes, that means we added or removed a data
47 // type. Don't forget to add a unit test for {New 48 // type. Don't forget to add a unit test for {New
48 // type}SpecificsToValue below. 49 // type}SpecificsToValue below.
49 EXPECT_EQ(16, syncable::MODEL_TYPE_COUNT); 50 EXPECT_EQ(17, syncable::MODEL_TYPE_COUNT);
50 51
51 // We'd also like to check if we changed any field in our messages. 52 // We'd also like to check if we changed any field in our messages.
52 // However, that's hard to do: sizeof could work, but it's 53 // However, that's hard to do: sizeof could work, but it's
53 // platform-dependent. default_instance().ByteSize() won't change 54 // platform-dependent. default_instance().ByteSize() won't change
54 // for most changes, since most of our fields are optional. So we 55 // for most changes, since most of our fields are optional. So we
55 // just settle for comments in the proto files. 56 // just settle for comments in the proto files.
56 } 57 }
57 58
58 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { 59 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) {
59 TestSpecificsToValue(EncryptedDataToValue); 60 TestSpecificsToValue(EncryptedDataToValue);
(...skipping 22 matching lines...) Expand all
82 EXPECT_FALSE(value->empty()); 83 EXPECT_FALSE(value->empty());
83 std::string password_value; 84 std::string password_value;
84 EXPECT_TRUE(value->GetString("password_value", &password_value)); 85 EXPECT_TRUE(value->GetString("password_value", &password_value));
85 EXPECT_EQ("<redacted>", password_value); 86 EXPECT_EQ("<redacted>", password_value);
86 } 87 }
87 88
88 TEST_F(ProtoValueConversionsTest, AppNotificationSpecificsToValue) { 89 TEST_F(ProtoValueConversionsTest, AppNotificationSpecificsToValue) {
89 TestSpecificsToValue(AppNotificationSpecificsToValue); 90 TestSpecificsToValue(AppNotificationSpecificsToValue);
90 } 91 }
91 92
93 TEST_F(ProtoValueConversionsTest, AppSettingSpecificsToValue) {
94 TestSpecificsToValue(AppSettingSpecificsToValue);
95 }
96
92 TEST_F(ProtoValueConversionsTest, AppSpecificsToValue) { 97 TEST_F(ProtoValueConversionsTest, AppSpecificsToValue) {
93 TestSpecificsToValue(AppSpecificsToValue); 98 TestSpecificsToValue(AppSpecificsToValue);
94 } 99 }
95 100
96 TEST_F(ProtoValueConversionsTest, AutofillSpecificsToValue) { 101 TEST_F(ProtoValueConversionsTest, AutofillSpecificsToValue) {
97 TestSpecificsToValue(AutofillSpecificsToValue); 102 TestSpecificsToValue(AutofillSpecificsToValue);
98 } 103 }
99 104
100 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { 105 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) {
101 TestSpecificsToValue(AutofillProfileSpecificsToValue); 106 TestSpecificsToValue(AutofillProfileSpecificsToValue);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. 149 // TODO(akalin): Figure out how to better test EntitySpecificsToValue.
145 150
146 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { 151 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
147 sync_pb::EntitySpecifics specifics; 152 sync_pb::EntitySpecifics specifics;
148 // Touch the extensions to make sure it shows up in the generated 153 // Touch the extensions to make sure it shows up in the generated
149 // value. 154 // value.
150 #define SET_EXTENSION(key) (void)specifics.MutableExtension(sync_pb::key) 155 #define SET_EXTENSION(key) (void)specifics.MutableExtension(sync_pb::key)
151 156
152 SET_EXTENSION(app); 157 SET_EXTENSION(app);
153 SET_EXTENSION(app_notification); 158 SET_EXTENSION(app_notification);
159 SET_EXTENSION(app_setting);
154 SET_EXTENSION(autofill); 160 SET_EXTENSION(autofill);
155 SET_EXTENSION(autofill_profile); 161 SET_EXTENSION(autofill_profile);
156 SET_EXTENSION(bookmark); 162 SET_EXTENSION(bookmark);
157 SET_EXTENSION(extension); 163 SET_EXTENSION(extension);
158 SET_EXTENSION(extension_setting); 164 SET_EXTENSION(extension_setting);
159 SET_EXTENSION(nigori); 165 SET_EXTENSION(nigori);
160 SET_EXTENSION(password); 166 SET_EXTENSION(password);
161 SET_EXTENSION(preference); 167 SET_EXTENSION(preference);
162 SET_EXTENSION(search_engine); 168 SET_EXTENSION(search_engine);
163 SET_EXTENSION(session); 169 SET_EXTENSION(session);
164 SET_EXTENSION(theme); 170 SET_EXTENSION(theme);
165 SET_EXTENSION(typed_url); 171 SET_EXTENSION(typed_url);
166 172
167 #undef SET_EXTENSION 173 #undef SET_EXTENSION
168 174
169 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); 175 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics));
170 EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE, 176 EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE,
171 static_cast<int>(value->size())); 177 static_cast<int>(value->size()));
172 } 178 }
173 179
174 } // namespace 180 } // namespace
175 } // namespace browser_sync 181 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698