| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/test/multiprocess_test.h" | |
| 6 | |
| 7 #include "base/base_switches.h" | |
| 8 #include "base/command_line.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/files/file_util.h" | |
| 11 | |
| 12 namespace base { | |
| 13 | |
| 14 #if !defined(OS_ANDROID) | |
| 15 Process SpawnMultiProcessTestChild( | |
| 16 const std::string& procname, | |
| 17 const CommandLine& base_command_line, | |
| 18 const LaunchOptions& options) { | |
| 19 CommandLine command_line(base_command_line); | |
| 20 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. | |
| 21 // This is a temporary hack, since |MakeCmdLine()| has to provide a full | |
| 22 // command line. | |
| 23 if (!command_line.HasSwitch(switches::kTestChildProcess)) | |
| 24 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | |
| 25 | |
| 26 return LaunchProcess(command_line, options); | |
| 27 } | |
| 28 #endif // !defined(OS_ANDROID) | |
| 29 | |
| 30 CommandLine GetMultiProcessTestChildBaseCommandLine() { | |
| 31 CommandLine cmd_line = *CommandLine::ForCurrentProcess(); | |
| 32 cmd_line.SetProgram(MakeAbsoluteFilePath(cmd_line.GetProgram())); | |
| 33 return cmd_line; | |
| 34 } | |
| 35 | |
| 36 // MultiProcessTest ------------------------------------------------------------ | |
| 37 | |
| 38 MultiProcessTest::MultiProcessTest() { | |
| 39 } | |
| 40 | |
| 41 Process MultiProcessTest::SpawnChild(const std::string& procname) { | |
| 42 LaunchOptions options; | |
| 43 #if defined(OS_WIN) | |
| 44 options.start_hidden = true; | |
| 45 #endif | |
| 46 return SpawnChildWithOptions(procname, options); | |
| 47 } | |
| 48 | |
| 49 Process MultiProcessTest::SpawnChildWithOptions( | |
| 50 const std::string& procname, | |
| 51 const LaunchOptions& options) { | |
| 52 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); | |
| 53 } | |
| 54 | |
| 55 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { | |
| 56 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); | |
| 57 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | |
| 58 return command_line; | |
| 59 } | |
| 60 | |
| 61 } // namespace base | |
| OLD | NEW |