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 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "ipc/ipc_channel_handle.h" | |
13 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace IPC { | 17 namespace IPC { |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Tests nesting of messages as parameters to other messages. | 20 // Tests nesting of messages as parameters to other messages. |
20 TEST(IPCMessageUtilsTest, NestedMessages) { | 21 TEST(IPCMessageUtilsTest, NestedMessages) { |
21 int32_t nested_routing = 12; | 22 int32_t nested_routing = 12; |
22 uint32_t nested_type = 78; | 23 uint32_t nested_type = 78; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 128 |
128 base::Pickle pickle; | 129 base::Pickle pickle; |
129 IPC::WriteParam(&pickle, value); | 130 IPC::WriteParam(&pickle, value); |
130 | 131 |
131 base::PickleSizer sizer; | 132 base::PickleSizer sizer; |
132 IPC::GetParamSize(&sizer, value); | 133 IPC::GetParamSize(&sizer, value); |
133 | 134 |
134 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); | 135 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); |
135 } | 136 } |
136 | 137 |
138 TEST(IPCMessageUtilsTest, MojoChannelHandle) { | |
139 mojo::MessagePipe message_pipe; | |
140 IPC::ChannelHandle channel_handle(message_pipe.handle0.release()); | |
141 | |
142 IPC::Message message; | |
143 IPC::WriteParam(&message, channel_handle); | |
144 | |
145 base::PickleSizer sizer; | |
146 IPC::GetParamSize(&sizer, channel_handle); | |
147 EXPECT_EQ(sizer.payload_size(), message.payload_size()); | |
148 | |
149 base::PickleIterator iter(message); | |
150 IPC::ChannelHandle result_handle; | |
151 EXPECT_TRUE(IPC::ReadParam(&message, &iter, &result_handle)); | |
152 EXPECT_TRUE(result_handle.name.empty()); | |
153 #if defined(OS_POSIX) | |
154 EXPECT_EQ(result_handle.socket.fd, -1); | |
dcheng
2016/06/27 01:55:32
EXPECT_EQ(expected, actual) is the convention, I t
Anand Mistry (off Chromium)
2016/06/27 02:40:43
Done.
Funnily enough, I've had a post-it note on
| |
155 #elif defined(OS_WIN) | |
156 EXPECT_TRUE(result_handle.pipe.handle == NULL); | |
dcheng
2016/06/27 01:55:32
EXPECT_EQ(nullptr, result_handle.pipe.handle)
Anand Mistry (off Chromium)
2016/06/27 02:40:43
Done. But note, the field is a HANDLE and I don't
| |
157 #endif | |
158 EXPECT_EQ(channel_handle.mojo_handle, result_handle.mojo_handle); | |
159 } | |
160 | |
137 } // namespace | 161 } // namespace |
138 } // namespace IPC | 162 } // namespace IPC |
OLD | NEW |