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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "ipc/ipc_channel.h" | 12 #include "ipc/ipc_channel.h" |
13 #include "ipc/ipc_channel_proxy.h" | 13 #include "ipc/ipc_channel_proxy.h" |
| 14 #include "ipc/ipc_multiprocess_test.h" |
14 #include "ipc/ipc_tests.h" | 15 #include "ipc/ipc_tests.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/multiprocess_func_list.h" | 17 #include "testing/multiprocess_func_list.h" |
17 | 18 |
18 // IPC messages for testing --------------------------------------------------- | 19 // IPC messages for testing --------------------------------------------------- |
19 | 20 |
20 #define IPC_MESSAGE_IMPL | 21 #define IPC_MESSAGE_IMPL |
21 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
22 | 23 |
23 #define IPC_MESSAGE_START TestMsgStart | 24 #define IPC_MESSAGE_START TestMsgStart |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (FUZZER_ROUTING_ID != last_msg_->routing_id()) | 240 if (FUZZER_ROUTING_ID != last_msg_->routing_id()) |
240 return false; | 241 return false; |
241 return (type_id == last_msg_->type()); | 242 return (type_id == last_msg_->type()); |
242 }; | 243 }; |
243 | 244 |
244 IPC::Message* last_msg_; | 245 IPC::Message* last_msg_; |
245 }; | 246 }; |
246 | 247 |
247 // Runs the fuzzing server child mode. Returns when the preset number | 248 // Runs the fuzzing server child mode. Returns when the preset number |
248 // of messages have been received. | 249 // of messages have been received. |
249 MULTIPROCESS_TEST_MAIN(RunFuzzServer) { | 250 MULTIPROCESS_IPC_TEST_MAIN(RunFuzzServer) { |
250 MessageLoopForIO main_message_loop; | 251 MessageLoopForIO main_message_loop; |
251 FuzzerServerListener listener; | 252 FuzzerServerListener listener; |
252 IPC::Channel chan(kFuzzerChannel, IPC::Channel::MODE_CLIENT, &listener); | 253 IPC::Channel chan(kFuzzerChannel, IPC::Channel::MODE_CLIENT, &listener); |
253 CHECK(chan.Connect()); | 254 CHECK(chan.Connect()); |
254 listener.Init(&chan); | 255 listener.Init(&chan); |
255 MessageLoop::current()->Run(); | 256 MessageLoop::current()->Run(); |
256 return 0; | 257 return 0; |
257 } | 258 } |
258 | 259 |
259 class IPCFuzzingTest : public IPCChannelTest { | 260 class IPCFuzzingTest : public IPCChannelTest { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID, | 408 msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID, |
408 IPC::Message::PRIORITY_NORMAL); | 409 IPC::Message::PRIORITY_NORMAL); |
409 msg->WriteInt(0x64); | 410 msg->WriteInt(0x64); |
410 msg->WriteInt(0x32); | 411 msg->WriteInt(0x32); |
411 EXPECT_FALSE(server.OnMessageReceived(*msg)); | 412 EXPECT_FALSE(server.OnMessageReceived(*msg)); |
412 delete msg; | 413 delete msg; |
413 | 414 |
414 EXPECT_EQ(0, server.unhandled_msgs()); | 415 EXPECT_EQ(0, server.unhandled_msgs()); |
415 #endif | 416 #endif |
416 } | 417 } |
OLD | NEW |