OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/chrome_test_launcher.h" | 5 #include "chrome/test/base/chrome_test_launcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #if defined(OS_LINUX) || defined(OS_ANDROID) | 43 #if defined(OS_LINUX) || defined(OS_ANDROID) |
44 #include "chrome/app/chrome_crash_reporter_client.h" | 44 #include "chrome/app/chrome_crash_reporter_client.h" |
45 #endif | 45 #endif |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { | 49 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { |
50 public: | 50 public: |
51 explicit ChromeTestLauncherDelegate(ChromeTestSuiteRunner* runner) | 51 explicit ChromeTestLauncherDelegate(ChromeTestSuiteRunner* runner) |
52 : runner_(runner) {} | 52 : runner_(runner) {} |
53 virtual ~ChromeTestLauncherDelegate() {} | 53 ~ChromeTestLauncherDelegate() override {} |
54 | 54 |
55 virtual int RunTestSuite(int argc, char** argv) override { | 55 int RunTestSuite(int argc, char** argv) override { |
56 return runner_->RunTestSuite(argc, argv); | 56 return runner_->RunTestSuite(argc, argv); |
57 } | 57 } |
58 | 58 |
59 virtual bool AdjustChildProcessCommandLine( | 59 bool AdjustChildProcessCommandLine( |
60 CommandLine* command_line, const base::FilePath& temp_data_dir) override { | 60 CommandLine* command_line, |
| 61 const base::FilePath& temp_data_dir) override { |
61 CommandLine new_command_line(command_line->GetProgram()); | 62 CommandLine new_command_line(command_line->GetProgram()); |
62 CommandLine::SwitchMap switches = command_line->GetSwitches(); | 63 CommandLine::SwitchMap switches = command_line->GetSwitches(); |
63 | 64 |
64 // Strip out user-data-dir if present. We will add it back in again later. | 65 // Strip out user-data-dir if present. We will add it back in again later. |
65 switches.erase(switches::kUserDataDir); | 66 switches.erase(switches::kUserDataDir); |
66 | 67 |
67 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 68 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
68 iter != switches.end(); ++iter) { | 69 iter != switches.end(); ++iter) { |
69 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); | 70 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
70 } | 71 } |
71 | 72 |
72 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); | 73 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); |
73 | 74 |
74 // file:// access for ChromeOS. | 75 // file:// access for ChromeOS. |
75 new_command_line.AppendSwitch(switches::kAllowFileAccess); | 76 new_command_line.AppendSwitch(switches::kAllowFileAccess); |
76 | 77 |
77 *command_line = new_command_line; | 78 *command_line = new_command_line; |
78 return true; | 79 return true; |
79 } | 80 } |
80 | 81 |
81 protected: | 82 protected: |
82 virtual content::ContentMainDelegate* CreateContentMainDelegate() override { | 83 content::ContentMainDelegate* CreateContentMainDelegate() override { |
83 return new ChromeMainDelegate(); | 84 return new ChromeMainDelegate(); |
84 } | 85 } |
85 | 86 |
86 virtual void AdjustDefaultParallelJobs(int* default_jobs) override { | 87 void AdjustDefaultParallelJobs(int* default_jobs) override { |
87 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
88 if (CommandLine::ForCurrentProcess()->HasSwitch( | 89 if (CommandLine::ForCurrentProcess()->HasSwitch( |
89 switches::kAshBrowserTests)) { | 90 switches::kAshBrowserTests)) { |
90 *default_jobs = 1; | 91 *default_jobs = 1; |
91 fprintf(stdout, | 92 fprintf(stdout, |
92 "Disabling test parallelization for --ash-browsertests.\n"); | 93 "Disabling test parallelization for --ash-browsertests.\n"); |
93 fflush(stdout); | 94 fflush(stdout); |
94 } | 95 } |
95 #endif // defined(OS_WIN) | 96 #endif // defined(OS_WIN) |
96 } | 97 } |
(...skipping 19 matching lines...) Expand all Loading... |
116 // all other code. | 117 // all other code. |
117 chrome::ChromeCrashReporterClient* crash_client = | 118 chrome::ChromeCrashReporterClient* crash_client = |
118 new chrome::ChromeCrashReporterClient(); | 119 new chrome::ChromeCrashReporterClient(); |
119 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); | 120 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); |
120 crash_reporter::SetCrashReporterClient(crash_client); | 121 crash_reporter::SetCrashReporterClient(crash_client); |
121 #endif | 122 #endif |
122 | 123 |
123 ChromeTestLauncherDelegate launcher_delegate(runner); | 124 ChromeTestLauncherDelegate launcher_delegate(runner); |
124 return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv); | 125 return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv); |
125 } | 126 } |
OLD | NEW |