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

Unified 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, 3 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_mojo_bootstrap_unittest.cc
diff --git a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..207c06036877a6a1578fc3a9172d1e78de0eee33
--- /dev/null
+++ b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
@@ -0,0 +1,86 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ipc/mojo/ipc_mojo_bootstrap.h"
+
+#include "base/base_paths.h"
+#include "base/files/file.h"
+#include "base/message_loop/message_loop.h"
+#include "ipc/ipc_test_base.h"
+
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
+namespace {
+
+class IPCMojoBootstrapTest : public IPCTestBase {
+ protected:
+};
+
+class TestingDelegate : public IPC::MojoBootstrap::Delegate {
+ public:
+ TestingDelegate() : passed_(false) {}
+
+ virtual void OnPipeAvailable(
+ mojo::embedder::ScopedPlatformHandle handle) OVERRIDE;
+ virtual void OnBootstrapError() OVERRIDE;
+
+ bool passed() const { return passed_; }
+
+ private:
+ bool passed_;
+};
+
+void TestingDelegate::OnPipeAvailable(
+ mojo::embedder::ScopedPlatformHandle handle) {
+ passed_ = true;
+ base::MessageLoop::current()->Quit();
+}
+
+void TestingDelegate::OnBootstrapError() {
+ base::MessageLoop::current()->Quit();
+}
+
+TEST_F(IPCMojoBootstrapTest, Connect) {
+ Init("IPCMojoBootstrapTestClient");
+
+ TestingDelegate delegate;
+ scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
+ GetTestChannelHandle(), IPC::Channel::MODE_SERVER, &delegate);
+
+ ASSERT_TRUE(bootstrap->Connect());
+#if defined(OS_POSIX)
+ ASSERT_TRUE(StartClientWithFD(bootstrap->GetClientFileDescriptor()));
+#else
+ ASSERT_TRUE(StartClient());
+#endif
+ bootstrap->OnClientLaunched(client_process());
+
+ base::MessageLoop::current()->Run();
+
+ EXPECT_TRUE(delegate.passed());
+ EXPECT_TRUE(WaitForClientShutdown());
+}
+
+// A long running process that connects to us.
+MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCMojoBootstrapTestClient) {
+ base::MessageLoopForIO main_message_loop;
+
+ TestingDelegate delegate;
+ scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
+ IPCTestBase::GetChannelName("IPCMojoBootstrapTestClient"),
+ IPC::Channel::MODE_CLIENT,
+ &delegate);
+
+ bootstrap->Connect();
+
+ base::MessageLoop::current()->Run();
+
+ EXPECT_TRUE(delegate.passed());
+
+ return 0;
+}
+
+} // namespace
« 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