Chromium Code Reviews| Index: content/test/out_of_proc_test_runner.cc |
| =================================================================== |
| --- content/test/out_of_proc_test_runner.cc (revision 102172) |
| +++ content/test/out_of_proc_test_runner.cc (working copy) |
| @@ -21,26 +21,29 @@ |
| #include "base/test/test_timeouts.h" |
| #include "base/time.h" |
| #include "base/utf_string_conversions.h" |
| -#include "chrome/common/chrome_switches.h" |
| -#include "chrome/test/base/chrome_test_suite.h" |
| -#include "chrome/test/base/in_process_browser_test.h" |
| -#include "chrome/test/base/test_launcher_utils.h" |
| +#include "content/test/browser_test.h" |
|
sky
2011/09/27 15:31:52
Are these classes landing separately?
|
| +#include "content/test/browser_test_suite.h" |
| #include "net/base/escape.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #if defined(OS_WIN) |
| #include "base/base_switches.h" |
| -#include "chrome/common/chrome_constants.h" |
| #include "content/common/sandbox_policy.h" |
| #include "sandbox/src/dep.h" |
| #include "sandbox/src/sandbox_factory.h" |
| #include "sandbox/src/sandbox_types.h" |
| #endif // defined(OS_WIN) |
| +#if defined(BROWSER_TESTS_USE_CHROME) |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/common/chrome_constants.h" |
| + |
| #if defined(OS_MACOSX) |
| #include "chrome/browser/chrome_browser_application_mac.h" |
| #endif // defined(OS_MACOSX) |
| +#endif // defined(BROWSER_TESTS_USE_CHROME) |
| + |
| #if defined(OS_WIN) |
| // The entry point signature of chrome.dll. |
| typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*); |
| @@ -303,6 +306,28 @@ |
| } |
| } |
| +namespace { |
| + |
| +// A multiplier for slow tests. We generally avoid multiplying |
| +// test timeouts by any constants. Here it is used as last resort |
| +// to implement the SLOW_ test prefix. |
| +static const int kSlowTestTimeoutMultiplier = 5; |
| + |
| +} // namespace |
| + |
| +int GetTestTerminationTimeout(const std::string& test_name, |
| + int default_timeout_ms) { |
| + int timeout_ms = default_timeout_ms; |
| + |
| + // Make it possible for selected tests to request a longer timeout. |
| + // Generally tests should really avoid doing too much, and splitting |
| + // a test instead of using SLOW prefix is strongly preferred. |
| + if (test_name.find("SLOW_") != std::string::npos) |
| + timeout_ms *= kSlowTestTimeoutMultiplier; |
| + |
| + return timeout_ms; |
| +} |
| + |
| // Runs test specified by |test_name| in a child process, |
| // and returns the exit code. |
| int RunTest(const std::string& test_name, int default_timeout_ms) { |
| @@ -324,8 +349,10 @@ |
| // has been shut down and will actually crash). |
| switches.erase(kGTestRepeatFlag); |
| +#if defined(BROWSER_TESTS_USE_CHROME) |
| // Strip out user-data-dir if present. We will add it back in again later. |
| switches.erase(switches::kUserDataDir); |
| +#endif // defined(BROWSER_TESTS_USE_CHROME) |
| for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
| iter != switches.end(); ++iter) { |
| @@ -342,6 +369,7 @@ |
| // failure status back to the parent. |
| new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); |
| +#if defined(BROWSER_TESTS_USE_CHROME) |
| // Create a new user data dir and pass it to the child. |
| ScopedTempDir temp_dir; |
| if (!temp_dir.CreateUniqueTempDir() || !temp_dir.IsValid()) { |
| @@ -352,6 +380,7 @@ |
| // file:// access for ChromeOS. |
| new_cmd_line.AppendSwitch(switches::kAllowFileAccess); |
| +#endif // defined(BROWSER_TESTS_USE_CHROME) |
| const char* browser_wrapper = getenv("BROWSER_WRAPPER"); |
| if (browser_wrapper) { |
| @@ -378,9 +407,8 @@ |
| if (!base::LaunchProcess(new_cmd_line, options, &process_handle)) |
| return false; |
| - int timeout_ms = |
| - test_launcher_utils::GetTestTerminationTimeout(test_name, |
| - default_timeout_ms); |
| + int timeout_ms = GetTestTerminationTimeout(test_name, |
| + default_timeout_ms); |
| int exit_code = 0; |
| if (!base::WaitForExitCodeWithTimeout(process_handle, &exit_code, |
| @@ -576,10 +604,10 @@ |
| } |
| } |
| #endif |
| - return ChromeTestSuite(argc, argv).Run(); |
| + return BrowserTestSuite(argc, argv).Run(); |
| } |
| -#if defined(OS_WIN) |
| +#if defined(OS_WIN) && defined(BROWSER_TESTS_USE_CHROME) |
| if (command_line->HasSwitch(switches::kProcessType)) { |
| // This is a child process, call ChromeMain. |
| FilePath chrome_path(command_line->GetProgram().DirName()); |
| @@ -595,7 +623,7 @@ |
| sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices(); |
| return entry_point(GetModuleHandle(NULL), &sandbox_info, GetCommandLineW()); |
| } |
| -#endif |
| +#endif // defined(OS_WIN) && defined(BROWSER_TESTS_USE_CHROME) |
| int32 total_shards; |
| int32 shard_index; |