Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / common / switch_utils_unittest.cc
blobf7bb44dcc5dc3e7572598479718abc013092f11c
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 "chrome/common/switch_utils.h"
7 #include "base/basictypes.h"
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(SwitchUtilsTest, RemoveSwitches) {
13 const base::CommandLine::CharType* argv[] = {
14 FILE_PATH_LITERAL("program"),
15 FILE_PATH_LITERAL("--app=http://www.google.com/"),
16 FILE_PATH_LITERAL("--force-first-run"),
17 FILE_PATH_LITERAL("--make-default-browser"),
18 FILE_PATH_LITERAL("--foo"),
19 FILE_PATH_LITERAL("--bar")};
20 base::CommandLine cmd_line(arraysize(argv), argv);
21 EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
23 std::map<std::string, base::CommandLine::StringType> switches =
24 cmd_line.GetSwitches();
25 EXPECT_EQ(5U, switches.size());
27 switches::RemoveSwitchesForAutostart(&switches);
28 EXPECT_EQ(2U, switches.size());
29 EXPECT_TRUE(cmd_line.HasSwitch("foo"));
30 EXPECT_TRUE(cmd_line.HasSwitch("bar"));
33 #if defined(OS_WIN)
34 TEST(SwitchUtilsTest, RemoveSwitchesFromString) {
35 // All these command line args (except foo and bar) will
36 // be removed after RemoveSwitchesForAutostart:
37 base::CommandLine cmd_line = base::CommandLine::FromString(
38 L"program"
39 L" --app=http://www.google.com/"
40 L" --force-first-run"
41 L" --make-default-browser"
42 L" --foo"
43 L" --bar");
44 EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
46 std::map<std::string, base::CommandLine::StringType> switches =
47 cmd_line.GetSwitches();
48 EXPECT_EQ(5U, switches.size());
50 switches::RemoveSwitchesForAutostart(&switches);
51 EXPECT_EQ(2U, switches.size());
52 EXPECT_TRUE(cmd_line.HasSwitch("foo"));
53 EXPECT_TRUE(cmd_line.HasSwitch("bar"));
55 #endif