OLD | NEW |
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 <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 std::unique_ptr<base::DictionaryValue> value = | 53 std::unique_ptr<base::DictionaryValue> value = |
54 specifics_to_value(specifics); | 54 specifics_to_value(specifics); |
55 // We can't do much but make sure that this doesn't crash. | 55 // We can't do much but make sure that this doesn't crash. |
56 } | 56 } |
57 }; | 57 }; |
58 | 58 |
59 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 59 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
60 // If this number changes, that means we added or removed a data | 60 // If this number changes, that means we added or removed a data |
61 // type. Don't forget to add a unit test for {New | 61 // type. Don't forget to add a unit test for {New |
62 // type}SpecificsToValue below. | 62 // type}SpecificsToValue below. |
63 EXPECT_EQ(36, MODEL_TYPE_COUNT); | 63 EXPECT_EQ(37, MODEL_TYPE_COUNT); |
64 | 64 |
65 // We'd also like to check if we changed any field in our messages. | 65 // We'd also like to check if we changed any field in our messages. |
66 // However, that's hard to do: sizeof could work, but it's | 66 // However, that's hard to do: sizeof could work, but it's |
67 // platform-dependent. default_instance().ByteSize() won't change | 67 // platform-dependent. default_instance().ByteSize() won't change |
68 // for most changes, since most of our fields are optional. So we | 68 // for most changes, since most of our fields are optional. So we |
69 // just settle for comments in the proto files. | 69 // just settle for comments in the proto files. |
70 } | 70 } |
71 | 71 |
72 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 72 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
73 TestSpecificsToValue(EncryptedDataToValue); | 73 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 EXPECT_TRUE(value->GetBoolean("disabled", &disabled_value)); | 123 EXPECT_TRUE(value->GetBoolean("disabled", &disabled_value)); |
124 EXPECT_EQ(true, disabled_value); | 124 EXPECT_EQ(true, disabled_value); |
125 EXPECT_TRUE(value->GetString("oauth_client_id", &oauth_client_id_value)); | 125 EXPECT_TRUE(value->GetString("oauth_client_id", &oauth_client_id_value)); |
126 EXPECT_EQ("some_id_value", oauth_client_id_value); | 126 EXPECT_EQ("some_id_value", oauth_client_id_value); |
127 } | 127 } |
128 | 128 |
129 TEST_F(ProtoValueConversionsTest, AppSpecificsToValue) { | 129 TEST_F(ProtoValueConversionsTest, AppSpecificsToValue) { |
130 TestSpecificsToValue(AppSpecificsToValue); | 130 TestSpecificsToValue(AppSpecificsToValue); |
131 } | 131 } |
132 | 132 |
| 133 TEST_F(ProtoValueConversionsTest, ArcPackageSpecificsToValue) { |
| 134 TestSpecificsToValue(ArcPackageSpecificsToValue); |
| 135 } |
| 136 |
133 TEST_F(ProtoValueConversionsTest, AutofillSpecificsToValue) { | 137 TEST_F(ProtoValueConversionsTest, AutofillSpecificsToValue) { |
134 TestSpecificsToValue(AutofillSpecificsToValue); | 138 TestSpecificsToValue(AutofillSpecificsToValue); |
135 } | 139 } |
136 | 140 |
137 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { | 141 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { |
138 TestSpecificsToValue(AutofillProfileSpecificsToValue); | 142 TestSpecificsToValue(AutofillProfileSpecificsToValue); |
139 } | 143 } |
140 | 144 |
141 TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { | 145 TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { |
142 TestSpecificsToValue(AutofillWalletSpecificsToValue); | 146 TestSpecificsToValue(AutofillWalletSpecificsToValue); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { | 299 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { |
296 sync_pb::EntitySpecifics specifics; | 300 sync_pb::EntitySpecifics specifics; |
297 // Touch the extensions to make sure it shows up in the generated | 301 // Touch the extensions to make sure it shows up in the generated |
298 // value. | 302 // value. |
299 #define SET_FIELD(key) (void)specifics.mutable_##key() | 303 #define SET_FIELD(key) (void)specifics.mutable_##key() |
300 | 304 |
301 SET_FIELD(app); | 305 SET_FIELD(app); |
302 SET_FIELD(app_list); | 306 SET_FIELD(app_list); |
303 SET_FIELD(app_notification); | 307 SET_FIELD(app_notification); |
304 SET_FIELD(app_setting); | 308 SET_FIELD(app_setting); |
| 309 SET_FIELD(arc_package); |
305 SET_FIELD(article); | 310 SET_FIELD(article); |
306 SET_FIELD(autofill); | 311 SET_FIELD(autofill); |
307 SET_FIELD(autofill_profile); | 312 SET_FIELD(autofill_profile); |
308 SET_FIELD(bookmark); | 313 SET_FIELD(bookmark); |
309 SET_FIELD(device_info); | 314 SET_FIELD(device_info); |
310 SET_FIELD(dictionary); | 315 SET_FIELD(dictionary); |
311 SET_FIELD(experiments); | 316 SET_FIELD(experiments); |
312 SET_FIELD(extension); | 317 SET_FIELD(extension); |
313 SET_FIELD(extension_setting); | 318 SET_FIELD(extension_setting); |
314 SET_FIELD(favicon_image); | 319 SET_FIELD(favicon_image); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 407 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
403 "get_updates.entries")); | 408 "get_updates.entries")); |
404 } | 409 } |
405 | 410 |
406 TEST_F(ProtoValueConversionsTest, AttachmentIdProtoToValue) { | 411 TEST_F(ProtoValueConversionsTest, AttachmentIdProtoToValue) { |
407 TestSpecificsToValue(AttachmentIdProtoToValue); | 412 TestSpecificsToValue(AttachmentIdProtoToValue); |
408 } | 413 } |
409 | 414 |
410 } // namespace | 415 } // namespace |
411 } // namespace syncer | 416 } // namespace syncer |
OLD | NEW |