Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / system / message_pipe_test_utils.h
blob153ee425cd97d4609dc9d777e53861edd340b19e
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
3 // found in the LICENSE file.
5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_
6 #define MOJO_SYSTEM_MESSAGE_PIPE_TEST_UTILS_H_
8 #include "mojo/common/test/multiprocess_test_helper.h"
9 #include "mojo/embedder/simple_platform_support.h"
10 #include "mojo/system/channel.h"
11 #include "mojo/system/message_pipe.h"
12 #include "mojo/system/test_utils.h"
14 namespace mojo {
15 namespace system {
16 namespace test {
18 MojoResult WaitIfNecessary(scoped_refptr<MessagePipe> mp,
19 MojoHandleSignals signals,
20 HandleSignalsState* signals_state);
22 class ChannelThread {
23 public:
24 explicit ChannelThread(embedder::PlatformSupport* platform_support);
25 ~ChannelThread();
27 void Start(embedder::ScopedPlatformHandle platform_handle,
28 scoped_refptr<MessagePipe> message_pipe);
29 void Stop();
31 private:
32 void InitChannelOnIOThread(embedder::ScopedPlatformHandle platform_handle,
33 scoped_refptr<MessagePipe> message_pipe);
34 void ShutdownChannelOnIOThread();
36 embedder::PlatformSupport* const platform_support_;
37 TestIOThread test_io_thread_;
38 scoped_refptr<Channel> channel_;
40 DISALLOW_COPY_AND_ASSIGN(ChannelThread);
43 class MultiprocessMessagePipeTestBase : public testing::Test {
44 public:
45 MultiprocessMessagePipeTestBase();
46 virtual ~MultiprocessMessagePipeTestBase();
48 protected:
49 void Init(scoped_refptr<MessagePipe> mp);
51 embedder::PlatformSupport* platform_support() { return &platform_support_; }
52 mojo::test::MultiprocessTestHelper* helper() { return &helper_; }
54 private:
55 embedder::SimplePlatformSupport platform_support_;
56 ChannelThread channel_thread_;
57 mojo::test::MultiprocessTestHelper helper_;
59 DISALLOW_COPY_AND_ASSIGN(MultiprocessMessagePipeTestBase);
62 } // namespace test
63 } // namespace system
64 } // namespace mojo
66 #endif // MOJO_SYSTEM_MESSAGE_PIPE_TEST_HELPER_H_