Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: content/test/content_test_launcher.cc

Issue 8137012: Make an empty content browser test work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/content_test_launcher.cc
===================================================================
--- content/test/content_test_launcher.cc (revision 103728)
+++ content/test/content_test_launcher.cc (working copy)
@@ -4,11 +4,25 @@
#include "content/test/test_launcher.h"
+#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
-#include "content/test/content_test_suite.h"
+#include "base/test/test_suite.h"
+#include "content/app/content_main.h"
+#include "content/common/content_switches.h"
+#include "content/shell/shell_main_delegate.h"
+#if defined(OS_WIN)
+#include "base/base_switches.h"
+#include "content/app/startup_helper_win.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)
+
class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate {
public:
ContentTestLauncherDelegate() {
@@ -32,15 +46,44 @@
test_launcher::kSingleProcessTestsAndChromeFlag) ||
command_line->HasSwitch(test_launcher::kGTestListTestsFlag) ||
command_line->HasSwitch(test_launcher::kGTestHelpFlag)) {
- *return_code = ContentTestSuite(argc, argv).Run();
+#if defined(OS_WIN)
jam 2011/10/04 22:21:13 we shouldn't copy all this code from chrome_test_l
Paweł Hajdan Jr. 2011/10/04 23:19:48 Done.
+ if (command_line->HasSwitch(test_launcher::kSingleProcessTestsFlag)) {
+ // This is the browser process, so setup the sandbox broker.
+ sandbox::BrokerServices* broker_services =
+ sandbox::SandboxFactory::GetBrokerServices();
+ if (broker_services) {
+ sandbox::InitBrokerServices(broker_services);
+ // Precreate the desktop and window station used by the renderers.
+ sandbox::TargetPolicy* policy = broker_services->CreatePolicy();
+ sandbox::ResultCode result = policy->CreateAlternateDesktop(true);
+ CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result);
+ policy->Release();
+ }
+ }
+#endif
+ *return_code = base::TestSuite(argc, argv).Run();
return true;
}
+#if defined(OS_WIN)
+ if (command_line->HasSwitch(switches::kProcessType)) {
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ content::InitializeSandboxInfo(&sandbox_info);
+ ShellMainDelegate delegate;
+ *return_code = content::ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate);
+ return true;
+ }
+#endif // defined(OS_WIN)
+
return false;
}
virtual bool AdjustChildProcessCommandLine(
CommandLine* command_line) OVERRIDE {
+ FilePath file_exe;
+ if (!PathService::Get(base::FILE_EXE, &file_exe))
+ return false;
+ command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_exe);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698