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

Side by Side Diff: chrome/test/base/mash_browser_tests_main.cc

Issue 2557213002: Build services as standalone executables (Closed)
Patch Set: remove DCHECKs with side effects -_- Created 4 years 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
« no previous file with comments | « chrome/app/mash/mash_runner.cc ('k') | chrome/test/base/mojo_test_connector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/i18n/icu_util.h" 10 #include "base/i18n/icu_util.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/process/launch.h" 13 #include "base/process/launch.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/test/base/chrome_test_launcher.h" 17 #include "chrome/test/base/chrome_test_launcher.h"
18 #include "chrome/test/base/chrome_test_suite.h" 18 #include "chrome/test/base/chrome_test_suite.h"
19 #include "chrome/test/base/mojo_test_connector.h" 19 #include "chrome/test/base/mojo_test_connector.h"
20 #include "content/public/common/service_manager_connection.h" 20 #include "content/public/common/service_manager_connection.h"
21 #include "content/public/test/test_launcher.h" 21 #include "content/public/test/test_launcher.h"
22 #include "mash/package/mash_packaged_service.h" 22 #include "mash/package/mash_packaged_service.h"
23 #include "services/service_manager/public/cpp/connector.h" 23 #include "services/service_manager/public/cpp/connector.h"
24 #include "services/service_manager/public/cpp/service.h" 24 #include "services/service_manager/public/cpp/service.h"
25 #include "services/service_manager/public/cpp/service_context.h" 25 #include "services/service_manager/public/cpp/service_context.h"
26 #include "services/service_manager/public/cpp/service_runner.h" 26 #include "services/service_manager/public/cpp/service_runner.h"
27 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h"
27 #include "services/service_manager/runner/common/switches.h" 28 #include "services/service_manager/runner/common/switches.h"
28 #include "services/service_manager/runner/host/child_process.h"
29 #include "services/service_manager/runner/host/child_process_base.h"
30 #include "services/service_manager/runner/init.h" 29 #include "services/service_manager/runner/init.h"
31 30
32 namespace { 31 namespace {
33 32
34 void ConnectToDefaultApps(service_manager::Connector* connector) { 33 void ConnectToDefaultApps(service_manager::Connector* connector) {
35 connector->Connect("mash_session"); 34 connector->Connect("mash_session");
36 } 35 }
37 36
38 class MashTestSuite : public ChromeTestSuite { 37 class MashTestSuite : public ChromeTestSuite {
39 public: 38 public:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const base::CommandLine& command_line = 142 const base::CommandLine& command_line =
144 *base::CommandLine::ForCurrentProcess(); 143 *base::CommandLine::ForCurrentProcess();
145 if (!command_line.HasSwitch("run-in-mash")) 144 if (!command_line.HasSwitch("run-in-mash"))
146 return false; 145 return false;
147 146
148 if (command_line.HasSwitch(MojoTestConnector::kMashApp)) { 147 if (command_line.HasSwitch(MojoTestConnector::kMashApp)) {
149 #if defined(OS_LINUX) 148 #if defined(OS_LINUX)
150 base::AtExitManager exit_manager; 149 base::AtExitManager exit_manager;
151 #endif 150 #endif
152 base::i18n::InitializeICU(); 151 base::i18n::InitializeICU();
153 service_manager::ChildProcessMainWithCallback(base::Bind(&StartChildApp)); 152 service_manager::RunStandaloneService(base::Bind(&StartChildApp));
154 *exit_code = 0; 153 *exit_code = 0;
155 return true; 154 return true;
156 } 155 }
157 156
158 if (command_line.HasSwitch(switches::kChildProcess) &&
159 !command_line.HasSwitch(MojoTestConnector::kTestSwitch)) {
160 base::AtExitManager at_exit;
161 service_manager::InitializeLogging();
162 service_manager::WaitForDebuggerIfNecessary();
163 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN)
164 base::RouteStdioToConsole(false);
165 #endif
166 *exit_code = service_manager::ChildProcessMain();
167 return true;
168 }
169
170 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); 157 int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2);
171 MashTestLauncherDelegate delegate; 158 MashTestLauncherDelegate delegate;
172 // --single_process and no primoridal pipe token indicate we were run directly 159 // --single_process and no primoridal pipe token indicate we were run directly
173 // from the command line. In this case we have to start up 160 // from the command line. In this case we have to start up
174 // ServiceManagerConnection 161 // ServiceManagerConnection
175 // as though we were embedded. 162 // as though we were embedded.
176 content::ServiceManagerConnection::Factory service_manager_connection_factory; 163 content::ServiceManagerConnection::Factory service_manager_connection_factory;
177 if (command_line.HasSwitch(content::kSingleProcessTestsFlag) && 164 if (command_line.HasSwitch(content::kSingleProcessTestsFlag) &&
178 !command_line.HasSwitch(switches::kPrimordialPipeToken)) { 165 !command_line.HasSwitch(switches::kPrimordialPipeToken)) {
179 service_manager_connection_factory = 166 service_manager_connection_factory =
180 base::Bind(&CreateServiceManagerConnection, &delegate); 167 base::Bind(&CreateServiceManagerConnection, &delegate);
181 content::ServiceManagerConnection::SetFactoryForTest( 168 content::ServiceManagerConnection::SetFactoryForTest(
182 &service_manager_connection_factory); 169 &service_manager_connection_factory);
183 } 170 }
184 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv); 171 *exit_code = LaunchChromeTests(default_jobs, &delegate, argc, argv);
185 return true; 172 return true;
186 } 173 }
OLDNEW
« no previous file with comments | « chrome/app/mash/mash_runner.cc ('k') | chrome/test/base/mojo_test_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698