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

Side by Side Diff: base/process_util_unittest.cc

Issue 329017: Remove deprecated CommandLine(std::wstring) ctor. (Closed)
Patch Set: Created 11 years, 2 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
« no previous file with comments | « base/command_line_unittest.cc ('k') | chrome/app/chrome_main_uitest.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/eintr_wrapper.h" 8 #include "base/eintr_wrapper.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/multiprocess_test.h" 10 #include "base/multiprocess_test.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // boundary. 144 // boundary.
145 message += "Hello!"; 145 message += "Hello!";
146 } 146 }
147 147
148 FilePath python_runtime; 148 FilePath python_runtime;
149 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &python_runtime)); 149 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &python_runtime));
150 python_runtime = python_runtime.Append(FILE_PATH_LITERAL("third_party")) 150 python_runtime = python_runtime.Append(FILE_PATH_LITERAL("third_party"))
151 .Append(FILE_PATH_LITERAL("python_24")) 151 .Append(FILE_PATH_LITERAL("python_24"))
152 .Append(FILE_PATH_LITERAL("python.exe")); 152 .Append(FILE_PATH_LITERAL("python.exe"));
153 153
154 CommandLine cmd_line(python_runtime.value()); 154 CommandLine cmd_line(python_runtime);
155 cmd_line.AppendLooseValue(L"-c"); 155 cmd_line.AppendLooseValue(L"-c");
156 cmd_line.AppendLooseValue(L"\"import sys; sys.stdout.write('" + 156 cmd_line.AppendLooseValue(L"\"import sys; sys.stdout.write('" +
157 ASCIIToWide(message) + L"');\""); 157 ASCIIToWide(message) + L"');\"");
158 std::string output; 158 std::string output;
159 ASSERT_TRUE(base::GetAppOutput(cmd_line, &output)); 159 ASSERT_TRUE(base::GetAppOutput(cmd_line, &output));
160 EXPECT_EQ(message, output); 160 EXPECT_EQ(message, output);
161 161
162 // Let's make sure stderr is ignored. 162 // Let's make sure stderr is ignored.
163 CommandLine other_cmd_line(python_runtime.value()); 163 CommandLine other_cmd_line(python_runtime);
164 other_cmd_line.AppendLooseValue(L"-c"); 164 other_cmd_line.AppendLooseValue(L"-c");
165 other_cmd_line.AppendLooseValue( 165 other_cmd_line.AppendLooseValue(
166 L"\"import sys; sys.stderr.write('Hello!');\""); 166 L"\"import sys; sys.stderr.write('Hello!');\"");
167 output.clear(); 167 output.clear();
168 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output)); 168 ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output));
169 EXPECT_EQ("", output); 169 EXPECT_EQ("", output);
170 } 170 }
171 #endif // defined(OS_WIN) 171 #endif // defined(OS_WIN)
172 172
173 #if defined(OS_POSIX) 173 #if defined(OS_POSIX)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 ASSERT_EQ(fds_after, fds_before); 254 ASSERT_EQ(fds_after, fds_before);
255 255
256 HANDLE_EINTR(close(sockets[0])); 256 HANDLE_EINTR(close(sockets[0]));
257 HANDLE_EINTR(close(sockets[1])); 257 HANDLE_EINTR(close(sockets[1]));
258 HANDLE_EINTR(close(dev_null)); 258 HANDLE_EINTR(close(dev_null));
259 } 259 }
260 260
261 TEST_F(ProcessUtilTest, GetAppOutput) { 261 TEST_F(ProcessUtilTest, GetAppOutput) {
262 std::string output; 262 std::string output;
263 EXPECT_TRUE(GetAppOutput(CommandLine(L"true"), &output)); 263 EXPECT_TRUE(GetAppOutput(CommandLine(FilePath("true")), &output));
264 EXPECT_STREQ("", output.c_str()); 264 EXPECT_STREQ("", output.c_str());
265 265
266 EXPECT_FALSE(GetAppOutput(CommandLine(L"false"), &output)); 266 EXPECT_FALSE(GetAppOutput(CommandLine(FilePath("false")), &output));
267 267
268 std::vector<std::string> argv; 268 std::vector<std::string> argv;
269 argv.push_back("/bin/echo"); 269 argv.push_back("/bin/echo");
270 argv.push_back("-n"); 270 argv.push_back("-n");
271 argv.push_back("foobar42"); 271 argv.push_back("foobar42");
272 EXPECT_TRUE(GetAppOutput(CommandLine(argv), &output)); 272 EXPECT_TRUE(GetAppOutput(CommandLine(argv), &output));
273 EXPECT_STREQ("foobar42", output.c_str()); 273 EXPECT_STREQ("foobar42", output.c_str());
274 } 274 }
275 275
276 #if defined(OS_LINUX) 276 #if defined(OS_LINUX)
(...skipping 19 matching lines...) Expand all
296 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 " 296 "16 0 1 0 1676099790 2957312 114 4294967295 134512640 134528148 "
297 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0"; 297 "3221224832 3221224344 3086339742 0 0 0 0 0 0 0 17 0 0 0";
298 298
299 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat)); 299 EXPECT_EQ(0, ParseProcStatCPU(kSelfStat));
300 } 300 }
301 #endif 301 #endif
302 302
303 #endif // defined(OS_POSIX) 303 #endif // defined(OS_POSIX)
304 304
305 } // namespace base 305 } // namespace base
OLDNEW
« no previous file with comments | « base/command_line_unittest.cc ('k') | chrome/app/chrome_main_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698