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

Unified Diff: base/command_line_unittest.cc

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line.cc ('k') | base/compiler_specific.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line_unittest.cc
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 018d83f1add248ca85f8825a6789cb477fb7b1b1..f505c4e72ec84e9bbf94c4d91d3b2b00fa0d04ff 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -61,11 +61,7 @@ TEST(CommandLineTest, CommandLineConstructor) {
cl.GetProgram().value());
EXPECT_TRUE(cl.HasSwitch("foo"));
-#if defined(OS_WIN)
- EXPECT_TRUE(cl.HasSwitch("bar"));
-#else
EXPECT_FALSE(cl.HasSwitch("bar"));
-#endif
EXPECT_TRUE(cl.HasSwitch("baz"));
EXPECT_TRUE(cl.HasSwitch("spaetzle"));
EXPECT_TRUE(cl.HasSwitch("other-switches"));
@@ -102,78 +98,8 @@ TEST(CommandLineTest, CommandLineConstructor) {
EXPECT_TRUE(iter == args.end());
}
-TEST(CommandLineTest, CommandLineFromString) {
-#if defined(OS_WIN)
- CommandLine cl = CommandLine::FromString(
- L"program --foo= -bAr /Spaetzel=pierogi /Baz flim "
- L"--other-switches=\"--dog=canine --cat=feline\" "
- L"-spaetzle=Crepe -=loosevalue FLAN "
- L"--input-translation=\"45\"--output-rotation "
- L"--quotes=" + kTrickyQuoted + L" "
- L"-- -- --not-a-switch "
- L"\"in the time of submarines...\"");
-
- EXPECT_FALSE(cl.GetCommandLineString().empty());
- EXPECT_FALSE(cl.HasSwitch("cruller"));
- EXPECT_FALSE(cl.HasSwitch("flim"));
- EXPECT_FALSE(cl.HasSwitch("program"));
- EXPECT_FALSE(cl.HasSwitch("dog"));
- EXPECT_FALSE(cl.HasSwitch("cat"));
- EXPECT_FALSE(cl.HasSwitch("output-rotation"));
- EXPECT_FALSE(cl.HasSwitch("not-a-switch"));
- EXPECT_FALSE(cl.HasSwitch("--"));
-
- EXPECT_EQ(FilePath(FILE_PATH_LITERAL("program")).value(),
- cl.GetProgram().value());
-
- EXPECT_TRUE(cl.HasSwitch("foo"));
- EXPECT_TRUE(cl.HasSwitch("bar"));
- EXPECT_TRUE(cl.HasSwitch("baz"));
- EXPECT_TRUE(cl.HasSwitch("spaetzle"));
- EXPECT_TRUE(cl.HasSwitch("other-switches"));
- EXPECT_TRUE(cl.HasSwitch("input-translation"));
- EXPECT_TRUE(cl.HasSwitch("quotes"));
-
- EXPECT_EQ("Crepe", cl.GetSwitchValueASCII("spaetzle"));
- EXPECT_EQ("", cl.GetSwitchValueASCII("foo"));
- EXPECT_EQ("", cl.GetSwitchValueASCII("bar"));
- EXPECT_EQ("", cl.GetSwitchValueASCII("cruller"));
- EXPECT_EQ("--dog=canine --cat=feline", cl.GetSwitchValueASCII(
- "other-switches"));
- EXPECT_EQ("45--output-rotation", cl.GetSwitchValueASCII("input-translation"));
- EXPECT_EQ(kTricky, cl.GetSwitchValueNative("quotes"));
-
- const CommandLine::StringVector& args = cl.GetArgs();
- ASSERT_EQ(5U, args.size());
-
- std::vector<CommandLine::StringType>::const_iterator iter = args.begin();
- EXPECT_EQ(FILE_PATH_LITERAL("flim"), *iter);
- ++iter;
- EXPECT_EQ(FILE_PATH_LITERAL("FLAN"), *iter);
- ++iter;
- EXPECT_EQ(FILE_PATH_LITERAL("--"), *iter);
- ++iter;
- EXPECT_EQ(FILE_PATH_LITERAL("--not-a-switch"), *iter);
- ++iter;
- EXPECT_EQ(FILE_PATH_LITERAL("in the time of submarines..."), *iter);
- ++iter;
- EXPECT_TRUE(iter == args.end());
-
- // Check that a generated string produces an equivalent command line.
- CommandLine cl_duplicate = CommandLine::FromString(cl.GetCommandLineString());
- EXPECT_EQ(cl.GetCommandLineString(), cl_duplicate.GetCommandLineString());
-#endif
-}
-
// Tests behavior with an empty input string.
TEST(CommandLineTest, EmptyString) {
-#if defined(OS_WIN)
- CommandLine cl_from_string = CommandLine::FromString(L"");
- EXPECT_TRUE(cl_from_string.GetCommandLineString().empty());
- EXPECT_TRUE(cl_from_string.GetProgram().empty());
- EXPECT_EQ(1U, cl_from_string.argv().size());
- EXPECT_TRUE(cl_from_string.GetArgs().empty());
-#endif
CommandLine cl_from_argv(0, NULL);
EXPECT_TRUE(cl_from_argv.GetCommandLineString().empty());
EXPECT_TRUE(cl_from_argv.GetProgram().empty());
@@ -200,25 +126,13 @@ TEST(CommandLineTest, GetArgumentsString) {
cl.AppendArg(kFourthArgName);
cl.AppendArg(kFifthArgName);
-#if defined(OS_WIN)
- CommandLine::StringType expected_first_arg(UTF8ToUTF16(kFirstArgName));
- CommandLine::StringType expected_second_arg(UTF8ToUTF16(kSecondArgName));
- CommandLine::StringType expected_third_arg(UTF8ToUTF16(kThirdArgName));
- CommandLine::StringType expected_fourth_arg(UTF8ToUTF16(kFourthArgName));
- CommandLine::StringType expected_fifth_arg(UTF8ToUTF16(kFifthArgName));
-#elif defined(OS_POSIX)
CommandLine::StringType expected_first_arg(kFirstArgName);
CommandLine::StringType expected_second_arg(kSecondArgName);
CommandLine::StringType expected_third_arg(kThirdArgName);
CommandLine::StringType expected_fourth_arg(kFourthArgName);
CommandLine::StringType expected_fifth_arg(kFifthArgName);
-#endif
-#if defined(OS_WIN)
-#define QUOTE_ON_WIN FILE_PATH_LITERAL("\"")
-#else
#define QUOTE_ON_WIN FILE_PATH_LITERAL("")
-#endif // OS_WIN
CommandLine::StringType expected_str;
expected_str.append(FILE_PATH_LITERAL("--"))
@@ -246,14 +160,6 @@ TEST(CommandLineTest, GetArgumentsString) {
expected_str_no_quote_placeholders.append(expected_fifth_arg);
EXPECT_EQ(expected_str_no_quote_placeholders, cl.GetArgumentsString());
-#if defined(OS_WIN)
- CommandLine::StringType expected_str_quote_placeholders(expected_str);
- expected_str_quote_placeholders.append(QUOTE_ON_WIN)
- .append(expected_fifth_arg)
- .append(QUOTE_ON_WIN);
- EXPECT_EQ(expected_str_quote_placeholders,
- cl.GetArgumentsStringWithPlaceholders());
-#endif
}
// Test methods for appending switches to a command line.
@@ -287,18 +193,6 @@ TEST(CommandLineTest, AppendSwitches) {
EXPECT_TRUE(cl.HasSwitch(switch5));
EXPECT_EQ(value5, cl.GetSwitchValueNative(switch5));
-#if defined(OS_WIN)
- EXPECT_EQ(L"Program "
- L"--switch1 "
- L"--switch2=value "
- L"--switch3=\"a value with spaces\" "
- L"--switch4=\"\\\"a value with quotes\\\"\" "
- // Even though the switches are unique, appending can add repeat
- // switches to argv.
- L"--quotes=\"\\\"a value with quotes\\\"\" "
- L"--quotes=\"" + kTrickyQuoted + L"\"",
- cl.GetCommandLineString());
-#endif
}
TEST(CommandLineTest, AppendSwitchesDashDash) {
@@ -347,35 +241,6 @@ TEST(CommandLineTest, AppendArguments) {
EXPECT_TRUE(c1.HasSwitch("switch2"));
}
-#if defined(OS_WIN)
-// Make sure that the command line string program paths are quoted as necessary.
-// This only makes sense on Windows and the test is basically here to guard
-// against regressions.
-TEST(CommandLineTest, ProgramQuotes) {
- // Check that quotes are not added for paths without spaces.
- const FilePath kProgram(L"Program");
- CommandLine cl_program(kProgram);
- EXPECT_EQ(kProgram.value(), cl_program.GetProgram().value());
- EXPECT_EQ(kProgram.value(), cl_program.GetCommandLineString());
-
- const FilePath kProgramPath(L"Program Path");
-
- // Check that quotes are not returned from GetProgram().
- CommandLine cl_program_path(kProgramPath);
- EXPECT_EQ(kProgramPath.value(), cl_program_path.GetProgram().value());
-
- // Check that quotes are added to command line string paths containing spaces.
- CommandLine::StringType cmd_string(cl_program_path.GetCommandLineString());
- EXPECT_EQ(L"\"Program Path\"", cmd_string);
-
- // Check the optional quoting of placeholders in programs.
- CommandLine cl_quote_placeholder(FilePath(L"%1"));
- EXPECT_EQ(L"%1", cl_quote_placeholder.GetCommandLineString());
- EXPECT_EQ(L"\"%1\"",
- cl_quote_placeholder.GetCommandLineStringWithPlaceholders());
-}
-#endif
-
// Calling Init multiple times should not modify the previous CommandLine.
TEST(CommandLineTest, Init) {
CommandLine* initial = CommandLine::ForCurrentProcess();
« no previous file with comments | « base/command_line.cc ('k') | base/compiler_specific.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698