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

Unified Diff: services/service_manager/runner/host/child_process_host_unittest.cc

Issue 2576233002: Consolidating the mojo NativeRunner functionality. (Closed)
Patch Set: Merged mojo_runner_host_unittests in service_manager_unittests Created 4 years 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
Index: services/service_manager/runner/host/child_process_host_unittest.cc
diff --git a/services/service_manager/runner/host/child_process_host_unittest.cc b/services/service_manager/runner/host/child_process_host_unittest.cc
deleted file mode 100644
index ea3f5e27f983110b637e1ec9c9b749761672eb2a..0000000000000000000000000000000000000000
--- a/services/service_manager/runner/host/child_process_host_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// 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.
-
-// Note: This file also tests child_process.*.
-
-#include "services/service_manager/runner/host/child_process_host.h"
-
-#include <memory>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
-#include "base/path_service.h"
-#include "base/run_loop.h"
-#include "base/threading/thread.h"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/process_delegate.h"
-#include "services/service_manager/native_runner_delegate.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace service_manager {
-namespace {
-
-const char kTestServiceName[] = "host_test_service";
-
-const base::FilePath::CharType kPackagesPath[] = FILE_PATH_LITERAL("Packages");
-
-#if defined(OS_WIN)
-const base::FilePath::CharType kServiceExtension[] =
- FILE_PATH_LITERAL(".service.exe");
-#else
-const base::FilePath::CharType kServiceExtension[] =
- FILE_PATH_LITERAL(".service");
-#endif
-
-void ProcessReadyCallbackAdapater(const base::Closure& callback,
- base::ProcessId process_id) {
- callback.Run();
-}
-
-class ProcessDelegate : public mojo::edk::ProcessDelegate {
- public:
- ProcessDelegate() {}
- ~ProcessDelegate() override {}
-
- private:
- void OnShutdownComplete() override {}
- DISALLOW_COPY_AND_ASSIGN(ProcessDelegate);
-};
-
-class NativeRunnerDelegateImpl : public NativeRunnerDelegate {
- public:
- NativeRunnerDelegateImpl() {}
- ~NativeRunnerDelegateImpl() override {}
-
- size_t get_and_clear_adjust_count() {
- size_t count = 0;
- std::swap(count, adjust_count_);
- return count;
- }
-
- private:
- // NativeRunnerDelegate:
- void AdjustCommandLineArgumentsForTarget(
- const Identity& target,
- base::CommandLine* command_line) override {
- adjust_count_++;
- }
-
- size_t adjust_count_ = 0;
-
- DISALLOW_COPY_AND_ASSIGN(NativeRunnerDelegateImpl);
-};
-
-#if defined(OS_ANDROID)
-// TODO(qsr): Multiprocess service manager tests are not supported on android.
-#define MAYBE_StartJoin DISABLED_StartJoin
-#else
-#define MAYBE_StartJoin StartJoin
-#endif // defined(OS_ANDROID)
-TEST(ChildProcessHostTest, MAYBE_StartJoin) {
- base::FilePath service_manager_dir;
- PathService::Get(base::DIR_MODULE, &service_manager_dir);
- base::MessageLoop message_loop;
- scoped_refptr<base::SequencedWorkerPool> blocking_pool(
- new base::SequencedWorkerPool(3, "blocking_pool",
- base::TaskPriority::USER_VISIBLE));
-
- base::Thread io_thread("io_thread");
- base::Thread::Options options;
- options.message_loop_type = base::MessageLoop::TYPE_IO;
- io_thread.StartWithOptions(options);
-
- ProcessDelegate delegate;
- mojo::edk::InitIPCSupport(&delegate, io_thread.task_runner());
-
- base::FilePath test_service_path =
- base::FilePath(kPackagesPath).AppendASCII(kTestServiceName)
- .AppendASCII(kTestServiceName) .AddExtension(kServiceExtension);
-
- NativeRunnerDelegateImpl native_runner_delegate;
- ChildProcessHost child_process_host(blocking_pool.get(),
- &native_runner_delegate, false,
- Identity(), test_service_path);
- base::RunLoop run_loop;
- child_process_host.Start(
- Identity(),
- base::Bind(&ProcessReadyCallbackAdapater, run_loop.QuitClosure()),
- base::Bind(&base::DoNothing));
- run_loop.Run();
-
- child_process_host.Join();
- blocking_pool->Shutdown();
- mojo::edk::ShutdownIPCSupport();
- EXPECT_EQ(1u, native_runner_delegate.get_and_clear_adjust_count());
-}
-
-} // namespace
-} // namespace service_manager
« no previous file with comments | « services/service_manager/runner/host/child_process_host.cc ('k') | services/service_manager/runner/host/host_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698