blob: 2194cde1d86e3cb86e08112bfaae5a8ca1aea35d [file] [log] [blame]
[email protected]f573ed6b2012-02-10 15:58:521// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]bb36d822011-09-30 20:55:092// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]7d855a12012-06-04 06:08:095#include "content/public/test/test_launcher.h"
[email protected]bb36d822011-09-30 20:55:096
[email protected]c1f87b22011-10-05 21:59:337#include "base/base_paths.h"
[email protected]bb36d822011-09-30 20:55:098#include "base/command_line.h"
9#include "base/logging.h"
[email protected]c1f87b22011-10-05 21:59:3310#include "base/path_service.h"
[email protected]bb36d822011-09-30 20:55:0911#include "base/scoped_temp_dir.h"
[email protected]c1f87b22011-10-05 21:59:3312#include "base/test/test_suite.h"
[email protected]f573ed6b2012-02-10 15:58:5213#include "content/public/app/content_main.h"
[email protected]c08950d22011-10-13 22:20:2914#include "content/public/common/content_switches.h"
[email protected]c1f87b22011-10-05 21:59:3315#include "content/shell/shell_main_delegate.h"
16
17#if defined(OS_WIN)
[email protected]badf5cf2011-10-29 03:44:4418#include "content/public/app/startup_helper_win.h"
[email protected]181491782012-07-18 00:59:1519#include "sandbox/win/src/sandbox_types.h"
[email protected]c1f87b22011-10-05 21:59:3320#endif // defined(OS_WIN)
[email protected]bb36d822011-09-30 20:55:0921
22class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate {
23 public:
24 ContentTestLauncherDelegate() {
25 }
26
27 virtual ~ContentTestLauncherDelegate() {
28 }
29
30 virtual void EarlyInitialize() OVERRIDE {
31 }
32
33 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE {
[email protected]c1f87b22011-10-05 21:59:3334#if defined(OS_WIN)
[email protected]bb36d822011-09-30 20:55:0935 CommandLine* command_line = CommandLine::ForCurrentProcess();
[email protected]c1f87b22011-10-05 21:59:3336 if (command_line->HasSwitch(switches::kProcessType)) {
37 sandbox::SandboxInterfaceInfo sandbox_info = {0};
38 content::InitializeSandboxInfo(&sandbox_info);
39 ShellMainDelegate delegate;
40 *return_code =
41 content::ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate);
[email protected]bb36d822011-09-30 20:55:0942 return true;
43 }
[email protected]c1f87b22011-10-05 21:59:3344#endif // defined(OS_WIN)
[email protected]bb36d822011-09-30 20:55:0945
46 return false;
47 }
48
[email protected]c1f87b22011-10-05 21:59:3349 virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
50 return base::TestSuite(argc, argv).Run();
51 }
52
[email protected]bb36d822011-09-30 20:55:0953 virtual bool AdjustChildProcessCommandLine(
54 CommandLine* command_line) OVERRIDE {
[email protected]c1f87b22011-10-05 21:59:3355 FilePath file_exe;
56 if (!PathService::Get(base::FILE_EXE, &file_exe))
57 return false;
58 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_exe);
[email protected]bb36d822011-09-30 20:55:0959 return true;
60 }
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate);
64};
65
66int main(int argc, char** argv) {
67 ContentTestLauncherDelegate launcher_delegate;
68 return test_launcher::LaunchTests(&launcher_delegate, argc, argv);
[email protected]76df8e362011-09-30 21:23:5869}