| Index: ipc/ipc_test_base.cc
|
| diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc
|
| index 880e49555efe35fee6abcfd552bf512b92f77e89..8bc6bfc7c81e8e6bd29ce6895a9d62e3009e35d6 100644
|
| --- a/ipc/ipc_test_base.cc
|
| +++ b/ipc/ipc_test_base.cc
|
| @@ -9,10 +9,12 @@
|
| #include "base/command_line.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/process/kill.h"
|
| +#include "base/run_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread.h"
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| +#include "ipc/ipc_channel_mojo.h"
|
| #include "ipc/ipc_descriptors.h"
|
|
|
| #if defined(OS_POSIX)
|
| @@ -168,3 +170,59 @@ std::unique_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory(
|
| base::SingleThreadTaskRunner* runner) {
|
| return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER, runner);
|
| }
|
| +IPCChannelMojoTestBase::IPCChannelMojoTestBase() = default;
|
| +IPCChannelMojoTestBase::~IPCChannelMojoTestBase() = default;
|
| +
|
| +void IPCChannelMojoTestBase::Init(const std::string& test_client_name) {
|
| + handle_ = helper_.StartChild(test_client_name);
|
| +}
|
| +
|
| +bool IPCChannelMojoTestBase::WaitForClientShutdown() {
|
| + return helper_.WaitForChildTestShutdown();
|
| +}
|
| +
|
| +void IPCChannelMojoTestBase::TearDown() {
|
| + base::RunLoop().RunUntilIdle();
|
| +}
|
| +
|
| +void IPCChannelMojoTestBase::CreateChannel(IPC::Listener* listener) {
|
| + channel_ =
|
| + IPC::ChannelMojo::Create(TakeHandle(), IPC::Channel::MODE_SERVER,
|
| + listener, base::ThreadTaskRunnerHandle::Get());
|
| +}
|
| +
|
| +bool IPCChannelMojoTestBase::ConnectChannel() {
|
| + return channel_->Connect();
|
| +}
|
| +
|
| +void IPCChannelMojoTestBase::DestroyChannel() {
|
| + channel_.reset();
|
| +}
|
| +
|
| +mojo::ScopedMessagePipeHandle IPCChannelMojoTestBase::TakeHandle() {
|
| + return std::move(handle_);
|
| +}
|
| +
|
| +IpcChannelMojoTestClient::IpcChannelMojoTestClient() = default;
|
| +
|
| +IpcChannelMojoTestClient::~IpcChannelMojoTestClient() = default;
|
| +
|
| +void IpcChannelMojoTestClient::Init(mojo::ScopedMessagePipeHandle handle) {
|
| + handle_ = std::move(handle);
|
| +}
|
| +
|
| +void IpcChannelMojoTestClient::Connect(IPC::Listener* listener) {
|
| + channel_ =
|
| + IPC::ChannelMojo::Create(std::move(handle_), IPC::Channel::MODE_CLIENT,
|
| + listener, base::ThreadTaskRunnerHandle::Get());
|
| + CHECK(channel_->Connect());
|
| +}
|
| +
|
| +void IpcChannelMojoTestClient::Close() {
|
| + channel_->Close();
|
| +
|
| + base::RunLoop run_loop;
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| + run_loop.QuitClosure());
|
| + run_loop.Run();
|
| +}
|
|
|