OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 c1.AppendSwitch("switch1"); | 172 c1.AppendSwitch("switch1"); |
173 CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2"))); | 173 CommandLine c2(FilePath(FILE_PATH_LITERAL("Program2"))); |
174 c2.AppendSwitch("switch2"); | 174 c2.AppendSwitch("switch2"); |
175 | 175 |
176 c1.AppendArguments(c2, true); | 176 c1.AppendArguments(c2, true); |
177 EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value()); | 177 EXPECT_EQ(c1.GetProgram().value(), c2.GetProgram().value()); |
178 EXPECT_TRUE(c1.HasSwitch("switch1")); | 178 EXPECT_TRUE(c1.HasSwitch("switch1")); |
179 EXPECT_TRUE(c1.HasSwitch("switch2")); | 179 EXPECT_TRUE(c1.HasSwitch("switch2")); |
180 } | 180 } |
181 | 181 |
182 #if defined(OS_WIN) | |
183 // Make sure that the program part of a command line is always quoted. | |
184 // This only makes sense on Windows and the test is basically here to guard | |
185 // against regressions. | |
186 TEST(CommandLineTest, ProgramQuotes) { | |
187 const FilePath kProgram(FILE_PATH_LITERAL("Program")); | |
Evan Martin
2010/11/29 20:39:55
Since you're in a Windows-specific branch, L"Progr
tommi (sloooow) - chröme
2010/11/29 20:45:01
Done.
| |
188 | |
189 // Check that quotes are not returned from GetProgram(). | |
190 CommandLine cl(kProgram); | |
191 EXPECT_EQ(kProgram.value(), cl.GetProgram().value()); | |
192 | |
193 // Verify that in the command line string, the program part is always quoted. | |
194 CommandLine::StringType cmd(cl.command_line_string()); | |
195 CommandLine::StringType program(cl.GetProgram().value()); | |
196 EXPECT_EQ('"', cmd[0]); | |
197 EXPECT_EQ(program, cmd.substr(1, program.length())); | |
198 EXPECT_EQ('"', cmd[program.length() + 1]); | |
199 } | |
200 #endif | |
OLD | NEW |