summaryrefslogtreecommitdiffstats
path: root/mojo/common
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 23:44:57 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 23:44:57 +0000
commit2f8f0c044fb4b4e715b0bf4d4e7148aa467b12de (patch)
tree63bad5b85985f3bdbc39d70a44d99891a9c976ed /mojo/common
parent1c0f34e2613ea5af8be7cf5618aee4e854463c1d (diff)
downloadchromium_src-2f8f0c044fb4b4e715b0bf4d4e7148aa467b12de.zip
chromium_src-2f8f0c044fb4b4e715b0bf4d4e7148aa467b12de.tar.gz
chromium_src-2f8f0c044fb4b4e715b0bf4d4e7148aa467b12de.tar.bz2
Mojo: (POSIX) Pass channel handle to child.
R=darin@chromium.org Review URL: https://codereview.chromium.org/103113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common')
-rw-r--r--mojo/common/test/multiprocess_test_base.cc29
-rw-r--r--mojo/common/test/multiprocess_test_base.h10
-rw-r--r--mojo/common/test/multiprocess_test_base_unittest.cc15
3 files changed, 40 insertions, 14 deletions
diff --git a/mojo/common/test/multiprocess_test_base.cc b/mojo/common/test/multiprocess_test_base.cc
index 85aaa76..e637e69 100644
--- a/mojo/common/test/multiprocess_test_base.cc
+++ b/mojo/common/test/multiprocess_test_base.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/process/process_handle.h"
+// TODO(vtl): Remove build_config.h include when fully implemented on Windows.
#include "build/build_config.h"
namespace mojo {
@@ -28,7 +29,7 @@ void MultiprocessTestBase::SetUp() {
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
- platform_server_channel_ =
+ platform_server_channel =
system::PlatformServerChannel::Create("TestChannel");
#endif
}
@@ -36,13 +37,13 @@ void MultiprocessTestBase::SetUp() {
void MultiprocessTestBase::TearDown() {
CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
- platform_server_channel_.reset();
+ platform_server_channel.reset();
MultiProcessTest::TearDown();
}
void MultiprocessTestBase::StartChild(const std::string& test_child_name) {
- CHECK(platform_server_channel_.get());
+ CHECK(platform_server_channel.get());
CHECK(!test_child_name.empty());
CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
@@ -51,7 +52,7 @@ void MultiprocessTestBase::StartChild(const std::string& test_child_name) {
#if defined(OS_POSIX)
CommandLine unused(CommandLine::NO_PROGRAM);
base::FileHandleMappingVector fds_to_map;
- platform_server_channel_->GetDataNeededToPassClientChannelToChildProcess(
+ platform_server_channel->GetDataNeededToPassClientChannelToChildProcess(
&unused, &fds_to_map);
test_child_handle_ = SpawnChild(test_child_main, fds_to_map, false);
#elif defined(OS_WIN)
@@ -61,7 +62,7 @@ void MultiprocessTestBase::StartChild(const std::string& test_child_name) {
#endif
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
- platform_server_channel_->ChildProcessLaunched();
+ platform_server_channel->ChildProcessLaunched();
#endif
CHECK_NE(test_child_handle_, base::kNullProcessHandle);
@@ -81,14 +82,14 @@ int MultiprocessTestBase::WaitForChildShutdown() {
CommandLine MultiprocessTestBase::MakeCmdLine(const std::string& procname,
bool debug_on_start) {
- CHECK(platform_server_channel_.get());
+ CHECK(platform_server_channel.get());
CommandLine command_line =
base::MultiProcessTest::MakeCmdLine(procname, debug_on_start);
// TODO(vtl): Not implemented on Windows yet.
#if defined(OS_POSIX)
base::FileHandleMappingVector unused;
- platform_server_channel_->GetDataNeededToPassClientChannelToChildProcess(
+ platform_server_channel->GetDataNeededToPassClientChannelToChildProcess(
&command_line, &unused);
#endif
return command_line;
@@ -96,9 +97,19 @@ CommandLine MultiprocessTestBase::MakeCmdLine(const std::string& procname,
// static
void MultiprocessTestBase::ChildSetup() {
- // TODO(vtl)
- NOTIMPLEMENTED();
+ CHECK(CommandLine::InitializedForCurrentProcess());
+// TODO(vtl): Not implemented on Windows yet.
+#if defined(OS_POSIX)
+ platform_client_channel =
+ system::PlatformClientChannel::CreateFromParentProcess(
+ *CommandLine::ForCurrentProcess());
+ CHECK(platform_client_channel.get());
+#endif
}
+// static
+scoped_ptr<system::PlatformClientChannel>
+ MultiprocessTestBase::platform_client_channel;
+
} // namespace test
} // namespace mojo
diff --git a/mojo/common/test/multiprocess_test_base.h b/mojo/common/test/multiprocess_test_base.h
index 08b66a3..c983df2 100644
--- a/mojo/common/test/multiprocess_test_base.h
+++ b/mojo/common/test/multiprocess_test_base.h
@@ -39,9 +39,11 @@ class MultiprocessTestBase : public base::MultiProcessTest {
// For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only:
static void ChildSetup();
- system::PlatformServerChannel* platform_server_channel() {
- return platform_server_channel_.get();
- }
+ // For use in the main process:
+ scoped_ptr<system::PlatformServerChannel> platform_server_channel;
+
+ // For use (and only valid) in the child process:
+ static scoped_ptr<system::PlatformClientChannel> platform_client_channel;
private:
virtual CommandLine MakeCmdLine(const std::string& procname,
@@ -50,8 +52,6 @@ class MultiprocessTestBase : public base::MultiProcessTest {
// Valid after |StartChild()| and before |WaitForChildShutdown()|.
base::ProcessHandle test_child_handle_;
- scoped_ptr<system::PlatformServerChannel> platform_server_channel_;
-
DISALLOW_COPY_AND_ASSIGN(MultiprocessTestBase);
};
diff --git a/mojo/common/test/multiprocess_test_base_unittest.cc b/mojo/common/test/multiprocess_test_base_unittest.cc
index 681d8bc4..be72bee 100644
--- a/mojo/common/test/multiprocess_test_base_unittest.cc
+++ b/mojo/common/test/multiprocess_test_base_unittest.cc
@@ -4,6 +4,10 @@
#include "mojo/common/test/multiprocess_test_base.h"
+#include "base/logging.h"
+// TODO(vtl): Remove build_config.h include when fully implemented on Windows.
+#include "build/build_config.h"
+
namespace mojo {
namespace {
@@ -11,11 +15,22 @@ class MultiprocessTestBaseTest : public test::MultiprocessTestBase {
};
TEST_F(MultiprocessTestBaseTest, RunChild) {
+// TODO(vtl): Not implemented on Windows yet.
+#if defined(OS_POSIX)
+ EXPECT_TRUE(platform_server_channel.get());
+ EXPECT_TRUE(platform_server_channel->is_valid());
+#endif
StartChild("RunChild");
EXPECT_EQ(123, WaitForChildShutdown());
}
MOJO_MULTIPROCESS_TEST_CHILD_MAIN(RunChild) {
+// TODO(vtl): Not implemented on Windows yet.
+#if defined(OS_POSIX)
+ CHECK(MultiprocessTestBaseTest::platform_client_channel.get());
+ CHECK(MultiprocessTestBaseTest::platform_client_channel->is_valid());
+ // TODO(vtl): Check the client channel.
+#endif
return 123;
}