Index: chrome/common/switch_utils_unittest.cc |
diff --git a/chrome/common/switch_utils_unittest.cc b/chrome/common/switch_utils_unittest.cc |
index 20da818f816a9dd617d591811a56a0ebf29e3800..92ccb10816b235ef9a95703587053e86a1039634 100644 |
--- a/chrome/common/switch_utils_unittest.cc |
+++ b/chrome/common/switch_utils_unittest.cc |
@@ -11,7 +11,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
TEST(SwitchUtilsTest, RemoveSwitches) { |
- const base::CommandLine::CharType* argv[] = { |
+ static const base::CommandLine::CharType* argv[] = { |
FILE_PATH_LITERAL("program"), |
FILE_PATH_LITERAL("--app=http://www.google.com/"), |
FILE_PATH_LITERAL("--force-first-run"), |
@@ -53,4 +53,63 @@ TEST(SwitchUtilsTest, RemoveSwitchesFromString) { |
EXPECT_TRUE(cmd_line.HasSwitch("foo")); |
EXPECT_TRUE(cmd_line.HasSwitch("bar")); |
} |
+ |
+TEST(SwitchUtilsTest, RemovePrefetchSwitch) { |
+ static const base::CommandLine::CharType* argv[] = { |
+ FILE_PATH_LITERAL("program"), |
+ FILE_PATH_LITERAL("--foo"), |
+ FILE_PATH_LITERAL("/prefetch:1"), |
+ FILE_PATH_LITERAL("--bar")}; |
+ base::CommandLine cmd_line(arraysize(argv), argv); |
+ EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); |
+ |
+ std::map<std::string, base::CommandLine::StringType> switches = |
+ cmd_line.GetSwitches(); |
+ EXPECT_EQ(3U, switches.size()); |
+ |
+ switches::RemoveSwitchesForAutostart(&switches); |
+ EXPECT_EQ(2U, switches.size()); |
+ EXPECT_TRUE(cmd_line.HasSwitch("foo")); |
+ EXPECT_TRUE(cmd_line.HasSwitch("bar")); |
+} |
+ |
+TEST(SwitchUtilsTest, RemovePrefetchSwitches) { |
+ static const base::CommandLine::CharType* argv[] = { |
+ FILE_PATH_LITERAL("program"), |
+ FILE_PATH_LITERAL("--foo"), |
+ FILE_PATH_LITERAL("/prefetch:1"), |
+ FILE_PATH_LITERAL("/prefetch:2"), |
gab
2016/02/25 20:22:23
As mentioned above, don't think we should support
fdoray
2016/02/26 18:10:36
Done.
|
+ FILE_PATH_LITERAL("--bar")}; |
+ base::CommandLine cmd_line(arraysize(argv), argv); |
+ EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); |
+ |
+ std::map<std::string, base::CommandLine::StringType> switches = |
+ cmd_line.GetSwitches(); |
+ EXPECT_EQ(4U, switches.size()); |
+ |
+ switches::RemoveSwitchesForAutostart(&switches); |
+ EXPECT_EQ(2U, switches.size()); |
+ EXPECT_TRUE(cmd_line.HasSwitch("foo")); |
+ EXPECT_TRUE(cmd_line.HasSwitch("bar")); |
+} |
+ |
+TEST(SwitchUtilsTest, RemovePrefetchSwitchAndNormalSwitch) { |
+ static const base::CommandLine::CharType* argv[] = { |
+ FILE_PATH_LITERAL("program"), |
+ FILE_PATH_LITERAL("--foo"), |
+ FILE_PATH_LITERAL("/prefetch:1"), |
+ FILE_PATH_LITERAL("--force-first-run"), |
+ FILE_PATH_LITERAL("--bar")}; |
+ base::CommandLine cmd_line(arraysize(argv), argv); |
+ EXPECT_FALSE(cmd_line.GetCommandLineString().empty()); |
+ |
+ std::map<std::string, base::CommandLine::StringType> switches = |
+ cmd_line.GetSwitches(); |
+ EXPECT_EQ(4U, switches.size()); |
+ |
+ switches::RemoveSwitchesForAutostart(&switches); |
+ EXPECT_EQ(2U, switches.size()); |
+ EXPECT_TRUE(cmd_line.HasSwitch("foo")); |
+ EXPECT_TRUE(cmd_line.HasSwitch("bar")); |
+} |
#endif |