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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const T& specifics(T::default_instance()); | 50 const T& specifics(T::default_instance()); |
51 scoped_ptr<base::DictionaryValue> value = specifics_to_value(specifics); | 51 scoped_ptr<base::DictionaryValue> value = specifics_to_value(specifics); |
52 // We can't do much but make sure that this doesn't crash. | 52 // We can't do much but make sure that this doesn't crash. |
53 } | 53 } |
54 }; | 54 }; |
55 | 55 |
56 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { | 56 TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { |
57 // If this number changes, that means we added or removed a data | 57 // If this number changes, that means we added or removed a data |
58 // type. Don't forget to add a unit test for {New | 58 // type. Don't forget to add a unit test for {New |
59 // type}SpecificsToValue below. | 59 // type}SpecificsToValue below. |
60 EXPECT_EQ(35, MODEL_TYPE_COUNT); | 60 EXPECT_EQ(36, MODEL_TYPE_COUNT); |
61 | 61 |
62 // We'd also like to check if we changed any field in our messages. | 62 // We'd also like to check if we changed any field in our messages. |
63 // However, that's hard to do: sizeof could work, but it's | 63 // However, that's hard to do: sizeof could work, but it's |
64 // platform-dependent. default_instance().ByteSize() won't change | 64 // platform-dependent. default_instance().ByteSize() won't change |
65 // for most changes, since most of our fields are optional. So we | 65 // for most changes, since most of our fields are optional. So we |
66 // just settle for comments in the proto files. | 66 // just settle for comments in the proto files. |
67 } | 67 } |
68 | 68 |
69 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { | 69 TEST_F(ProtoValueConversionsTest, EncryptedDataToValue) { |
70 TestSpecificsToValue(EncryptedDataToValue); | 70 TestSpecificsToValue(EncryptedDataToValue); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 132 } |
133 | 133 |
134 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { | 134 TEST_F(ProtoValueConversionsTest, AutofillProfileSpecificsToValue) { |
135 TestSpecificsToValue(AutofillProfileSpecificsToValue); | 135 TestSpecificsToValue(AutofillProfileSpecificsToValue); |
136 } | 136 } |
137 | 137 |
138 TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { | 138 TEST_F(ProtoValueConversionsTest, AutofillWalletSpecificsToValue) { |
139 TestSpecificsToValue(AutofillWalletSpecificsToValue); | 139 TestSpecificsToValue(AutofillWalletSpecificsToValue); |
140 } | 140 } |
141 | 141 |
| 142 TEST_F(ProtoValueConversionsTest, WalletMetadataSpecificsToValue) { |
| 143 TestSpecificsToValue(WalletMetadataSpecificsToValue); |
| 144 } |
| 145 |
142 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) { | 146 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsToValue) { |
143 TestSpecificsToValue(BookmarkSpecificsToValue); | 147 TestSpecificsToValue(BookmarkSpecificsToValue); |
144 } | 148 } |
145 | 149 |
146 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsData) { | 150 TEST_F(ProtoValueConversionsTest, BookmarkSpecificsData) { |
147 const base::Time creation_time(base::Time::Now()); | 151 const base::Time creation_time(base::Time::Now()); |
148 const std::string icon_url = "http://www.google.com/favicon.ico"; | 152 const std::string icon_url = "http://www.google.com/favicon.ico"; |
149 sync_pb::BookmarkSpecifics specifics; | 153 sync_pb::BookmarkSpecifics specifics; |
150 specifics.set_creation_time_us(creation_time.ToInternalValue()); | 154 specifics.set_creation_time_us(creation_time.ToInternalValue()); |
151 specifics.set_icon_url(icon_url); | 155 specifics.set_icon_url(icon_url); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 SET_FIELD(priority_preference); | 320 SET_FIELD(priority_preference); |
317 SET_FIELD(search_engine); | 321 SET_FIELD(search_engine); |
318 SET_FIELD(session); | 322 SET_FIELD(session); |
319 SET_FIELD(synced_notification); | 323 SET_FIELD(synced_notification); |
320 SET_FIELD(synced_notification_app_info); | 324 SET_FIELD(synced_notification_app_info); |
321 SET_FIELD(theme); | 325 SET_FIELD(theme); |
322 SET_FIELD(typed_url); | 326 SET_FIELD(typed_url); |
323 SET_FIELD(wifi_credential); | 327 SET_FIELD(wifi_credential); |
324 | 328 |
325 SET_FIELD(autofill_wallet); | 329 SET_FIELD(autofill_wallet); |
| 330 SET_FIELD(wallet_metadata); |
326 | 331 |
327 #undef SET_FIELD | 332 #undef SET_FIELD |
328 | 333 |
329 scoped_ptr<base::DictionaryValue> value(EntitySpecificsToValue(specifics)); | 334 scoped_ptr<base::DictionaryValue> value(EntitySpecificsToValue(specifics)); |
330 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE - | 335 EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE - |
331 (LAST_PROXY_TYPE - FIRST_PROXY_TYPE + 1), | 336 (LAST_PROXY_TYPE - FIRST_PROXY_TYPE + 1), |
332 static_cast<int>(value->size())); | 337 static_cast<int>(value->size())); |
333 } | 338 } |
334 | 339 |
335 namespace { | 340 namespace { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 398 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
394 "get_updates.entries")); | 399 "get_updates.entries")); |
395 } | 400 } |
396 | 401 |
397 TEST_F(ProtoValueConversionsTest, AttachmentIdProtoToValue) { | 402 TEST_F(ProtoValueConversionsTest, AttachmentIdProtoToValue) { |
398 TestSpecificsToValue(AttachmentIdProtoToValue); | 403 TestSpecificsToValue(AttachmentIdProtoToValue); |
399 } | 404 } |
400 | 405 |
401 } // namespace | 406 } // namespace |
402 } // namespace syncer | 407 } // namespace syncer |
OLD | NEW |