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

Side by Side Diff: base/test/multiprocess_test.cc

Issue 189373002: Add multiprocess test helper functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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) 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 "base/test/multiprocess_test.h" 5 #include "base/test/multiprocess_test.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 9
10 namespace base { 10 namespace base {
11 11
12 #if !defined(OS_ANDROID)
13 ProcessHandle SpawnMultiProcessTestChild(
14 const std::string& procname,
15 const CommandLine& base_command_line,
16 const LaunchOptions& options,
17 bool debug_on_start) {
18 CommandLine command_line(base_command_line);
19 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
20 if (debug_on_start)
21 command_line.AppendSwitch(switches::kDebugOnStart);
22
23 ProcessHandle handle = kNullProcessHandle;
24 LaunchProcess(command_line, options, &handle);
25 return handle;
26 }
27 #endif
Paweł Hajdan Jr. 2014/03/07 02:08:01 nit: // !defined(OS_ANDROID)
viettrungluu 2014/03/07 04:42:44 Done, but note that these are generally considered
28
29 CommandLine GetMultiProcessTestChildBaseCommandLine() {
30 return *CommandLine::ForCurrentProcess();
31 }
32
33 // MultiProcessTest ------------------------------------------------------------
34
12 MultiProcessTest::MultiProcessTest() { 35 MultiProcessTest::MultiProcessTest() {
13 } 36 }
14 37
15 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, 38 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname,
16 bool debug_on_start) { 39 bool debug_on_start) {
17 LaunchOptions options; 40 LaunchOptions options;
18 #if defined(OS_WIN) 41 #if defined(OS_WIN)
19 options.start_hidden = true; 42 options.start_hidden = true;
20 #endif 43 #endif
21 return SpawnChildWithOptions(procname, options, debug_on_start); 44 return SpawnChildWithOptions(procname, options, debug_on_start);
22 } 45 }
23 46
24 #if !defined(OS_ANDROID)
25 ProcessHandle MultiProcessTest::SpawnChildWithOptions( 47 ProcessHandle MultiProcessTest::SpawnChildWithOptions(
26 const std::string& procname, 48 const std::string& procname,
27 const LaunchOptions& options, 49 const LaunchOptions& options,
28 bool debug_on_start) { 50 bool debug_on_start) {
29 ProcessHandle handle = kNullProcessHandle; 51 return SpawnMultiProcessTestChild(procname,
30 LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle); 52 MakeCmdLine(procname, debug_on_start),
31 return handle; 53 options,
54 debug_on_start);
32 } 55 }
33 #endif
34 56
35 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, 57 CommandLine MultiProcessTest::MakeCmdLine(const std::string& /*procname*/,
Paweł Hajdan Jr. 2014/03/07 02:08:01 nit: AFAIK we don't comment out parameter names.
viettrungluu 2014/03/07 04:42:44 Removed. <shrug>
36 bool debug_on_start) { 58 bool /*debug_on_start*/) {
37 CommandLine cl(*CommandLine::ForCurrentProcess()); 59 return GetMultiProcessTestChildBaseCommandLine();
38 cl.AppendSwitchASCII(switches::kTestChildProcess, procname);
39 if (debug_on_start)
40 cl.AppendSwitch(switches::kDebugOnStart);
41 return cl;
42 } 60 }
43 61
44 } // namespace base 62 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698