| Index: base/command_line.cc
|
| diff --git a/base/command_line.cc b/base/command_line.cc
|
| index c991959d6911bf545f994b3e6d0833f793cc7cf0..61f4688cac6388b87581d1f624acd732013b288e 100644
|
| --- a/base/command_line.cc
|
| +++ b/base/command_line.cc
|
| @@ -145,6 +145,11 @@ string16 QuoteForCommandLineToArgvW(const string16& arg,
|
|
|
| return out;
|
| }
|
| +
|
| +// Controls whether we honor the argc and argv parameters passed in to the main
|
| +// function for console apps or use the shell32 API's to parse the command
|
| +// line string and retrieve argc and argv.
|
| +bool honor_command_line_args_for_testing = false;
|
| #endif
|
|
|
| } // namespace
|
| @@ -197,6 +202,11 @@ void CommandLine::set_slash_is_not_a_switch() {
|
| DCHECK_EQ(wcscmp(kSwitchPrefixes[arraysize(kSwitchPrefixes) - 1], L"/"), 0);
|
| switch_prefix_count = arraysize(kSwitchPrefixes) - 1;
|
| }
|
| +
|
| +void CommandLine::set_honor_command_line_args_for_testing(
|
| + bool honor_args_for_testing) {
|
| + honor_command_line_args_for_testing = honor_args_for_testing;
|
| +}
|
| #endif
|
|
|
| // static
|
| @@ -209,12 +219,20 @@ bool CommandLine::Init(int argc, const char* const* argv) {
|
| }
|
|
|
| current_process_commandline_ = new CommandLine(NO_PROGRAM);
|
| +
|
| #if defined(OS_WIN)
|
| - current_process_commandline_->ParseFromString(::GetCommandLineW());
|
| + if (honor_command_line_args_for_testing) {
|
| + // On Windows we need to convert the command line arguments to string16
|
| + base::CommandLine::StringVector argv_vector;
|
| + for (int i = 0; i < argc; ++i)
|
| + argv_vector.push_back(UTF8ToUTF16(argv[i]));
|
| + current_process_commandline_->InitFromArgv(argv_vector);
|
| + } else {
|
| + current_process_commandline_->ParseFromString(::GetCommandLineW());
|
| + }
|
| #elif defined(OS_POSIX)
|
| current_process_commandline_->InitFromArgv(argc, argv);
|
| #endif
|
| -
|
| return true;
|
| }
|
|
|
|
|