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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/float_util.h" | 9 #include "base/float_util.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const int64 kInt64Value = -47; | 32 const int64 kInt64Value = -47; |
33 writer.AppendInt64(kInt64Value); | 33 writer.AppendInt64(kInt64Value); |
34 const uint64 kUint64Value = 48; | 34 const uint64 kUint64Value = 48; |
35 writer.AppendUint64(kUint64Value); | 35 writer.AppendUint64(kUint64Value); |
36 const double kDoubleValue = 4.9; | 36 const double kDoubleValue = 4.9; |
37 writer.AppendDouble(kDoubleValue); | 37 writer.AppendDouble(kDoubleValue); |
38 const std::string kStringValue = "fifty"; | 38 const std::string kStringValue = "fifty"; |
39 writer.AppendString(kStringValue); | 39 writer.AppendString(kStringValue); |
40 const std::string kEmptyStringValue; | 40 const std::string kEmptyStringValue; |
41 writer.AppendString(kEmptyStringValue); | 41 writer.AppendString(kEmptyStringValue); |
42 const dbus::ObjectPath kObjectPathValue("ObjectPath"); | 42 const dbus::ObjectPath kObjectPathValue("/ObjectPath"); |
43 writer.AppendObjectPath(kObjectPathValue); | 43 writer.AppendObjectPath(kObjectPathValue); |
44 | 44 |
45 dbus::MessageReader reader(response.get()); | 45 dbus::MessageReader reader(response.get()); |
46 scoped_ptr<Value> value; | 46 scoped_ptr<Value> value; |
47 scoped_ptr<Value> expected_value; | 47 scoped_ptr<Value> expected_value; |
48 // Pop a byte. | 48 // Pop a byte. |
49 value.reset(dbus::PopDataAsValue(&reader)); | 49 value.reset(dbus::PopDataAsValue(&reader)); |
50 ASSERT_TRUE(value.get() != NULL); | 50 ASSERT_TRUE(value.get() != NULL); |
51 expected_value.reset(Value::CreateIntegerValue(kByteValue)); | 51 expected_value.reset(Value::CreateIntegerValue(kByteValue)); |
52 EXPECT_TRUE(value->Equals(expected_value.get())); | 52 EXPECT_TRUE(value->Equals(expected_value.get())); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 value.reset(dbus::PopDataAsValue(&reader)); | 435 value.reset(dbus::PopDataAsValue(&reader)); |
436 ASSERT_TRUE(value.get() != NULL); | 436 ASSERT_TRUE(value.get() != NULL); |
437 EXPECT_TRUE(value->Equals(&kIntegerValue)); | 437 EXPECT_TRUE(value->Equals(&kIntegerValue)); |
438 value.reset(dbus::PopDataAsValue(&reader)); | 438 value.reset(dbus::PopDataAsValue(&reader)); |
439 ASSERT_TRUE(value.get() != NULL); | 439 ASSERT_TRUE(value.get() != NULL); |
440 EXPECT_TRUE(value->Equals(&kDoubleValue)); | 440 EXPECT_TRUE(value->Equals(&kDoubleValue)); |
441 value.reset(dbus::PopDataAsValue(&reader)); | 441 value.reset(dbus::PopDataAsValue(&reader)); |
442 ASSERT_TRUE(value.get() != NULL); | 442 ASSERT_TRUE(value.get() != NULL); |
443 EXPECT_TRUE(value->Equals(&kStringValue)); | 443 EXPECT_TRUE(value->Equals(&kStringValue)); |
444 } | 444 } |
OLD | NEW |