OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef IPC_IPC_TEST_BASE_H_ | 5 #ifndef IPC_IPC_TEST_BASE_H_ |
6 #define IPC_IPC_TEST_BASE_H_ | 6 #define IPC_IPC_TEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
13 #include "base/test/multiprocess_test.h" | 13 #include "base/test/multiprocess_test.h" |
14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_channel_factory.h" |
15 #include "ipc/ipc_channel_proxy.h" | 16 #include "ipc/ipc_channel_proxy.h" |
16 #include "ipc/ipc_multiprocess_test.h" | 17 #include "ipc/ipc_multiprocess_test.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class MessageLoop; | 20 class MessageLoop; |
20 } | 21 } |
21 | 22 |
22 // A test fixture for multiprocess IPC tests. Such tests include a "client" side | 23 // A test fixture for multiprocess IPC tests. Such tests include a "client" side |
23 // (running in a separate process). The same client may be shared between | 24 // (running in a separate process). The same client may be shared between |
24 // several different tests. | 25 // several different tests. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : | 89 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : |
89 static_cast<IPC::Sender*>(channel_proxy_.get()); | 90 static_cast<IPC::Sender*>(channel_proxy_.get()); |
90 } | 91 } |
91 | 92 |
92 IPC::Channel* channel() { return channel_.get(); } | 93 IPC::Channel* channel() { return channel_.get(); } |
93 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } | 94 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } |
94 | 95 |
95 const base::ProcessHandle& client_process() const { return client_process_; } | 96 const base::ProcessHandle& client_process() const { return client_process_; } |
96 scoped_refptr<base::TaskRunner> task_runner(); | 97 scoped_refptr<base::TaskRunner> task_runner(); |
97 | 98 |
| 99 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
| 100 const IPC::ChannelHandle& handle, base::TaskRunner* runner); |
| 101 |
98 private: | 102 private: |
99 std::string test_client_name_; | 103 std::string test_client_name_; |
100 scoped_ptr<base::MessageLoop> message_loop_; | 104 scoped_ptr<base::MessageLoop> message_loop_; |
101 | 105 |
102 scoped_ptr<IPC::Channel> channel_; | 106 scoped_ptr<IPC::Channel> channel_; |
103 scoped_ptr<IPC::ChannelProxy> channel_proxy_; | 107 scoped_ptr<IPC::ChannelProxy> channel_proxy_; |
104 | 108 |
105 base::ProcessHandle client_process_; | 109 base::ProcessHandle client_process_; |
106 | 110 |
107 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); | 111 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); |
108 }; | 112 }; |
109 | 113 |
110 // Use this to declare the client side for tests using IPCTestBase. | 114 // Use this to declare the client side for tests using IPCTestBase. |
111 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ | 115 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ |
112 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) | 116 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) |
113 | 117 |
114 #endif // IPC_IPC_TEST_BASE_H_ | 118 #endif // IPC_IPC_TEST_BASE_H_ |
OLD | NEW |