| Index: content/public/test/test_launcher.cc
|
| diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc
|
| index 12244614a26945a2d2f217b8f961939bf498f0de..6bfff1700339327bf5a4382d0a1bce012298a02a 100644
|
| --- a/content/public/test/test_launcher.cc
|
| +++ b/content/public/test/test_launcher.cc
|
| @@ -22,7 +22,10 @@
|
| #include "base/test/test_timeouts.h"
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| +#include "content/public/app/content_main.h"
|
| +#include "content/public/app/content_main_delegate.h"
|
| #include "content/public/app/startup_helper_win.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "content/public/common/sandbox_init.h"
|
| #include "content/public/test/browser_test.h"
|
| #include "net/base/escape.h"
|
| @@ -622,6 +625,10 @@ void PrintUsage() {
|
|
|
| } // namespace
|
|
|
| +// The following is kept for historical reasons (so people that are used to
|
| +// using it don't get surprised).
|
| +const char kChildProcessFlag[] = "child";
|
| +
|
| const char kGTestFilterFlag[] = "gtest_filter";
|
| const char kGTestHelpFlag[] = "gtest_help";
|
| const char kGTestListTestsFlag[] = "gtest_list_tests";
|
| @@ -629,23 +636,53 @@ const char kGTestRepeatFlag[] = "gtest_repeat";
|
| const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests";
|
| const char kGTestOutputFlag[] = "gtest_output";
|
|
|
| -const char kSingleProcessTestsFlag[] = "single_process";
|
| -const char kSingleProcessTestsAndChromeFlag[] = "single-process";
|
| +const char kHelpFlag[] = "help";
|
| +
|
| +const char kLaunchAsBrowser[] = "as-browser";
|
|
|
| // See kManualTestPrefix above.
|
| const char kRunManualTestsFlag[] = "run-manual";
|
|
|
| -// The following is kept for historical reasons (so people that are used to
|
| -// using it don't get surprised).
|
| -const char kChildProcessFlag[] = "child";
|
| -
|
| -const char kHelpFlag[] = "help";
|
| +const char kSingleProcessTestsFlag[] = "single_process";
|
| +const char kSingleProcessTestsAndChromeFlag[] = "single-process";
|
|
|
| const char kWarmupFlag[] = "warmup";
|
|
|
| +
|
| TestLauncherDelegate::~TestLauncherDelegate() {
|
| }
|
|
|
| +bool ShouldRunContentMain() {
|
| +#if defined(OS_WIN) || defined(OS_LINUX)
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + return command_line->HasSwitch(switches::kProcessType) ||
|
| + command_line->HasSwitch(kLaunchAsBrowser);
|
| +#else
|
| + return false;
|
| +#endif // defined(OS_WIN) || defined(OS_LINUX)
|
| +}
|
| +
|
| +int RunContentMain(int argc, char** argv,
|
| + TestLauncherDelegate* launcher_delegate) {
|
| +#if defined(OS_WIN)
|
| + sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
| + content::InitializeSandboxInfo(&sandbox_info);
|
| + scoped_ptr<content::ContentMainDelegate> chrome_main_delegate(
|
| + launcher_delegate->CreateContentMainDelegate());
|
| + return content::ContentMain(GetModuleHandle(NULL),
|
| + &sandbox_info,
|
| + chrome_main_delegate.get());
|
| +#elif defined(OS_LINUX)
|
| + scoped_ptr<content::ContentMainDelegate> chrome_main_delegate(
|
| + launcher_delegate->CreateContentMainDelegate());
|
| + return content::ContentMain(argc,
|
| + const_cast<const char**>(argv),
|
| + chrome_main_delegate.get());
|
| +#endif // defined(OS_WIN)
|
| + NOTREACHED();
|
| + return 0;
|
| +}
|
| +
|
| int LaunchTests(TestLauncherDelegate* launcher_delegate,
|
| int argc,
|
| char** argv) {
|
| @@ -678,9 +715,8 @@ int LaunchTests(TestLauncherDelegate* launcher_delegate,
|
| return launcher_delegate->RunTestSuite(argc, argv);
|
| }
|
|
|
| - int return_code = 0;
|
| - if (launcher_delegate->Run(argc, argv, &return_code))
|
| - return return_code;
|
| + if (ShouldRunContentMain())
|
| + return RunContentMain(argc, argv, launcher_delegate);
|
|
|
| base::AtExitManager at_exit;
|
|
|
|
|