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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/test_launcher.h" 5 #include "content/test/test_launcher.h"
6 6
7 #include "base/base_paths.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
10 #include "content/test/content_test_suite.h" 12 #include "base/test/test_suite.h"
13 #include "content/app/content_main.h"
14 #include "content/common/content_switches.h"
15 #include "content/shell/shell_main_delegate.h"
16
17 #if defined(OS_WIN)
18 #include "base/base_switches.h"
19 #include "content/app/startup_helper_win.h"
jam 2011/10/05 00:54:01 don't think you need all these includes
Paweł Hajdan Jr. 2011/10/05 18:34:27 Done.
20 #include "content/common/sandbox_policy.h"
21 #include "sandbox/src/dep.h"
22 #include "sandbox/src/sandbox_factory.h"
23 #include "sandbox/src/sandbox_types.h"
24 #endif // defined(OS_WIN)
11 25
12 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate { 26 class ContentTestLauncherDelegate : public test_launcher::TestLauncherDelegate {
13 public: 27 public:
14 ContentTestLauncherDelegate() { 28 ContentTestLauncherDelegate() {
15 } 29 }
16 30
17 virtual ~ContentTestLauncherDelegate() { 31 virtual ~ContentTestLauncherDelegate() {
18 } 32 }
19 33
20 virtual void EarlyInitialize() OVERRIDE { 34 virtual void EarlyInitialize() OVERRIDE {
21 } 35 }
22 36
23 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE { 37 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE {
24 CommandLine* command_line = CommandLine::ForCurrentProcess(); 38 CommandLine* command_line = CommandLine::ForCurrentProcess();
25 39
26 // TODO(pkasting): This "single_process vs. single-process" design is 40 #if defined(OS_WIN)
27 // terrible UI. Instead, there should be some sort of signal flag on the 41 if (command_line->HasSwitch(switches::kProcessType)) {
28 // command line, with all subsequent arguments passed through to the 42 sandbox::SandboxInterfaceInfo sandbox_info = {0};
29 // underlying browser. 43 content::InitializeSandboxInfo(&sandbox_info);
30 if (command_line->HasSwitch(test_launcher::kSingleProcessTestsFlag) || 44 ShellMainDelegate delegate;
31 command_line->HasSwitch( 45 *return_code =
32 test_launcher::kSingleProcessTestsAndChromeFlag) || 46 content::ContentMain(GetModuleHandle(NULL), &sandbox_info, &delegate);
33 command_line->HasSwitch(test_launcher::kGTestListTestsFlag) ||
34 command_line->HasSwitch(test_launcher::kGTestHelpFlag)) {
35 *return_code = ContentTestSuite(argc, argv).Run();
36 return true; 47 return true;
37 } 48 }
49 #endif // defined(OS_WIN)
38 50
39 return false; 51 return false;
40 } 52 }
41 53
54 virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
55 return base::TestSuite(argc, argv).Run();
56 }
57
42 virtual bool AdjustChildProcessCommandLine( 58 virtual bool AdjustChildProcessCommandLine(
43 CommandLine* command_line) OVERRIDE { 59 CommandLine* command_line) OVERRIDE {
60 FilePath file_exe;
61 if (!PathService::Get(base::FILE_EXE, &file_exe))
62 return false;
63 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, file_exe);
44 return true; 64 return true;
45 } 65 }
46 66
47 private: 67 private:
48 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate); 68 DISALLOW_COPY_AND_ASSIGN(ContentTestLauncherDelegate);
49 }; 69 };
50 70
51 int main(int argc, char** argv) { 71 int main(int argc, char** argv) {
52 ContentTestLauncherDelegate launcher_delegate; 72 ContentTestLauncherDelegate launcher_delegate;
53 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); 73 return test_launcher::LaunchTests(&launcher_delegate, argc, argv);
54 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698