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

Side by Side Diff: chrome/common/switch_utils_unittest.cc

Issue 11636031: [Fixit Dec-2012] Refactor first_run, very few things should depend on whether the First Run senti... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No first run import test on OS_CHROMEOS. Created 7 years, 11 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/common/switch_utils.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | 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 "chrome/common/switch_utils.h" 5 #include "chrome/common/switch_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 TEST(SwitchUtilsTest, RemoveSwitches) { 12 TEST(SwitchUtilsTest, RemoveSwitches) {
13 const CommandLine::CharType* argv[] = { 13 const CommandLine::CharType* argv[] = {
14 FILE_PATH_LITERAL("program"), 14 FILE_PATH_LITERAL("program"),
15 FILE_PATH_LITERAL("--app=http://www.google.com/"), 15 FILE_PATH_LITERAL("--app=http://www.google.com/"),
16 FILE_PATH_LITERAL("--first-run"), 16 FILE_PATH_LITERAL("--force-first-run"),
17 FILE_PATH_LITERAL("--import"), 17 FILE_PATH_LITERAL("--import"),
18 FILE_PATH_LITERAL("--import-from-file=c:\\test.html"), 18 FILE_PATH_LITERAL("--import-from-file=c:\\test.html"),
19 FILE_PATH_LITERAL("--make-default-browser"), 19 FILE_PATH_LITERAL("--make-default-browser"),
20 FILE_PATH_LITERAL("--foo"), 20 FILE_PATH_LITERAL("--foo"),
21 FILE_PATH_LITERAL("--bar")}; 21 FILE_PATH_LITERAL("--bar")};
22 CommandLine cmd_line(arraysize(argv), argv); 22 CommandLine cmd_line(arraysize(argv), argv);
23 EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); 23 EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
24 24
25 std::map<std::string, CommandLine::StringType> switches = 25 std::map<std::string, CommandLine::StringType> switches =
26 cmd_line.GetSwitches(); 26 cmd_line.GetSwitches();
27 EXPECT_EQ(7U, switches.size()); 27 EXPECT_EQ(7U, switches.size());
28 28
29 switches::RemoveSwitchesForAutostart(&switches); 29 switches::RemoveSwitchesForAutostart(&switches);
30 EXPECT_EQ(2U, switches.size()); 30 EXPECT_EQ(2U, switches.size());
31 EXPECT_TRUE(cmd_line.HasSwitch("foo")); 31 EXPECT_TRUE(cmd_line.HasSwitch("foo"));
32 EXPECT_TRUE(cmd_line.HasSwitch("bar")); 32 EXPECT_TRUE(cmd_line.HasSwitch("bar"));
33 } 33 }
34 34
35 #if defined(OS_WIN) 35 #if defined(OS_WIN)
36 TEST(SwitchUtilsTest, RemoveSwitchesFromString) { 36 TEST(SwitchUtilsTest, RemoveSwitchesFromString) {
37 // All these command line args (except foo and bar) will 37 // All these command line args (except foo and bar) will
38 // be removed after RemoveSwitchesForAutostart: 38 // be removed after RemoveSwitchesForAutostart:
39 CommandLine cmd_line = CommandLine::FromString( 39 CommandLine cmd_line = CommandLine::FromString(
40 L"program" 40 L"program"
41 L" --app=http://www.google.com/" 41 L" --app=http://www.google.com/"
42 L" --first-run" 42 L" --force-first-run"
43 L" --import" 43 L" --import"
44 L" --import-from-file=c:\\test.html" 44 L" --import-from-file=c:\\test.html"
45 L" --make-default-browser" 45 L" --make-default-browser"
46 L" --foo" 46 L" --foo"
47 L" --bar"); 47 L" --bar");
48 EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); 48 EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
49 49
50 std::map<std::string, CommandLine::StringType> switches = 50 std::map<std::string, CommandLine::StringType> switches =
51 cmd_line.GetSwitches(); 51 cmd_line.GetSwitches();
52 EXPECT_EQ(7U, switches.size()); 52 EXPECT_EQ(7U, switches.size());
53 53
54 switches::RemoveSwitchesForAutostart(&switches); 54 switches::RemoveSwitchesForAutostart(&switches);
55 EXPECT_EQ(2U, switches.size()); 55 EXPECT_EQ(2U, switches.size());
56 EXPECT_TRUE(cmd_line.HasSwitch("foo")); 56 EXPECT_TRUE(cmd_line.HasSwitch("foo"));
57 EXPECT_TRUE(cmd_line.HasSwitch("bar")); 57 EXPECT_TRUE(cmd_line.HasSwitch("bar"));
58 } 58 }
59 #endif 59 #endif
OLDNEW
« no previous file with comments | « chrome/common/switch_utils.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698