OLD | NEW |
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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString()); | 341 EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString()); |
342 | 342 |
343 const FilePath kProgramPath(L"Program Path"); | 343 const FilePath kProgramPath(L"Program Path"); |
344 | 344 |
345 // Check that quotes are not returned from GetProgram(). | 345 // Check that quotes are not returned from GetProgram(). |
346 CommandLine cl_program_path(kProgramPath); | 346 CommandLine cl_program_path(kProgramPath); |
347 EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value()); | 347 EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value()); |
348 | 348 |
349 // Check that quotes are added to command line string paths containing spaces. | 349 // Check that quotes are added to command line string paths containing spaces. |
350 CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString()); | 350 CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString()); |
351 CommandLine::StringType program_string(cl_program_path.GetProgram().value()); | 351 EXPECT_EQ(L"\"Program Path\"", cmd_string); |
352 EXPECT_EQ('"', cmd_string[0]); | |
353 EXPECT_EQ(program_string, cmd_string.substr(1, program_string.length())); | |
354 EXPECT_EQ('"', cmd_string[program_string.length() + 1]); | |
355 } | 352 } |
356 #endif | 353 #endif |
357 | 354 |
358 // Calling Init multiple times should not modify the previous CommandLine. | 355 // Calling Init multiple times should not modify the previous CommandLine. |
359 TEST(CommandLineTest, Init) { | 356 TEST(CommandLineTest, Init) { |
360 CommandLine* initial = CommandLine::ForCurrentProcess(); | 357 CommandLine* initial = CommandLine::ForCurrentProcess(); |
361 EXPECT_FALSE(CommandLine::Init(0, NULL)); | 358 EXPECT_FALSE(CommandLine::Init(0, NULL)); |
362 CommandLine* current = CommandLine::ForCurrentProcess(); | 359 CommandLine* current = CommandLine::ForCurrentProcess(); |
363 EXPECT_EQ(initial, current); | 360 EXPECT_EQ(initial, current); |
364 } | 361 } |
OLD | NEW |