ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / test / render_thread_impl_browser_test_ipc_helper.cc
blob3075f753225d4e343b457dcfeb98b8a0cb1aea42
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 #include "content/test/render_thread_impl_browser_test_ipc_helper.h"
7 #include "content/common/mojo/channel_init.h"
8 #include "ipc/mojo/ipc_channel_mojo_host.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace content {
13 class RenderThreadImplBrowserIPCTestHelper::DummyListener
14 : public IPC::Listener {
15 public:
16 bool OnMessageReceived(const IPC::Message& message) override { return true; }
19 RenderThreadImplBrowserIPCTestHelper::RenderThreadImplBrowserIPCTestHelper() {
20 message_loop_.reset(new base::MessageLoopForIO());
22 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("");
23 dummy_listener_.reset(new DummyListener());
25 SetupIpcThread();
27 if (IPC::ChannelMojo::ShouldBeUsed()) {
28 SetupMojo();
29 } else {
30 channel_ = IPC::ChannelProxy::Create(channel_id_, IPC::Channel::MODE_SERVER,
31 dummy_listener_.get(),
32 ipc_thread_->task_runner());
36 RenderThreadImplBrowserIPCTestHelper::~RenderThreadImplBrowserIPCTestHelper() {
39 void RenderThreadImplBrowserIPCTestHelper::SetupIpcThread() {
40 ipc_thread_.reset(new base::Thread("test_ipc_thread"));
41 base::Thread::Options options;
42 options.message_loop_type = base::MessageLoop::TYPE_IO;
43 ASSERT_TRUE(ipc_thread_->StartWithOptions(options));
44 ChannelInit::SetSingleProcessIOTaskRunner(ipc_thread_->task_runner());
47 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() {
48 InitializeMojo();
50 ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner()));
51 mojo_host_.reset(new IPC::ChannelMojoHost(ipc_thread_->task_runner()));
52 mojo_application_host_.reset(new MojoApplicationHost());
53 mojo_application_host_->OverrideIOTaskRunnerForTest(
54 ipc_thread_->task_runner());
56 channel_ = IPC::ChannelProxy::Create(
57 IPC::ChannelMojo::CreateServerFactory(mojo_host_->channel_delegate(),
58 channel_id_),
59 dummy_listener_.get(), ipc_thread_->task_runner());
61 mojo_application_host_->Init();
62 mojo_application_host_->Activate(channel_.get(),
63 base::GetCurrentProcessHandle());
64 mojo_host_->OnClientLaunched(base::GetCurrentProcessHandle());
67 } // namespace content