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

Side by Side Diff: chrome_frame/chrome_launcher_unittest.cc

Issue 8070019: Don't allow Chrome to go into background mode when launched by GCF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: knitting Created 9 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_launcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(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(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.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist 23 good.AppendSwitchASCII(switches::kUserDataDir, "foo"); // in whitelist
23 24
24 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( 25 EXPECT_TRUE(chrome_launcher::IsValidCommandLine(
25 good.GetCommandLineString().c_str())); 26 good.GetCommandLineString().c_str()));
26 27
27 CommandLine no_params(FilePath(L"dummy.exe")); 28 CommandLine no_params(FilePath(L"dummy.exe"));
28 EXPECT_TRUE(chrome_launcher::IsValidCommandLine( 29 EXPECT_TRUE(chrome_launcher::IsValidCommandLine(
29 no_params.GetCommandLineString().c_str())); 30 no_params.GetCommandLineString().c_str()));
30 31
31 CommandLine empty(FilePath(L"")); 32 CommandLine empty(FilePath(L""));
(...skipping 16 matching lines...) Expand all
48 49
49 std::wstring trimmed_right(chrome_launcher::TrimWhiteSpace(L"foo bar\t")); 50 std::wstring trimmed_right(chrome_launcher::TrimWhiteSpace(L"foo bar\t"));
50 EXPECT_STREQ(L"foo bar", trimmed_right.c_str()); 51 EXPECT_STREQ(L"foo bar", trimmed_right.c_str());
51 52
52 std::wstring trimmed_left(chrome_launcher::TrimWhiteSpace(L"\nfoo bar")); 53 std::wstring trimmed_left(chrome_launcher::TrimWhiteSpace(L"\nfoo bar"));
53 EXPECT_STREQ(L"foo bar", trimmed_right.c_str()); 54 EXPECT_STREQ(L"foo bar", trimmed_right.c_str());
54 } 55 }
55 56
56 TEST(ChromeLauncher, IsValidArgument) { 57 TEST(ChromeLauncher, IsValidArgument) {
57 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame")); 58 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame"));
59 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--disable-background-mode"));
58 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--invalid-arg")); 60 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--invalid-arg"));
59 61
60 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=")); 62 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame="));
61 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo")); 63 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo"));
62 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo=foo")); 64 EXPECT_TRUE(chrome_launcher::IsValidArgument(L"--chrome-frame=foo=foo"));
63 65
64 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"chrome-frame")); 66 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"chrome-frame"));
65 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"-chrome-frame")); 67 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"-chrome-frame"));
66 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"---chrome-frame")); 68 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"---chrome-frame"));
67 EXPECT_FALSE(chrome_launcher::IsValidArgument(L" --chrome-frame")); 69 EXPECT_FALSE(chrome_launcher::IsValidArgument(L" --chrome-frame"));
68 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-framefoobar")); 70 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-framefoobar"));
69 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"foobar--chrome-frame")); 71 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"foobar--chrome-frame"));
70 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-frames")); 72 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--chrome-frames"));
71 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--Chrome-frame")); 73 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"--Chrome-frame"));
72 EXPECT_FALSE(chrome_launcher::IsValidArgument(L"")); 74 EXPECT_FALSE(chrome_launcher::IsValidArgument(L""));
73 } 75 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_launcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698