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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Use this to send IPC messages (when you don't care if you're using a | 99 // Use this to send IPC messages (when you don't care if you're using a |
100 // channel or a proxy). | 100 // channel or a proxy). |
101 IPC::Sender* sender() { | 101 IPC::Sender* sender() { |
102 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : | 102 return channel_.get() ? static_cast<IPC::Sender*>(channel_.get()) : |
103 static_cast<IPC::Sender*>(channel_proxy_.get()); | 103 static_cast<IPC::Sender*>(channel_proxy_.get()); |
104 } | 104 } |
105 | 105 |
106 IPC::Channel* channel() { return channel_.get(); } | 106 IPC::Channel* channel() { return channel_.get(); } |
107 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } | 107 IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); } |
| 108 void set_channel_proxy(std::unique_ptr<IPC::ChannelProxy> proxy) { |
| 109 DCHECK(!channel_proxy_); |
| 110 channel_proxy_.swap(proxy); |
| 111 } |
108 | 112 |
109 const base::Process& client_process() const { return client_process_; } | 113 const base::Process& client_process() const { return client_process_; } |
110 scoped_refptr<base::SequencedTaskRunner> task_runner(); | 114 scoped_refptr<base::SequencedTaskRunner> task_runner(); |
111 | 115 |
112 virtual std::unique_ptr<IPC::ChannelFactory> CreateChannelFactory( | 116 virtual std::unique_ptr<IPC::ChannelFactory> CreateChannelFactory( |
113 const IPC::ChannelHandle& handle, | 117 const IPC::ChannelHandle& handle, |
114 base::SequencedTaskRunner* runner); | 118 base::SequencedTaskRunner* runner); |
115 | 119 |
116 virtual bool DidStartClient(); | 120 virtual bool DidStartClient(); |
117 | 121 |
118 private: | 122 private: |
119 std::string GetTestMainName() const; | 123 std::string GetTestMainName() const; |
120 | 124 |
121 std::string test_client_name_; | 125 std::string test_client_name_; |
122 std::unique_ptr<base::MessageLoop> message_loop_; | 126 std::unique_ptr<base::MessageLoop> message_loop_; |
123 | 127 |
124 std::unique_ptr<IPC::Channel> channel_; | 128 std::unique_ptr<IPC::Channel> channel_; |
125 std::unique_ptr<IPC::ChannelProxy> channel_proxy_; | 129 std::unique_ptr<IPC::ChannelProxy> channel_proxy_; |
126 | 130 |
127 base::Process client_process_; | 131 base::Process client_process_; |
128 | 132 |
129 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); | 133 DISALLOW_COPY_AND_ASSIGN(IPCTestBase); |
130 }; | 134 }; |
131 | 135 |
132 // Use this to declare the client side for tests using IPCTestBase. | 136 // Use this to declare the client side for tests using IPCTestBase. |
133 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ | 137 #define MULTIPROCESS_IPC_TEST_CLIENT_MAIN(test_client_name) \ |
134 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) | 138 MULTIPROCESS_IPC_TEST_MAIN(test_client_name ## TestClientMain) |
135 | 139 |
136 #endif // IPC_IPC_TEST_BASE_H_ | 140 #endif // IPC_IPC_TEST_BASE_H_ |
OLD | NEW |