| 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 #include "dbus/values_util.h" | 5 #include "dbus/values_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 sub_writer.OpenDictEntry(&entry_writer); | 331 sub_writer.OpenDictEntry(&entry_writer); |
| 332 const std::string kKey3 = "example."; // String ending with a dot. | 332 const std::string kKey3 = "example."; // String ending with a dot. |
| 333 entry_writer.AppendString(kKey3); | 333 entry_writer.AppendString(kKey3); |
| 334 const double kDoubleValue = 4.9; | 334 const double kDoubleValue = 4.9; |
| 335 entry_writer.AppendVariantOfDouble(kDoubleValue); | 335 entry_writer.AppendVariantOfDouble(kDoubleValue); |
| 336 sub_writer.CloseContainer(&entry_writer); | 336 sub_writer.CloseContainer(&entry_writer); |
| 337 writer.CloseContainer(&sub_writer); | 337 writer.CloseContainer(&sub_writer); |
| 338 | 338 |
| 339 // Create the expected value. | 339 // Create the expected value. |
| 340 base::DictionaryValue dictionary_value; | 340 base::DictionaryValue dictionary_value; |
| 341 dictionary_value.SetWithoutPathExpansion(kKey1, new base::Value(kBoolValue)); | 341 dictionary_value.SetBooleanWithoutPathExpansion(kKey1, kBoolValue); |
| 342 dictionary_value.SetWithoutPathExpansion(kKey2, new base::Value(kInt32Value)); | 342 dictionary_value.SetIntegerWithoutPathExpansion(kKey2, kInt32Value); |
| 343 dictionary_value.SetWithoutPathExpansion(kKey3, | 343 dictionary_value.SetDoubleWithoutPathExpansion(kKey3, kDoubleValue); |
| 344 new base::Value(kDoubleValue)); | |
| 345 | 344 |
| 346 // Pop a dictinoary. | 345 // Pop a dictinoary. |
| 347 MessageReader reader(response.get()); | 346 MessageReader reader(response.get()); |
| 348 std::unique_ptr<base::Value> value(PopDataAsValue(&reader)); | 347 std::unique_ptr<base::Value> value(PopDataAsValue(&reader)); |
| 349 ASSERT_TRUE(value.get() != NULL); | 348 ASSERT_TRUE(value.get() != NULL); |
| 350 EXPECT_TRUE(value->Equals(&dictionary_value)); | 349 EXPECT_TRUE(value->Equals(&dictionary_value)); |
| 351 } | 350 } |
| 352 | 351 |
| 353 TEST(ValuesUtilTest, PopDoubleToIntDictionary) { | 352 TEST(ValuesUtilTest, PopDoubleToIntDictionary) { |
| 354 // Create test data. | 353 // Create test data. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 std::unique_ptr<base::Value> value; | 678 std::unique_ptr<base::Value> value; |
| 680 value = PopDataAsValue(&reader); | 679 value = PopDataAsValue(&reader); |
| 681 ASSERT_TRUE(value.get() != NULL); | 680 ASSERT_TRUE(value.get() != NULL); |
| 682 EXPECT_TRUE(value->Equals(&test_list)); | 681 EXPECT_TRUE(value->Equals(&test_list)); |
| 683 value = PopDataAsValue(&reader); | 682 value = PopDataAsValue(&reader); |
| 684 ASSERT_TRUE(value.get() != NULL); | 683 ASSERT_TRUE(value.get() != NULL); |
| 685 EXPECT_TRUE(value->Equals(&int_value)); | 684 EXPECT_TRUE(value->Equals(&int_value)); |
| 686 } | 685 } |
| 687 | 686 |
| 688 } // namespace dbus | 687 } // namespace dbus |
| OLD | NEW |