| 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 "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 base::StackVector<double, stack_capacity> output; | 90 base::StackVector<double, stack_capacity> output; |
| 91 base::PickleIterator iter(msg); | 91 base::PickleIterator iter(msg); |
| 92 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); | 92 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); |
| 93 for (size_t i = 0; i < 2 * stack_capacity; i++) | 93 for (size_t i = 0; i < 2 * stack_capacity; i++) |
| 94 EXPECT_EQ(stack_vector[i], output[i]); | 94 EXPECT_EQ(stack_vector[i], output[i]); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Tests that PickleSizer and Pickle agree on the size of a complex base::Value. | 97 // Tests that PickleSizer and Pickle agree on the size of a complex base::Value. |
| 98 TEST(IPCMessageUtilsTest, ValueSize) { | 98 TEST(IPCMessageUtilsTest, ValueSize) { |
| 99 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 99 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
| 100 value->SetWithoutPathExpansion("foo", new base::FundamentalValue(42)); | 100 value->SetWithoutPathExpansion("foo", new base::Value(42)); |
| 101 value->SetWithoutPathExpansion("bar", new base::FundamentalValue(3.14)); | 101 value->SetWithoutPathExpansion("bar", new base::Value(3.14)); |
| 102 value->SetWithoutPathExpansion("baz", new base::StringValue("hello")); | 102 value->SetWithoutPathExpansion("baz", new base::StringValue("hello")); |
| 103 value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue()); | 103 value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue()); |
| 104 | 104 |
| 105 std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue); | 105 std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue); |
| 106 nested_dict->SetWithoutPathExpansion("foobar", new base::FundamentalValue(5)); | 106 nested_dict->SetWithoutPathExpansion("foobar", new base::Value(5)); |
| 107 value->SetWithoutPathExpansion("nested", std::move(nested_dict)); | 107 value->SetWithoutPathExpansion("nested", std::move(nested_dict)); |
| 108 | 108 |
| 109 std::unique_ptr<base::ListValue> list_value(new base::ListValue); | 109 std::unique_ptr<base::ListValue> list_value(new base::ListValue); |
| 110 list_value->AppendString("im a string"); | 110 list_value->AppendString("im a string"); |
| 111 list_value->AppendString("im another string"); | 111 list_value->AppendString("im another string"); |
| 112 value->SetWithoutPathExpansion("awesome-list", std::move(list_value)); | 112 value->SetWithoutPathExpansion("awesome-list", std::move(list_value)); |
| 113 | 113 |
| 114 base::Pickle pickle; | 114 base::Pickle pickle; |
| 115 IPC::WriteParam(&pickle, *value); | 115 IPC::WriteParam(&pickle, *value); |
| 116 | 116 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 EXPECT_EQ(token.ToString(), log); | 209 EXPECT_EQ(token.ToString(), log); |
| 210 | 210 |
| 211 base::UnguessableToken deserialized_token; | 211 base::UnguessableToken deserialized_token; |
| 212 base::PickleIterator iter(pickle); | 212 base::PickleIterator iter(pickle); |
| 213 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &deserialized_token)); | 213 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &deserialized_token)); |
| 214 EXPECT_EQ(token, deserialized_token); | 214 EXPECT_EQ(token, deserialized_token); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace | 217 } // namespace |
| 218 } // namespace IPC | 218 } // namespace IPC |
| OLD | NEW |