summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 15:25:53 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 15:25:53 +0000
commit19d536f25ffa4e876c7af79b201c7330841b31ea (patch)
tree2f64619a8812920692bd3c7e69103727021e9d53 /chrome
parent6c4e6631acb0893ba00f035792e80942e2b00bd3 (diff)
downloadchromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.zip
chromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.tar.gz
chromium_src-19d536f25ffa4e876c7af79b201c7330841b31ea.tar.bz2
Cleanup in base. This moves the implementation (and a bunch of header file
dependencies) from the multiprocess test and the test_suite headers to .cc files. Moves multiprocess_test to the test directory, and all of this stuff to the existing base_test_support project. I also used the base namespace. Previously other projects included this functionality just by #include because it was all inline, so I had to add dependencies on base_test_support in a few places. Moves and renames the command line switch this was using to base_switches. Move the base switch for process type to chrome switches. TEST=none BUG=none Review URL: http://codereview.chromium.org/3026055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad_win.cc1
-rw-r--r--chrome/chrome_installer.gypi3
-rw-r--r--chrome/common/chrome_switches.cc4
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/process_watcher_unittest.cc9
-rw-r--r--chrome/common/sandbox_mac_unittest_helper.h4
-rw-r--r--chrome/common/sandbox_mac_unittest_helper.mm7
-rw-r--r--chrome/renderer/renderer_main_unittest.cc8
-rw-r--r--chrome/test/mini_installer_test/run_all_unittests.cc3
-rw-r--r--chrome/test/perf/perftests.cc2
-rw-r--r--chrome/test/test_launcher/out_of_proc_test_runner.cc2
-rw-r--r--chrome/test/test_launcher/test_runner.cc2
-rw-r--r--chrome/test/unit/chrome_test_suite.h11
13 files changed, 38 insertions, 19 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index a21f5b5..c3a9533 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -22,6 +22,7 @@
#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/child_process_logging.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/result_codes.h"
#include "chrome/common/policy_constants.h"
diff --git a/chrome/chrome_installer.gypi b/chrome/chrome_installer.gypi
index d3d7046..aab12c5 100644
--- a/chrome/chrome_installer.gypi
+++ b/chrome/chrome_installer.gypi
@@ -66,6 +66,7 @@
'installer_util_strings',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n',
+ '<(DEPTH)/base/base.gyp:test_support_base',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
@@ -144,6 +145,7 @@
'installer_util',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n',
+ '<(DEPTH)/base/base.gyp:test_support_base',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
'include_dirs': [
@@ -293,6 +295,7 @@
'installer_util',
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/base/base.gyp:base_i18n',
+ '<(DEPTH)/base/base.gyp:test_support_base',
'<(DEPTH)/build/temp_gyp/googleurl.gyp:googleurl',
'<(DEPTH)/testing/gtest.gyp:gtest',
],
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 32cbdca..4deba43 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -752,6 +752,10 @@ const char kProcessPerSite[] = "process-per-site";
// script connections to each other).
const char kProcessPerTab[] = "process-per-tab";
+// The value of this switch determines whether the process is started as a
+// renderer or plugin host. If it's empty, it's the browser.
+const char kProcessType[] = "type";
+
// Output the product version information and quit. Used as an internal api to
// detect the installed version of Chrome on Linux.
const char kProductVersion[] = "product-version";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 0db5f99..4767574 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -220,6 +220,7 @@ extern const char kPrelaunchGpuProcess[];
extern const char kPrint[];
extern const char kProcessPerSite[];
extern const char kProcessPerTab[];
+extern const char kProcessType[];
extern const char kProductVersion[];
extern const char kProfileImportProcess[];
extern const char kProxyAutoDetect[];
diff --git a/chrome/common/process_watcher_unittest.cc b/chrome/common/process_watcher_unittest.cc
index 159ebb59..9bde1ac 100644
--- a/chrome/common/process_watcher_unittest.cc
+++ b/chrome/common/process_watcher_unittest.cc
@@ -8,11 +8,12 @@
#include <sys/wait.h>
#include "base/eintr_wrapper.h"
-#include "base/multiprocess_test.h"
#include "base/process_util.h"
+#include "base/test/multiprocess_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/multiprocess_func_list.h"
-class ProcessWatcherTest : public MultiProcessTest {
+class ProcessWatcherTest : public base::MultiProcessTest {
};
namespace {
@@ -29,7 +30,7 @@ bool IsProcessDead(base::ProcessHandle child) {
TEST_F(ProcessWatcherTest, DelayedTermination) {
base::ProcessHandle child_process =
- SpawnChild("process_watcher_test_never_die");
+ SpawnChild("process_watcher_test_never_die", false);
ProcessWatcher::EnsureProcessTerminated(child_process);
base::WaitForSingleProcess(child_process, 5000);
@@ -47,7 +48,7 @@ MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) {
TEST_F(ProcessWatcherTest, ImmediateTermination) {
base::ProcessHandle child_process =
- SpawnChild("process_watcher_test_die_immediately");
+ SpawnChild("process_watcher_test_die_immediately", false);
// Give it time to die.
sleep(2);
ProcessWatcher::EnsureProcessTerminated(child_process);
diff --git a/chrome/common/sandbox_mac_unittest_helper.h b/chrome/common/sandbox_mac_unittest_helper.h
index 3006576..960a4cf 100644
--- a/chrome/common/sandbox_mac_unittest_helper.h
+++ b/chrome/common/sandbox_mac_unittest_helper.h
@@ -6,7 +6,7 @@
#define CHROME_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_
#pragma once
-#include "base/multiprocess_test.h"
+#include "base/test/multiprocess_test.h"
#include "chrome/common/sandbox_mac.h"
namespace sandboxtest {
@@ -43,7 +43,7 @@ namespace sandboxtest {
// Base test type with helper functions to spawn a subprocess that exercises
// a given test in the sandbox.
-class MacSandboxTest : public MultiProcessTest {
+class MacSandboxTest : public base::MultiProcessTest {
public:
// Runs a test specified by |test_name| in a sandbox of the type specified
// by |sandbox_type|. |test_data| is a custom string that a test can pass
diff --git a/chrome/common/sandbox_mac_unittest_helper.mm b/chrome/common/sandbox_mac_unittest_helper.mm
index 5ad7260..5b421c6 100644
--- a/chrome/common/sandbox_mac_unittest_helper.mm
+++ b/chrome/common/sandbox_mac_unittest_helper.mm
@@ -8,8 +8,12 @@ extern "C" {
#include <sandbox.h>
}
+#include <map>
+
+#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "chrome/common/sandbox_mac.h"
+#include "testing/multiprocess_func_list.h"
namespace {
@@ -71,7 +75,8 @@ bool MacSandboxTest::RunTestInSandbox(sandbox::SandboxProcessType sandbox_type,
if (test_data)
setenv(kTestDataKey, test_data, 1);
- base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner");
+ base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner",
+ false);
int code = -1;
if (!base::WaitForExitCode(child_process, &code)) {
LOG(WARNING) << "base::WaitForExitCode failed";
diff --git a/chrome/renderer/renderer_main_unittest.cc b/chrome/renderer/renderer_main_unittest.cc
index f329337..f30103c 100644
--- a/chrome/renderer/renderer_main_unittest.cc
+++ b/chrome/renderer/renderer_main_unittest.cc
@@ -1,15 +1,16 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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 "base/message_loop.h"
-#include "base/multiprocess_test.h"
#include "base/process_util.h"
+#include "base/test/multiprocess_test.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/main_function_params.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/multiprocess_func_list.h"
// TODO(port): Bring up this test this on other platforms.
#if defined(OS_POSIX)
@@ -22,9 +23,8 @@ extern int RendererMain(const MainFunctionParams& parameters);
// TODO(port): The IPC Channel tests have a class with extremely similar
// functionality, we should combine them.
-class RendererMainTest : public MultiProcessTest {
+class RendererMainTest : public base::MultiProcessTest {
protected:
-
// Create a new MessageLoopForIO For each test.
virtual void SetUp();
virtual void TearDown();
diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc
index 0549e1a..a0f6159 100644
--- a/chrome/test/mini_installer_test/run_all_unittests.cc
+++ b/chrome/test/mini_installer_test/run_all_unittests.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
+#include "base/process_util.h"
#include "base/test/test_suite.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/util_constants.h"
@@ -44,7 +45,7 @@ int main(int argc, char** argv) {
// with cleaning the system or make a backup before continuing.
CommandLine::Init(argc, argv);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- TestSuite test_suite = TestSuite(argc, argv);
+ base::TestSuite test_suite(argc, argv);
if (command_line.HasSwitch(switches::kInstallerTestClean)) {
printf("Current version of Chrome will be uninstalled "
"from all levels before proceeding with tests.\n");
diff --git a/chrome/test/perf/perftests.cc b/chrome/test/perf/perftests.cc
index 904d44e..dd00b65 100644
--- a/chrome/test/perf/perftests.cc
+++ b/chrome/test/perf/perftests.cc
@@ -7,7 +7,7 @@
#include "chrome/common/chrome_paths.cc"
int main(int argc, char **argv) {
- PerfTestSuite suite(argc, argv);
+ base::PerfTestSuite suite(argc, argv);
chrome::RegisterPathProvider();
MessageLoop main_message_loop;
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index eb4e172..290bec0 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -78,7 +78,7 @@ class OutOfProcTestRunner : public tests::TestRunner {
// Do not let the child ignore failures. We need to propagate the
// failure status back to the parent.
- new_cmd_line.AppendSwitch(kStrictFailureHandling);
+ new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling);
base::ProcessHandle process_handle;
if (!base::LaunchApp(new_cmd_line, false, false, &process_handle))
diff --git a/chrome/test/test_launcher/test_runner.cc b/chrome/test/test_launcher/test_runner.cc
index 1b75318..de448a36 100644
--- a/chrome/test/test_launcher/test_runner.cc
+++ b/chrome/test/test_launcher/test_runner.cc
@@ -237,7 +237,7 @@ bool RunTests(const TestRunnerFactory& test_runner_factory) {
++test_run_count;
if (!test_runner->RunTest(test_name.c_str())) {
failed_tests.push_back(test_name);
- bool ignore_failure = TestSuite::ShouldIgnoreFailure(*test_info);
+ bool ignore_failure = base::TestSuite::ShouldIgnoreFailure(*test_info);
printer.OnTestEnd(test_info->name(), test_case->name(), true, true,
ignore_failure,
(base::Time::Now() - start_time).InMillisecondsF());
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index b788879..1cdd90f 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -12,9 +12,11 @@
#include "app/app_paths.h"
#include "app/resource_bundle.h"
+#include "base/command_line.h"
#include "base/stats_table.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/process_util.h"
#include "base/ref_counted.h"
#include "base/scoped_nsautorelease_pool.h"
#include "base/test/test_suite.h"
@@ -28,6 +30,7 @@
#include "chrome/test/testing_browser_process.h"
#include "net/base/mock_host_resolver.h"
#include "net/base/net_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_MACOSX)
#include "base/mac_util.h"
@@ -81,10 +84,10 @@ class WarningHostResolverProc : public net::HostResolverProc {
}
};
-class ChromeTestSuite : public TestSuite {
+class ChromeTestSuite : public base::TestSuite {
public:
ChromeTestSuite(int argc, char** argv)
- : TestSuite(argc, argv),
+ : base::TestSuite(argc, argv),
stats_table_(NULL),
created_user_data_dir_(false) {
}
@@ -94,7 +97,7 @@ class ChromeTestSuite : public TestSuite {
virtual void Initialize() {
base::ScopedNSAutoreleasePool autorelease_pool;
- TestSuite::Initialize();
+ base::TestSuite::Initialize();
chrome::RegisterChromeSchemes();
host_resolver_proc_ = new WarningHostResolverProc();
@@ -172,7 +175,7 @@ class ChromeTestSuite : public TestSuite {
file_util::Delete(user_data_dir, true);
file_util::Delete(user_data_dir.DirName(), false);
}
- TestSuite::Shutdown();
+ base::TestSuite::Shutdown();
}
void SetBrowserDirectory(const FilePath& browser_dir) {