Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ipc / mojo / ipc_mojo_perftest.cc
blobdc96dd19a1448f11347acc769e6f372270a16f99
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 "base/run_loop.h"
7 #include "ipc/ipc_perftest_support.h"
8 #include "ipc/mojo/ipc_channel_mojo.h"
9 #include "ipc/mojo/ipc_channel_mojo_host.h"
10 #include "third_party/mojo/src/mojo/edk/embedder/test_embedder.h"
12 namespace {
14 // This is needed because we rely on //base/test:test_support_perf and
15 // it provides main() which doesn't have Mojo initialization. We need
16 // some way to call InitWithSimplePlatformSupport() only once before
17 // using Mojo.
18 struct MojoInitialier {
19 MojoInitialier() {
20 mojo::embedder::test::InitWithSimplePlatformSupport();
24 base::LazyInstance<MojoInitialier> g_mojo_initializer
25 = LAZY_INSTANCE_INITIALIZER;
27 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase {
28 public:
29 typedef IPC::test::IPCChannelPerfTestBase Super;
31 MojoChannelPerfTest();
33 void TearDown() override {
34 IPC::test::IPCChannelPerfTestBase::TearDown();
37 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
38 const IPC::ChannelHandle& handle,
39 base::SequencedTaskRunner* runner) override {
40 host_.reset(new IPC::ChannelMojoHost(runner));
41 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
42 runner, handle);
45 bool DidStartClient() override {
46 bool ok = IPCTestBase::DidStartClient();
47 DCHECK(ok);
48 host_->OnClientLaunched(client_process().Handle());
49 return ok;
52 private:
53 scoped_ptr<IPC::ChannelMojoHost> host_;
56 MojoChannelPerfTest::MojoChannelPerfTest() {
57 g_mojo_initializer.Get();
61 TEST_F(MojoChannelPerfTest, ChannelPingPong) {
62 RunTestChannelPingPong(GetDefaultTestParams());
64 base::RunLoop run_loop;
65 run_loop.RunUntilIdle();
68 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) {
69 RunTestChannelProxyPingPong(GetDefaultTestParams());
71 base::RunLoop run_loop;
72 run_loop.RunUntilIdle();
75 class MojoTestClient : public IPC::test::PingPongTestClient {
76 public:
77 typedef IPC::test::PingPongTestClient SuperType;
79 MojoTestClient();
81 scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override;
84 MojoTestClient::MojoTestClient() {
85 g_mojo_initializer.Get();
88 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel(
89 IPC::Listener* listener) {
90 return scoped_ptr<IPC::Channel>(IPC::ChannelMojo::Create(
91 NULL, task_runner(), IPCTestBase::GetChannelName("PerformanceClient"),
92 IPC::Channel::MODE_CLIENT, listener));
95 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) {
96 MojoTestClient client;
97 int rv = client.RunMain();
99 base::RunLoop run_loop;
100 run_loop.RunUntilIdle();
102 return rv;
105 } // namespace