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

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: restore old MakeCmdLine behavior 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
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.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 (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 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file.
20 // This is a temporary hack, since |MakeCmdLine()| has to provide a full
21 // command line.
22 if (!command_line.HasSwitch(switches::kTestChildProcess)) {
23 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
24 if (debug_on_start)
25 command_line.AppendSwitch(switches::kDebugOnStart);
26 }
27
28 ProcessHandle handle = kNullProcessHandle;
29 LaunchProcess(command_line, options, &handle);
30 return handle;
31 }
32 #endif // !defined(OS_ANDROID)
33
34 CommandLine GetMultiProcessTestChildBaseCommandLine() {
35 return *CommandLine::ForCurrentProcess();
36 }
37
38 // MultiProcessTest ------------------------------------------------------------
39
12 MultiProcessTest::MultiProcessTest() { 40 MultiProcessTest::MultiProcessTest() {
13 } 41 }
14 42
15 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, 43 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname,
16 bool debug_on_start) { 44 bool debug_on_start) {
17 LaunchOptions options; 45 LaunchOptions options;
18 #if defined(OS_WIN) 46 #if defined(OS_WIN)
19 options.start_hidden = true; 47 options.start_hidden = true;
20 #endif 48 #endif
21 return SpawnChildWithOptions(procname, options, debug_on_start); 49 return SpawnChildWithOptions(procname, options, debug_on_start);
22 } 50 }
23 51
24 #if !defined(OS_ANDROID)
25 ProcessHandle MultiProcessTest::SpawnChildWithOptions( 52 ProcessHandle MultiProcessTest::SpawnChildWithOptions(
26 const std::string& procname, 53 const std::string& procname,
27 const LaunchOptions& options, 54 const LaunchOptions& options,
28 bool debug_on_start) { 55 bool debug_on_start) {
29 ProcessHandle handle = kNullProcessHandle; 56 return SpawnMultiProcessTestChild(procname,
30 LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle); 57 MakeCmdLine(procname, debug_on_start),
31 return handle; 58 options,
59 debug_on_start);
32 } 60 }
33 #endif
34 61
35 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, 62 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname,
36 bool debug_on_start) { 63 bool debug_on_start) {
37 CommandLine cl(*CommandLine::ForCurrentProcess()); 64 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine();
38 cl.AppendSwitchASCII(switches::kTestChildProcess, procname); 65 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
39 if (debug_on_start) 66 if (debug_on_start)
40 cl.AppendSwitch(switches::kDebugOnStart); 67 command_line.AppendSwitch(switches::kDebugOnStart);
41 return cl; 68 return command_line;
42 } 69 }
43 70
44 } // namespace base 71 } // namespace base
OLDNEW
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698