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

Unified Diff: chrome/browser/about_flags_unittest.cc

Issue 344883002: Collect UMA statistics on which chrome://flags lead to chrome restart on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 4 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
Index: chrome/browser/about_flags_unittest.cc
diff --git a/chrome/browser/about_flags_unittest.cc b/chrome/browser/about_flags_unittest.cc
index 0cb9fa78835f36a552cf7fe0ffe1ed07170e7871..c8c426969ca89beee380cbd43187c547b3650480 100644
--- a/chrome/browser/about_flags_unittest.cc
+++ b/chrome/browser/about_flags_unittest.cc
@@ -233,22 +233,45 @@ TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) {
EXPECT_FALSE(command_line2.HasSwitch(switches::kFlagSwitchesEnd));
}
+CommandLine::StringType CreateSwitch(const std::string& value) {
+#if defined(OS_WIN)
+ return ASCIIToUTF16(value);
+#else
+ return value;
+#endif
+}
+
TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) {
SetExperimentEnabled(&flags_storage_, kFlags1, true);
+ const std::string kDoubleDash("--");
+
CommandLine command_line(CommandLine::NO_PROGRAM);
command_line.AppendSwitch("foo");
CommandLine new_command_line(CommandLine::NO_PROGRAM);
ConvertFlagsToSwitches(&flags_storage_, &new_command_line, kAddSentinels);
- EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
- command_line));
+ EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, command_line, NULL));
+ {
+ std::set<CommandLine::StringType> difference;
+ EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, command_line, &difference));
+ EXPECT_EQ(1U, difference.size());
+ EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1)));
+ }
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels);
- EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
- command_line));
+ EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, command_line, NULL));
+ {
+ std::set<CommandLine::StringType> difference;
+ EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, command_line, &difference));
+ EXPECT_TRUE(difference.empty());
+ }
// Now both have flags but different.
SetExperimentEnabled(&flags_storage_, kFlags1, false);
@@ -257,8 +280,18 @@ TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) {
CommandLine another_command_line(CommandLine::NO_PROGRAM);
ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels);
- EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
- another_command_line));
+ EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, another_command_line, NULL));
+ {
+ std::set<CommandLine::StringType> difference;
+ EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(
+ new_command_line, another_command_line, &difference));
+ EXPECT_EQ(2U, difference.size());
+ EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1)));
+ EXPECT_EQ(1U,
+ difference.count(CreateSwitch(kDoubleDash + kSwitch2 + "=" +
+ kValueForSwitch2)));
+ }
}
TEST_F(AboutFlagsTest, RemoveFlagSwitches) {

Powered by Google App Engine
This is Rietveld 408576698