summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 00:27:24 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 00:27:24 +0000
commit0f5c815c4ce3a1b970ae4b9a47f4a5001e5ec50c (patch)
tree0a360bad68bb39d8f87aa7f6136992946264a7d5 /chrome/browser
parent206743c88c222ed96d727da98e16ca19e2aac59e (diff)
downloadchromium_src-0f5c815c4ce3a1b970ae4b9a47f4a5001e5ec50c.zip
chromium_src-0f5c815c4ce3a1b970ae4b9a47f4a5001e5ec50c.tar.gz
chromium_src-0f5c815c4ce3a1b970ae4b9a47f4a5001e5ec50c.tar.bz2
Remove the utility process unit tests to simplify the utility process code a little (helpeful to make it use ChildProcessLauncher). Note that the test isn't needed anymore as a unit test because since it was written, there have been a couple of tests that exercise this code path through browser_tests. They use sandboxed utility processes so it's more equivalent to what the user experiences.
Review URL: http://codereview.chromium.org/402074 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/utility_process_host.cc5
-rw-r--r--chrome/browser/utility_process_host.h3
-rw-r--r--chrome/browser/utility_process_host_unittest.cc163
3 files changed, 1 insertions, 170 deletions
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index 1ba7068..35bc7f0 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -104,10 +104,7 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) {
base::ProcessHandle process;
#if defined(OS_WIN)
- if (!UseSandbox()) {
- // Don't use the sandbox during unit tests.
- base::LaunchApp(cmd_line, false, false, &process);
- } else if (exposed_dir.empty()) {
+ if (exposed_dir.empty()) {
process = sandbox::StartProcess(&cmd_line);
} else {
process = sandbox::StartProcessWithAccess(&cmd_line, exposed_dir);
diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h
index 773b515..f7f35e2 100644
--- a/chrome/browser/utility_process_host.h
+++ b/chrome/browser/utility_process_host.h
@@ -101,9 +101,6 @@ class UtilityProcessHost : public ChildProcessHost {
protected:
// Allow these methods to be overridden for tests.
virtual FilePath GetUtilityProcessCmd();
- virtual bool UseSandbox() {
- return true;
- }
private:
// Starts a process. Returns true iff it succeeded.
diff --git a/chrome/browser/utility_process_host_unittest.cc b/chrome/browser/utility_process_host_unittest.cc
deleted file mode 100644
index 44fb0f8..0000000
--- a/chrome/browser/utility_process_host_unittest.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) 2009 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 "chrome/browser/utility_process_host.h"
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/string_util.h"
-#include "build/build_config.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_service.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class UtilityProcessHostTest : public testing::Test {
- public:
- UtilityProcessHostTest()
- : ui_thread_(ChromeThread::UI, &message_loop_),
- io_thread_(ChromeThread::IO, &message_loop_) {
- }
-
- protected:
- MessageLoopForIO message_loop_;
- ChromeThread ui_thread_;
- ChromeThread io_thread_;
-};
-
-class TestUtilityProcessHostClient : public UtilityProcessHost::Client {
- public:
- explicit TestUtilityProcessHostClient() : success_(false) {
- }
-
- // UtilityProcessHost::Client methods.
- virtual void OnProcessCrashed() {
- NOTREACHED();
- }
-
- virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest,
- const DictionaryValue& catalogs) {
- success_ = true;
- }
-
- virtual void OnUnpackExtensionFailed(const std::string& error_message) {
- NOTREACHED();
- }
-
- virtual void OnUnpackWebResourceSucceeded(
- const ListValue& json_data) {
- NOTREACHED();
- }
-
- virtual void OnUnpackWebResourceFailed(
- const std::string& error_message) {
- NOTREACHED();
- }
-
- bool success() {
- return success_;
- }
-
- private:
- ~TestUtilityProcessHostClient() {}
-
- bool success_;
-};
-
-class TestUtilityProcessHost : public UtilityProcessHost {
- public:
- TestUtilityProcessHost(TestUtilityProcessHostClient* client,
- ResourceDispatcherHost* rdh)
- : UtilityProcessHost(rdh, client, ChromeThread::IO) {
- }
-
- protected:
- virtual FilePath GetUtilityProcessCmd() {
- FilePath exe_path;
- PathService::Get(base::DIR_EXE, &exe_path);
- exe_path = exe_path.Append(chrome::kHelperProcessExecutablePath);
- return exe_path;
- }
-
- virtual bool UseSandbox() {
- return false;
- }
-
- private:
-};
-
-class ProcessClosedObserver : public NotificationObserver {
- public:
- explicit ProcessClosedObserver(MessageLoop* message_loop)
- : message_loop_(message_loop) {
- registrar_.Add(this, NotificationType::CHILD_PROCESS_HOST_DISCONNECTED,
- NotificationService::AllSources());
- }
-
- void RunUntilClose(int child_id) {
- child_id_ = child_id;
- observed_ = false;
- message_loop_->Run();
- DCHECK(observed_);
- }
-
- private:
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK(type == NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
- ChildProcessInfo* info = Details<ChildProcessInfo>(details).ptr();
- if (info->id() == child_id_) {
- observed_ = true;
- message_loop_->Quit();
- }
- }
-
- MessageLoop* message_loop_;
- NotificationRegistrar registrar_;
- int child_id_;
- bool observed_;
-};
-
-#if !defined(OS_POSIX)
-// We should not run this on linux (crbug.com/22703) or MacOS (crbug.com/8102)
-// until problems related to autoupdate are fixed.
-TEST_F(UtilityProcessHostTest, ExtensionUnpacker) {
- // Copy the test extension into a temp dir and install from the temp dir.
- FilePath extension_file;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extension_file));
- extension_file = extension_file.AppendASCII("extensions")
- .AppendASCII("theme.crx");
- FilePath temp_extension_dir;
- ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_extension_dir));
- temp_extension_dir = temp_extension_dir.AppendASCII("extension_test");
- ASSERT_TRUE(file_util::CreateDirectory(temp_extension_dir));
- ASSERT_TRUE(file_util::CopyFile(extension_file,
- temp_extension_dir.AppendASCII("theme.crx")));
-
- scoped_refptr<TestUtilityProcessHostClient> client(
- new TestUtilityProcessHostClient());
- ResourceDispatcherHost rdh;
- TestUtilityProcessHost* process_host =
- new TestUtilityProcessHost(client.get(), &rdh);
- // process_host will delete itself when it's done.
- ProcessClosedObserver observer(&message_loop_);
- process_host->StartExtensionUnpacker(
- temp_extension_dir.AppendASCII("theme.crx"));
- observer.RunUntilClose(process_host->id());
- EXPECT_TRUE(client->success());
-
- // Clean up the temp dir.
- file_util::Delete(temp_extension_dir, true);
-}
-#endif
-
-} // namespace