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

Unified Diff: chrome/common/switch_utils_unittest.cc

Issue 1734053002: Remove the current /prefetch switch when relaunching Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/switch_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b02bc3748f4e1bcfd3125e1f1e5604e3a70a29d 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,43 @@ 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, 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
« no previous file with comments | « chrome/common/switch_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698