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

Side by Side Diff: ipc/ipc_mojo_bootstrap_unittest.cc

Issue 2173753002: Revert of Support early associated interface binding on ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-channel-ipc-task-runner
Patch Set: Created 4 years, 4 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/ipc_mojo_bootstrap.cc ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_mojo_bootstrap.h" 5 #include "ipc/ipc_mojo_bootstrap.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 17 matching lines...) Expand all
28 class IPCMojoBootstrapTest : public testing::Test { 28 class IPCMojoBootstrapTest : public testing::Test {
29 protected: 29 protected:
30 mojo::edk::test::MultiprocessTestHelper helper_; 30 mojo::edk::test::MultiprocessTestHelper helper_;
31 }; 31 };
32 32
33 class TestingDelegate : public IPC::MojoBootstrap::Delegate { 33 class TestingDelegate : public IPC::MojoBootstrap::Delegate {
34 public: 34 public:
35 explicit TestingDelegate(const base::Closure& quit_callback) 35 explicit TestingDelegate(const base::Closure& quit_callback)
36 : passed_(false), quit_callback_(quit_callback) {} 36 : passed_(false), quit_callback_(quit_callback) {}
37 37
38 void OnPipesAvailable( 38 void OnPipesAvailable(IPC::mojom::ChannelAssociatedPtrInfo send_channel,
39 IPC::mojom::ChannelAssociatedPtr sender, 39 IPC::mojom::ChannelAssociatedRequest receive_channel,
40 IPC::mojom::ChannelAssociatedRequest receiver) override; 40 int32_t peer_pid) override;
41 void OnBootstrapError() override;
41 42
42 bool passed() const { return passed_; } 43 bool passed() const { return passed_; }
43 44
44 private: 45 private:
45 bool passed_; 46 bool passed_;
46 const base::Closure quit_callback_; 47 const base::Closure quit_callback_;
47 }; 48 };
48 49
49 void TestingDelegate::OnPipesAvailable( 50 void TestingDelegate::OnPipesAvailable(
50 IPC::mojom::ChannelAssociatedPtr sender, 51 IPC::mojom::ChannelAssociatedPtrInfo send_channel,
51 IPC::mojom::ChannelAssociatedRequest receiver) { 52 IPC::mojom::ChannelAssociatedRequest receive_channel,
53 int32_t peer_pid) {
52 passed_ = true; 54 passed_ = true;
53 quit_callback_.Run(); 55 quit_callback_.Run();
54 } 56 }
55 57
58 void TestingDelegate::OnBootstrapError() {
59 quit_callback_.Run();
60 }
61
56 TEST_F(IPCMojoBootstrapTest, Connect) { 62 TEST_F(IPCMojoBootstrapTest, Connect) {
57 base::MessageLoop message_loop; 63 base::MessageLoop message_loop;
58 base::RunLoop run_loop; 64 base::RunLoop run_loop;
59 TestingDelegate delegate(run_loop.QuitClosure()); 65 TestingDelegate delegate(run_loop.QuitClosure());
60 std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create( 66 std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
61 helper_.StartChild("IPCMojoBootstrapTestClient"), 67 helper_.StartChild("IPCMojoBootstrapTestClient"),
62 IPC::Channel::MODE_SERVER, &delegate, 68 IPC::Channel::MODE_SERVER, &delegate);
63 base::ThreadTaskRunnerHandle::Get());
64 69
65 bootstrap->Connect(); 70 bootstrap->Connect();
66 run_loop.Run(); 71 run_loop.Run();
67 72
68 EXPECT_TRUE(delegate.passed()); 73 EXPECT_TRUE(delegate.passed());
69 EXPECT_TRUE(helper_.WaitForChildTestShutdown()); 74 EXPECT_TRUE(helper_.WaitForChildTestShutdown());
70 } 75 }
71 76
72 // A long running process that connects to us. 77 // A long running process that connects to us.
73 MULTIPROCESS_TEST_MAIN_WITH_SETUP( 78 MULTIPROCESS_TEST_MAIN_WITH_SETUP(
74 IPCMojoBootstrapTestClientTestChildMain, 79 IPCMojoBootstrapTestClientTestChildMain,
75 ::mojo::edk::test::MultiprocessTestHelper::ChildSetup) { 80 ::mojo::edk::test::MultiprocessTestHelper::ChildSetup) {
76 base::MessageLoop message_loop; 81 base::MessageLoop message_loop;
77 base::RunLoop run_loop; 82 base::RunLoop run_loop;
78 TestingDelegate delegate(run_loop.QuitClosure()); 83 TestingDelegate delegate(run_loop.QuitClosure());
79 std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create( 84 std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
80 mojo::edk::CreateChildMessagePipe( 85 mojo::edk::CreateChildMessagePipe(
81 mojo::edk::test::MultiprocessTestHelper::primordial_pipe_token), 86 mojo::edk::test::MultiprocessTestHelper::primordial_pipe_token),
82 IPC::Channel::MODE_CLIENT, &delegate, 87 IPC::Channel::MODE_CLIENT, &delegate);
83 base::ThreadTaskRunnerHandle::Get());
84 88
85 bootstrap->Connect(); 89 bootstrap->Connect();
86 90
87 run_loop.Run(); 91 run_loop.Run();
88 92
89 return delegate.passed() ? 0 : 1; 93 return delegate.passed() ? 0 : 1;
90 } 94 }
91 95
92 } // namespace 96 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_mojo_bootstrap.cc ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698