OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MOJO_EDK_TEST_MOJO_TEST_BASE_H_ | 5 #ifndef MOJO_EDK_TEST_MOJO_TEST_BASE_H_ |
6 #define MOJO_EDK_TEST_MOJO_TEST_BASE_H_ | 6 #define MOJO_EDK_TEST_MOJO_TEST_BASE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace mojo { | 23 namespace mojo { |
24 namespace edk { | 24 namespace edk { |
25 namespace test { | 25 namespace test { |
26 | 26 |
27 class MojoTestBase : public testing::Test { | 27 class MojoTestBase : public testing::Test { |
28 public: | 28 public: |
29 MojoTestBase(); | 29 MojoTestBase(); |
30 ~MojoTestBase() override; | 30 ~MojoTestBase() override; |
31 | 31 |
32 using LaunchType = MultiprocessTestHelper::LaunchType; | 32 using LaunchType = MultiprocessTestHelper::LaunchType; |
| 33 |
| 34 protected: |
33 using HandlerCallback = base::Callback<void(ScopedMessagePipeHandle)>; | 35 using HandlerCallback = base::Callback<void(ScopedMessagePipeHandle)>; |
34 | 36 |
35 class ClientController { | 37 class ClientController { |
36 public: | 38 public: |
37 ClientController(const std::string& client_name, | 39 ClientController(const std::string& client_name, |
38 MojoTestBase* test, | 40 MojoTestBase* test, |
39 const ProcessErrorCallback& process_error_callback, | 41 const ProcessErrorCallback& process_error_callback, |
40 LaunchType launch_type); | 42 LaunchType launch_type); |
41 ~ClientController(); | 43 ~ClientController(); |
42 | 44 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 static void CreateDataPipe(MojoHandle* producer, | 145 static void CreateDataPipe(MojoHandle* producer, |
144 MojoHandle* consumer, | 146 MojoHandle* consumer, |
145 size_t capacity); | 147 size_t capacity); |
146 | 148 |
147 // Writes data to a data pipe. | 149 // Writes data to a data pipe. |
148 static void WriteData(MojoHandle producer, const std::string& data); | 150 static void WriteData(MojoHandle producer, const std::string& data); |
149 | 151 |
150 // Reads data from a data pipe. | 152 // Reads data from a data pipe. |
151 static std::string ReadData(MojoHandle consumer, size_t size); | 153 static std::string ReadData(MojoHandle consumer, size_t size); |
152 | 154 |
153 // Queries the signals state of |handle|. | |
154 static MojoHandleSignalsState GetSignalsState(MojoHandle handle); | |
155 | |
156 // Helper to block the calling thread waiting for signals to be raised. | |
157 static MojoResult WaitForSignals(MojoHandle handle, | |
158 MojoHandleSignals signals, | |
159 MojoHandleSignalsState* state = nullptr); | |
160 | |
161 void set_launch_type(LaunchType launch_type) { launch_type_ = launch_type; } | 155 void set_launch_type(LaunchType launch_type) { launch_type_ = launch_type; } |
162 | 156 |
163 private: | 157 private: |
164 friend class ClientController; | 158 friend class ClientController; |
165 | 159 |
166 std::vector<std::unique_ptr<ClientController>> clients_; | 160 std::vector<std::unique_ptr<ClientController>> clients_; |
167 | 161 |
168 ProcessErrorCallback process_error_callback_; | 162 ProcessErrorCallback process_error_callback_; |
169 | 163 |
170 LaunchType launch_type_ = LaunchType::CHILD; | 164 LaunchType launch_type_ = LaunchType::CHILD; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 #else // !defined(OS_IOS) | 234 #else // !defined(OS_IOS) |
241 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name) | 235 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name) |
242 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name) | 236 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name) |
243 #endif // !defined(OS_IOS) | 237 #endif // !defined(OS_IOS) |
244 | 238 |
245 } // namespace test | 239 } // namespace test |
246 } // namespace edk | 240 } // namespace edk |
247 } // namespace mojo | 241 } // namespace mojo |
248 | 242 |
249 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_ | 243 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_ |
OLD | NEW |