OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome_frame/chrome_launcher.h" | 8 #include "chrome_frame/chrome_launcher.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 TEST(ChromeLauncher, IsValidCommandLine) { | 11 TEST(ChromeLauncher, IsValidCommandLine) { |
12 CommandLine bad(FilePath(L"dummy.exe")); | 12 CommandLine bad(base::FilePath(L"dummy.exe")); |
13 bad.AppendSwitch(switches::kNoFirstRun); // in whitelist | 13 bad.AppendSwitch(switches::kNoFirstRun); // in whitelist |
14 bad.AppendSwitch("no-such-switch"); // does not exist | 14 bad.AppendSwitch("no-such-switch"); // does not exist |
15 bad.AppendSwitch(switches::kHomePage); // exists but not in whitelist | 15 bad.AppendSwitch(switches::kHomePage); // exists but not in whitelist |
16 | 16 |
17 EXPECT_FALSE(chrome_launcher::IsValidCommandLine( | 17 EXPECT_FALSE(chrome_launcher::IsValidCommandLine( |
18 bad.GetCommandLineString().c_str())); | 18 bad.GetCommandLineString().c_str())); |
19 | 19 |
20 CommandLine good(FilePath(L"dummy.exe")); | 20 CommandLine good(base::FilePath(L"dummy.exe")); |
21 good.AppendSwitch(switches::kNoFirstRun); // in whitelist | 21 good.AppendSwitch(switches::kNoFirstRun); // in whitelist |
22 good.AppendSwitch(switches::kDisableBackgroundMode); // in whitelist | 22 good.AppendSwitch(switches::kDisableBackgroundMode); // in whitelist |
23 good.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist | 23 good.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist |
24 | 24 |
25 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( | 25 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( |
26 good.GetCommandLineString().c_str())); | 26 good.GetCommandLineString().c_str())); |
27 | 27 |
28 CommandLine no_params(FilePath(L"dummy.exe")); | 28 CommandLine no_params(base::FilePath(L"dummy.exe")); |
29 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( | 29 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( |
30 no_params.GetCommandLineString().c_str())); | 30 no_params.GetCommandLineString().c_str())); |
31 | 31 |
32 CommandLine empty(FilePath(L"")); | 32 CommandLine empty(base::FilePath(L"")); |
33 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( | 33 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( |
34 empty.GetCommandLineString().c_str())); | 34 empty.GetCommandLineString().c_str())); |
35 } | 35 } |
36 | 36 |
37 TEST(ChromeLauncher, TrimWhiteSpace) { | 37 TEST(ChromeLauncher, TrimWhiteSpace) { |
38 std::wstring trimmed(chrome_launcher::TrimWhiteSpace(L" \t some text \n\t")); | 38 std::wstring trimmed(chrome_launcher::TrimWhiteSpace(L" \t some text \n\t")); |
39 EXPECT_STREQ(L"some text", trimmed.c_str()); | 39 EXPECT_STREQ(L"some text", trimmed.c_str()); |
40 | 40 |
41 std::wstring now_empty(chrome_launcher::TrimWhiteSpace(L"\t\t \n\t")); | 41 std::wstring now_empty(chrome_launcher::TrimWhiteSpace(L"\t\t \n\t")); |
42 EXPECT_STREQ(L"", now_empty.c_str()); | 42 EXPECT_STREQ(L"", now_empty.c_str()); |
(...skipping 23 matching lines...) Expand all Loading... |
66 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"chrome-frame")); | 66 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"chrome-frame")); |
67 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"-chrome-frame")); | 67 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"-chrome-frame")); |
68 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"---chrome-frame")); | 68 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"---chrome-frame")); |
69 EXPECT_FALSE(chrome_launcher::IsValidArgument(L" --chrome-frame")); | 69 EXPECT_FALSE(chrome_launcher::IsValidArgument(L" --chrome-frame")); |
70 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-framefoobar")); | 70 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-framefoobar")); |
71 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"foobar--chrome-frame")); | 71 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"foobar--chrome-frame")); |
72 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-frames")); | 72 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-frames")); |
73 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--Chrome-frame")); | 73 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--Chrome-frame")); |
74 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"")); | 74 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"")); |
75 } | 75 } |
OLD | NEW |