OLD | NEW |
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_specifics.pb.h" | 11 #include "chrome/browser/sync/protocol/app_specifics.pb.h" |
12 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 12 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 13 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
14 #include "chrome/browser/sync/protocol/encryption.pb.h" | 14 #include "chrome/browser/sync/protocol/encryption.pb.h" |
| 15 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
15 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" | 16 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" |
16 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" | 17 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" |
17 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 18 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
18 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" | 19 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" |
19 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" | 20 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" |
20 #include "chrome/browser/sync/protocol/session_specifics.pb.h" | 21 #include "chrome/browser/sync/protocol/session_specifics.pb.h" |
21 #include "chrome/browser/sync/protocol/sync.pb.h" | 22 #include "chrome/browser/sync/protocol/sync.pb.h" |
22 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 23 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
23 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" | 24 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" |
24 #include "chrome/browser/sync/syncable/model_type.h" | 25 #include "chrome/browser/sync/syncable/model_type.h" |
(...skipping 12 matching lines...) Expand all Loading... |
37 // We can't do much but make sure that the returned value has | 38 // We can't do much but make sure that the returned value has |
38 // something in it. | 39 // something in it. |
39 EXPECT_FALSE(value->empty()); | 40 EXPECT_FALSE(value->empty()); |
40 } | 41 } |
41 }; | 42 }; |
42 | 43 |
43 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 44 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
44 // If this number changes, that means we added or removed a data | 45 // If this number changes, that means we added or removed a data |
45 // type. Don't forget to add a unit test for {New | 46 // type. Don't forget to add a unit test for {New |
46 // type}SpecificsToValue below. | 47 // type}SpecificsToValue below. |
47 EXPECT_EQ(14, syncable::MODEL_TYPE_COUNT); | 48 EXPECT_EQ(15, syncable::MODEL_TYPE_COUNT); |
48 | 49 |
49 // We'd also like to check if we changed any field in our messages. | 50 // We'd also like to check if we changed any field in our messages. |
50 // However, that's hard to do: sizeof could work, but it's | 51 // However, that's hard to do: sizeof could work, but it's |
51 // platform-dependent. default_instance().ByteSize() won't change | 52 // platform-dependent. default_instance().ByteSize() won't change |
52 // for most changes, since most of our fields are optional. So we | 53 // for most changes, since most of our fields are optional. So we |
53 // just settle for comments in the proto files. | 54 // just settle for comments in the proto files. |
54 } | 55 } |
55 | 56 |
56 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 57 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
57 TestSpecificsToValue(EncryptedDataToValue); | 58 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 93 } |
93 | 94 |
94 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { | 95 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { |
95 TestSpecificsToValue(AutofillProfileSpecificsToValue); | 96 TestSpecificsToValue(AutofillProfileSpecificsToValue); |
96 } | 97 } |
97 | 98 |
98 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) { | 99 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) { |
99 TestSpecificsToValue(BookmarkSpecificsToValue); | 100 TestSpecificsToValue(BookmarkSpecificsToValue); |
100 } | 101 } |
101 | 102 |
| 103 TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { |
| 104 TestSpecificsToValue(ExtensionSettingSpecificsToValue); |
| 105 } |
| 106 |
102 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { | 107 TEST_F(ProtoValueConversionsTest, ExtensionSpecificsToValue) { |
103 TestSpecificsToValue(ExtensionSpecificsToValue); | 108 TestSpecificsToValue(ExtensionSpecificsToValue); |
104 } | 109 } |
105 | 110 |
106 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { | 111 TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { |
107 TestSpecificsToValue(NigoriSpecificsToValue); | 112 TestSpecificsToValue(NigoriSpecificsToValue); |
108 } | 113 } |
109 | 114 |
110 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { | 115 TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { |
111 TestSpecificsToValue(PasswordSpecificsToValue); | 116 TestSpecificsToValue(PasswordSpecificsToValue); |
(...skipping 25 matching lines...) Expand all Loading... |
137 sync_pb::EntitySpecifics specifics; | 142 sync_pb::EntitySpecifics specifics; |
138 // Touch the extensions to make sure it shows up in the generated | 143 // Touch the extensions to make sure it shows up in the generated |
139 // value. | 144 // value. |
140 #define SET_EXTENSION(key) (void)specifics.MutableExtension(sync_pb::key) | 145 #define SET_EXTENSION(key) (void)specifics.MutableExtension(sync_pb::key) |
141 | 146 |
142 SET_EXTENSION(app); | 147 SET_EXTENSION(app); |
143 SET_EXTENSION(autofill); | 148 SET_EXTENSION(autofill); |
144 SET_EXTENSION(autofill_profile); | 149 SET_EXTENSION(autofill_profile); |
145 SET_EXTENSION(bookmark); | 150 SET_EXTENSION(bookmark); |
146 SET_EXTENSION(extension); | 151 SET_EXTENSION(extension); |
| 152 SET_EXTENSION(extension_setting); |
147 SET_EXTENSION(nigori); | 153 SET_EXTENSION(nigori); |
148 SET_EXTENSION(password); | 154 SET_EXTENSION(password); |
149 SET_EXTENSION(preference); | 155 SET_EXTENSION(preference); |
150 SET_EXTENSION(search_engine); | 156 SET_EXTENSION(search_engine); |
151 SET_EXTENSION(session); | 157 SET_EXTENSION(session); |
152 SET_EXTENSION(theme); | 158 SET_EXTENSION(theme); |
153 SET_EXTENSION(typed_url); | 159 SET_EXTENSION(typed_url); |
154 | 160 |
155 #undef SET_EXTENSION | 161 #undef SET_EXTENSION |
156 | 162 |
157 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); | 163 scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics)); |
158 EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE, | 164 EXPECT_EQ(syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE, |
159 static_cast<int>(value->size())); | 165 static_cast<int>(value->size())); |
160 } | 166 } |
161 | 167 |
162 } // namespace | 168 } // namespace |
163 } // namespace browser_sync | 169 } // namespace browser_sync |
OLD | NEW |