Temporarily disable stack trace tests, pending investigation on XP bots
[chromium-blink-merge.git] / ipc / mojo / ipc_mojo_perftest.cc
blob7147cd07e7107a1fe07e65cd9447a4907abc9c0b
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 "base/lazy_instance.h"
6 #include "ipc/ipc_perftest_support.h"
7 #include "ipc/mojo/ipc_channel_mojo.h"
8 #include "ipc/mojo/ipc_channel_mojo_host.h"
9 #include "third_party/mojo/src/mojo/edk/embedder/test_embedder.h"
11 namespace {
13 // This is needed because we rely on //base/test:test_support_perf and
14 // it provides main() which doesn't have Mojo initialization. We need
15 // some way to call InitWithSimplePlatformSupport() only once before
16 // using Mojo.
17 struct MojoInitialier {
18 MojoInitialier() {
19 mojo::embedder::test::InitWithSimplePlatformSupport();
23 base::LazyInstance<MojoInitialier> g_mojo_initializer
24 = LAZY_INSTANCE_INITIALIZER;
26 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
27 public:
28 typedef IPC::test::IPCChannelPerfTestBase Super;
30 MojoChannelPerfTest();
32 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
33 const IPC::ChannelHandle& handle,
34 base::TaskRunner* runner) override {
35 host_.reset(new IPC::ChannelMojoHost(task_runner()));
36 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
37 handle);
40 bool DidStartClient() override {
41 bool ok = IPCTestBase::DidStartClient();
42 DCHECK(ok);
43 host_->OnClientLaunched(client_process().Handle());
44 return ok;
47 void set_io_thread_task_runner(base::TaskRunner* runner) {
48 io_thread_task_runner_ = runner;
51 private:
52 base::TaskRunner* io_thread_task_runner_;
53 scoped_ptr<IPC::ChannelMojoHost> host_;
56 MojoChannelPerfTest::MojoChannelPerfTest()
57 : io_thread_task_runner_() {
58 g_mojo_initializer.Get();
62 TEST_F(MojoChannelPerfTest, ChannelPingPong) {
63 RunTestChannelPingPong(GetDefaultTestParams());
66 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
67 RunTestChannelProxyPingPong(GetDefaultTestParams());
70 class MojoTestClient : public IPC::test::PingPongTestClient {
71 public:
72 typedef IPC::test::PingPongTestClient SuperType;
74 MojoTestClient();
76 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override;
79 MojoTestClient::MojoTestClient() {
80 g_mojo_initializer.Get();
83 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
84 IPC::Listener* listener) {
85 return scoped_ptr<IPC::Channel>(
86 IPC::ChannelMojo::Create(NULL,
87 IPCTestBase::GetChannelName("PerformanceClient"),
88 IPC::Channel::MODE_CLIENT,
89 listener));
92 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
93 MojoTestClient client;
94 return client.RunMain();
97 } // namespace