Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: ipc/mojo/ipc_mojo_bootstrap_unittest.cc

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build error Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/mojo/ipc_mojo_bootstrap.cc ('k') | ipc/mojo/ipc_mojo_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ipc/mojo/ipc_mojo_bootstrap.h"
6
7 #include "base/base_paths.h"
8 #include "base/files/file.h"
9 #include "base/message_loop/message_loop.h"
10 #include "ipc/ipc_test_base.h"
11
12 #if defined(OS_POSIX)
13 #include "base/file_descriptor_posix.h"
14 #endif
15
16 namespace {
17
18 class IPCMojoBootstrapTest : public IPCTestBase {
19 protected:
20 };
21
22 class TestingDelegate : public IPC::MojoBootstrap::Delegate {
23 public:
24 TestingDelegate() : passed_(false) {}
25
26 virtual void OnPipeAvailable(
27 mojo::embedder::ScopedPlatformHandle handle) OVERRIDE;
28 virtual void OnBootstrapError() OVERRIDE;
29
30 bool passed() const { return passed_; }
31
32 private:
33 bool passed_;
34 };
35
36 void TestingDelegate::OnPipeAvailable(
37 mojo::embedder::ScopedPlatformHandle handle) {
38 passed_ = true;
39 base::MessageLoop::current()->Quit();
40 }
41
42 void TestingDelegate::OnBootstrapError() {
43 base::MessageLoop::current()->Quit();
44 }
45
46 TEST_F(IPCMojoBootstrapTest, Connect) {
47 Init("IPCMojoBootstrapTestClient");
48
49 TestingDelegate delegate;
50 scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
51 GetTestChannelHandle(), IPC::Channel::MODE_SERVER, &delegate);
52
53 ASSERT_TRUE(bootstrap->Connect());
54 #if defined(OS_POSIX)
55 ASSERT_TRUE(StartClientWithFD(bootstrap->GetClientFileDescriptor()));
56 #else
57 ASSERT_TRUE(StartClient());
58 #endif
59 bootstrap->OnClientLaunched(client_process());
60
61 base::MessageLoop::current()->Run();
62
63 EXPECT_TRUE(delegate.passed());
64 EXPECT_TRUE(WaitForClientShutdown());
65 }
66
67 // A long running process that connects to us.
68 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCMojoBootstrapTestClient) {
69 base::MessageLoopForIO main_message_loop;
70
71 TestingDelegate delegate;
72 scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
73 IPCTestBase::GetChannelName("IPCMojoBootstrapTestClient"),
74 IPC::Channel::MODE_CLIENT,
75 &delegate);
76
77 bootstrap->Connect();
78
79 base::MessageLoop::current()->Run();
80
81 EXPECT_TRUE(delegate.passed());
82
83 return 0;
84 }
85
86 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_mojo_bootstrap.cc ('k') | ipc/mojo/ipc_mojo_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698