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: | |
35 using HandlerCallback = base::Callback<void(ScopedMessagePipeHandle)>; | 33 using HandlerCallback = base::Callback<void(ScopedMessagePipeHandle)>; |
36 | 34 |
37 class ClientController { | 35 class ClientController { |
38 public: | 36 public: |
39 ClientController(const std::string& client_name, | 37 ClientController(const std::string& client_name, |
40 MojoTestBase* test, | 38 MojoTestBase* test, |
41 const ProcessErrorCallback& process_error_callback, | 39 const ProcessErrorCallback& process_error_callback, |
42 LaunchType launch_type); | 40 LaunchType launch_type); |
43 ~ClientController(); | 41 ~ClientController(); |
44 | 42 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 static void CreateDataPipe(MojoHandle* producer, | 143 static void CreateDataPipe(MojoHandle* producer, |
146 MojoHandle* consumer, | 144 MojoHandle* consumer, |
147 size_t capacity); | 145 size_t capacity); |
148 | 146 |
149 // Writes data to a data pipe. | 147 // Writes data to a data pipe. |
150 static void WriteData(MojoHandle producer, const std::string& data); | 148 static void WriteData(MojoHandle producer, const std::string& data); |
151 | 149 |
152 // Reads data from a data pipe. | 150 // Reads data from a data pipe. |
153 static std::string ReadData(MojoHandle consumer, size_t size); | 151 static std::string ReadData(MojoHandle consumer, size_t size); |
154 | 152 |
| 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 |
155 void set_launch_type(LaunchType launch_type) { launch_type_ = launch_type; } | 161 void set_launch_type(LaunchType launch_type) { launch_type_ = launch_type; } |
156 | 162 |
157 private: | 163 private: |
158 friend class ClientController; | 164 friend class ClientController; |
159 | 165 |
160 std::vector<std::unique_ptr<ClientController>> clients_; | 166 std::vector<std::unique_ptr<ClientController>> clients_; |
161 | 167 |
162 ProcessErrorCallback process_error_callback_; | 168 ProcessErrorCallback process_error_callback_; |
163 | 169 |
164 LaunchType launch_type_ = LaunchType::CHILD; | 170 LaunchType launch_type_ = LaunchType::CHILD; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 #else // !defined(OS_IOS) | 240 #else // !defined(OS_IOS) |
235 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name) | 241 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name) |
236 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name) | 242 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name) |
237 #endif // !defined(OS_IOS) | 243 #endif // !defined(OS_IOS) |
238 | 244 |
239 } // namespace test | 245 } // namespace test |
240 } // namespace edk | 246 } // namespace edk |
241 } // namespace mojo | 247 } // namespace mojo |
242 | 248 |
243 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_ | 249 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_ |
OLD | NEW |