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..932ad8b3c7fa2cd9b507685d9466d33e25df9e55 100644 |
--- a/content/public/test/test_launcher.cc |
+++ b/content/public/test/test_launcher.cc |
@@ -22,8 +22,11 @@ |
#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/sandbox_init.h" |
+#include "content/public/common/content_switches.h" |
jam
2012/09/05 15:26:51
nit: order
phoglund_chromium
2012/09/06 08:45:28
Done.
|
#include "content/public/test/browser_test.h" |
#include "net/base/escape.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -643,9 +646,42 @@ const char kHelpFlag[] = "help"; |
const char kWarmupFlag[] = "warmup"; |
+const char kLaunchAsBrowser[] = "as-browser"; |
jam
2012/09/05 15:26:51
nit: order
phoglund_chromium
2012/09/06 08:45:28
Done. The other switches weren't in order so I sor
|
+ |
TestLauncherDelegate::~TestLauncherDelegate() { |
} |
+bool ShouldRunInBrowserMode() { |
jam
2012/09/05 15:26:51
nit: this isn't just for running in browser, it's
phoglund_chromium
2012/09/06 08:45:28
Ok, then maybe it should even be ShouldRunContentM
|
+#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 RunInBrowserMode(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 +714,9 @@ 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 (ShouldRunInBrowserMode()) { |
jam
2012/09/05 15:26:51
what's the point of splitting this into two functi
phoglund_chromium
2012/09/06 08:45:28
I thought the code read better like this. The sema
|
+ return RunInBrowserMode(argc, argv, launcher_delegate); |
+ } |
base::AtExitManager at_exit; |