| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ |
| 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" |
| 8 #include "base/test/test_io_thread.h" | 9 #include "base/test/test_io_thread.h" |
| 9 #include "mojo/edk/embedder/simple_platform_support.h" | 10 #include "mojo/edk/embedder/simple_platform_support.h" |
| 10 #include "mojo/edk/system/channel.h" | |
| 11 #include "mojo/edk/system/test_utils.h" | 11 #include "mojo/edk/system/test_utils.h" |
| 12 #include "mojo/edk/test/multiprocess_test_helper.h" | 12 #include "mojo/edk/test/multiprocess_test_helper.h" |
| 13 #include "mojo/edk/test/scoped_ipc_support.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace system { | 17 namespace system { |
| 17 | 18 |
| 18 class Channel; | |
| 19 class ChannelEndpoint; | 19 class ChannelEndpoint; |
| 20 class MessagePipe; | 20 class MessagePipe; |
| 21 | 21 |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 MojoResult WaitIfNecessary(scoped_refptr<MessagePipe> mp, | |
| 25 MojoHandleSignals signals, | |
| 26 HandleSignalsState* signals_state); | |
| 27 | |
| 28 class ChannelThread { | |
| 29 public: | |
| 30 explicit ChannelThread(embedder::PlatformSupport* platform_support); | |
| 31 ~ChannelThread(); | |
| 32 | |
| 33 void Start(embedder::ScopedPlatformHandle platform_handle, | |
| 34 scoped_refptr<ChannelEndpoint> channel_endpoint); | |
| 35 void Stop(); | |
| 36 | |
| 37 private: | |
| 38 void InitChannelOnIOThread(embedder::ScopedPlatformHandle platform_handle, | |
| 39 scoped_refptr<ChannelEndpoint> channel_endpoint); | |
| 40 void ShutdownChannelOnIOThread(); | |
| 41 | |
| 42 embedder::PlatformSupport* const platform_support_; | |
| 43 base::TestIOThread test_io_thread_; | |
| 44 scoped_refptr<Channel> channel_; | |
| 45 | |
| 46 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelThread); | |
| 47 }; | |
| 48 | |
| 49 #if !defined(OS_IOS) | 24 #if !defined(OS_IOS) |
| 50 class MultiprocessMessagePipeTestBase : public testing::Test { | 25 class MultiprocessMessagePipeTestBase : public testing::Test { |
| 51 public: | 26 public: |
| 52 MultiprocessMessagePipeTestBase(); | 27 MultiprocessMessagePipeTestBase(); |
| 28 MultiprocessMessagePipeTestBase( |
| 29 base::MessageLoop::Type main_message_loop_type); |
| 53 ~MultiprocessMessagePipeTestBase() override; | 30 ~MultiprocessMessagePipeTestBase() override; |
| 54 | 31 |
| 55 protected: | 32 protected: |
| 56 void Init(scoped_refptr<ChannelEndpoint> ep); | |
| 57 | |
| 58 embedder::PlatformSupport* platform_support() { return &platform_support_; } | 33 embedder::PlatformSupport* platform_support() { return &platform_support_; } |
| 59 mojo::test::MultiprocessTestHelper* helper() { return &helper_; } | 34 mojo::test::MultiprocessTestHelper* helper() { return &helper_; } |
| 60 | 35 |
| 61 private: | 36 private: |
| 62 embedder::SimplePlatformSupport platform_support_; | 37 embedder::SimplePlatformSupport platform_support_; |
| 63 ChannelThread channel_thread_; | 38 base::MessageLoop message_loop_; |
| 39 base::TestIOThread test_io_thread_; |
| 40 mojo::test::ScopedIPCSupport ipc_support_; |
| 64 mojo::test::MultiprocessTestHelper helper_; | 41 mojo::test::MultiprocessTestHelper helper_; |
| 65 | 42 |
| 66 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessMessagePipeTestBase); | 43 MOJO_DISALLOW_COPY_AND_ASSIGN(MultiprocessMessagePipeTestBase); |
| 67 }; | 44 }; |
| 68 #endif | 45 #endif |
| 69 | 46 |
| 70 } // namespace test | 47 } // namespace test |
| 71 } // namespace system | 48 } // namespace system |
| 72 } // namespace mojo | 49 } // namespace mojo |
| 73 | 50 |
| 74 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ | 51 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_ |
| OLD | NEW |