roll skia to 5075
[chromium-blink-merge.git] / chrome_frame / chrome_launcher_unittest.cc
blob61c96dcd862d576770b71720df64ad0c167f16f9
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/file_path.h"
7 #include "chrome/common/chrome_switches.h"
8 #include "chrome_frame/chrome_launcher.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 TEST(ChromeLauncher, IsValidCommandLine) {
12 CommandLine bad(FilePath(L"dummy.exe"));
13 bad.AppendSwitch(switches::kNoFirstRun); // in whitelist
14 bad.AppendSwitch("no-such-switch"); // does not exist
15 bad.AppendSwitch(switches::kHomePage); // exists but not in whitelist
17 EXPECT_FALSE(chrome_launcher::IsValidCommandLine(
18 bad.GetCommandLineString().c_str()));
20 CommandLine good(FilePath(L"dummy.exe"));
21 good.AppendSwitch(switches::kNoFirstRun); // in whitelist
22 good.AppendSwitch(switches::kDisableBackgroundMode); // in whitelist
23 good.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist
25 EXPECT_TRUE(chrome_launcher::IsValidCommandLine(
26 good.GetCommandLineString().c_str()));
28 CommandLine no_params(FilePath(L"dummy.exe"));
29 EXPECT_TRUE(chrome_launcher::IsValidCommandLine(
30 no_params.GetCommandLineString().c_str()));
32 CommandLine empty(FilePath(L""));
33 EXPECT_TRUE(chrome_launcher::IsValidCommandLine(
34 empty.GetCommandLineString().c_str()));
37 TEST(ChromeLauncher, TrimWhiteSpace) {
38 std::wstring trimmed(chrome_launcher::TrimWhiteSpace(L" \t some text \n\t"));
39 EXPECT_STREQ(L"some text", trimmed.c_str());
41 std::wstring now_empty(chrome_launcher::TrimWhiteSpace(L"\t\t \n\t"));
42 EXPECT_STREQ(L"", now_empty.c_str());
44 std::wstring empty(chrome_launcher::TrimWhiteSpace(L""));
45 EXPECT_STREQ(L"", empty.c_str());
47 std::wstring not_trimmed(chrome_launcher::TrimWhiteSpace(L"foo bar"));
48 EXPECT_STREQ(L"foo bar", not_trimmed.c_str());
50 std::wstring trimmed_right(chrome_launcher::TrimWhiteSpace(L"foo bar\t"));
51 EXPECT_STREQ(L"foo bar", trimmed_right.c_str());
53 std::wstring trimmed_left(chrome_launcher::TrimWhiteSpace(L"\nfoo bar"));
54 EXPECT_STREQ(L"foo bar", trimmed_right.c_str());
57 TEST(ChromeLauncher, IsValidArgument) {
58 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame"));
59 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--disable-background-mode"));
60 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--invalid-arg"));
62 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame="));
63 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo"));
64 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo=foo"));
66 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"));
69 EXPECT_FALSE(chrome_launcher::IsValidArgument(L" --chrome-frame"));
70 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-framefoobar"));
71 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"foobar--chrome-frame"));
72 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-frames"));
73 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--Chrome-frame"));
74 EXPECT_FALSE(chrome_launcher::IsValidArgument(L""));