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.h" | 5 #include "ipc/ipc_message.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "ipc/ipc_message_utils.h" | 11 #include "ipc/ipc_message_utils.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
| 14 namespace { |
| 15 |
14 TEST(IPCMessageTest, ListValue) { | 16 TEST(IPCMessageTest, ListValue) { |
15 ListValue input; | 17 ListValue input; |
16 input.Set(0, Value::CreateDoubleValue(42.42)); | 18 input.Set(0, Value::CreateDoubleValue(42.42)); |
17 input.Set(1, Value::CreateStringValue("forty")); | 19 input.Set(1, Value::CreateStringValue("forty")); |
18 input.Set(2, Value::CreateNullValue()); | 20 input.Set(2, Value::CreateNullValue()); |
19 | 21 |
20 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 22 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
21 IPC::WriteParam(&msg, input); | 23 IPC::WriteParam(&msg, input); |
22 | 24 |
23 ListValue output; | 25 ListValue output; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); | 62 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); |
61 | 63 |
62 EXPECT_TRUE(input.Equals(&output)); | 64 EXPECT_TRUE(input.Equals(&output)); |
63 | 65 |
64 // Also test the corrupt case. | 66 // Also test the corrupt case. |
65 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 67 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
66 bad_msg.WriteInt(99); | 68 bad_msg.WriteInt(99); |
67 iter = PickleIterator(bad_msg); | 69 iter = PickleIterator(bad_msg); |
68 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); | 70 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); |
69 } | 71 } |
| 72 |
| 73 } // namespace |
OLD | NEW |