| 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/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_specifics.pb.h" |
| 24 #include "sync/protocol/nigori_specifics.pb.h" | 25 #include "sync/protocol/nigori_specifics.pb.h" |
| 25 #include "sync/protocol/password_specifics.pb.h" | 26 #include "sync/protocol/password_specifics.pb.h" |
| 26 #include "sync/protocol/preference_specifics.pb.h" | 27 #include "sync/protocol/preference_specifics.pb.h" |
| 27 #include "sync/protocol/priority_preference_specifics.pb.h" | 28 #include "sync/protocol/priority_preference_specifics.pb.h" |
| 28 #include "sync/protocol/search_engine_specifics.pb.h" | 29 #include "sync/protocol/search_engine_specifics.pb.h" |
| 29 #include "sync/protocol/session_specifics.pb.h" | 30 #include "sync/protocol/session_specifics.pb.h" |
| 30 #include "sync/protocol/sync.pb.h" | 31 #include "sync/protocol/sync.pb.h" |
| 31 #include "sync/protocol/theme_specifics.pb.h" | 32 #include "sync/protocol/theme_specifics.pb.h" |
| 32 #include "sync/protocol/typed_url_specifics.pb.h" | 33 #include "sync/protocol/typed_url_specifics.pb.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 193 } |
| 193 | 194 |
| 194 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { | 195 TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) { |
| 195 TestSpecificsToValue(TypedUrlSpecificsToValue); | 196 TestSpecificsToValue(TypedUrlSpecificsToValue); |
| 196 } | 197 } |
| 197 | 198 |
| 198 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) { | 199 TEST_F(ProtoValueConversionsTest, DictionarySpecificsToValue) { |
| 199 TestSpecificsToValue(DictionarySpecificsToValue); | 200 TestSpecificsToValue(DictionarySpecificsToValue); |
| 200 } | 201 } |
| 201 | 202 |
| 203 TEST_F(ProtoValueConversionsTest, FaviconSpecificsToValue) { |
| 204 TestSpecificsToValue(FaviconSpecificsToValue); |
| 205 } |
| 206 |
| 202 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. | 207 // TODO(akalin): Figure out how to better test EntitySpecificsToValue. |
| 203 | 208 |
| 204 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { | 209 TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { |
| 205 sync_pb::EntitySpecifics specifics; | 210 sync_pb::EntitySpecifics specifics; |
| 206 // Touch the extensions to make sure it shows up in the generated | 211 // Touch the extensions to make sure it shows up in the generated |
| 207 // value. | 212 // value. |
| 208 #define SET_FIELD(key) (void)specifics.mutable_##key() | 213 #define SET_FIELD(key) (void)specifics.mutable_##key() |
| 209 | 214 |
| 210 SET_FIELD(app); | 215 SET_FIELD(app); |
| 211 SET_FIELD(app_notification); | 216 SET_FIELD(app_notification); |
| 212 SET_FIELD(app_setting); | 217 SET_FIELD(app_setting); |
| 213 SET_FIELD(autofill); | 218 SET_FIELD(autofill); |
| 214 SET_FIELD(autofill_profile); | 219 SET_FIELD(autofill_profile); |
| 215 SET_FIELD(bookmark); | 220 SET_FIELD(bookmark); |
| 216 SET_FIELD(device_info); | 221 SET_FIELD(device_info); |
| 217 SET_FIELD(dictionary); | 222 SET_FIELD(dictionary); |
| 218 SET_FIELD(experiments); | 223 SET_FIELD(experiments); |
| 219 SET_FIELD(extension); | 224 SET_FIELD(extension); |
| 220 SET_FIELD(extension_setting); | 225 SET_FIELD(extension_setting); |
| 226 SET_FIELD(favicon); |
| 221 SET_FIELD(history_delete_directive); | 227 SET_FIELD(history_delete_directive); |
| 222 SET_FIELD(nigori); | 228 SET_FIELD(nigori); |
| 223 SET_FIELD(password); | 229 SET_FIELD(password); |
| 224 SET_FIELD(preference); | 230 SET_FIELD(preference); |
| 225 SET_FIELD(priority_preference); | 231 SET_FIELD(priority_preference); |
| 226 SET_FIELD(search_engine); | 232 SET_FIELD(search_engine); |
| 227 SET_FIELD(session); | 233 SET_FIELD(session); |
| 228 SET_FIELD(synced_notification); | 234 SET_FIELD(synced_notification); |
| 229 SET_FIELD(theme); | 235 SET_FIELD(theme); |
| 230 SET_FIELD(typed_url); | 236 SET_FIELD(typed_url); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 299 |
| 294 scoped_ptr<DictionaryValue> value_without_specifics( | 300 scoped_ptr<DictionaryValue> value_without_specifics( |
| 295 ClientToServerResponseToValue(message, false /* include_specifics */)); | 301 ClientToServerResponseToValue(message, false /* include_specifics */)); |
| 296 EXPECT_FALSE(value_without_specifics->empty()); | 302 EXPECT_FALSE(value_without_specifics->empty()); |
| 297 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), | 303 EXPECT_FALSE(ValueHasSpecifics(*(value_without_specifics.get()), |
| 298 "get_updates.entries")); | 304 "get_updates.entries")); |
| 299 } | 305 } |
| 300 | 306 |
| 301 } // namespace | 307 } // namespace |
| 302 } // namespace syncer | 308 } // namespace syncer |
| OLD | NEW |