Index: chrome/browser/about_flags_unittest.cc |
diff --git a/chrome/browser/about_flags_unittest.cc b/chrome/browser/about_flags_unittest.cc |
index f14651d27fecf310d6802943fbff47e64adc4572..28adaccfc6cf1c9db706c9a996339f358fdab1c3 100644 |
--- a/chrome/browser/about_flags_unittest.cc |
+++ b/chrome/browser/about_flags_unittest.cc |
@@ -188,22 +188,21 @@ std::string FilePathStringTypeToString(const base::FilePath::StringType& path) { |
std::set<std::string> GetAllSwitchesForTesting() { |
std::set<std::string> result; |
- size_t num_experiments = 0; |
- const Experiment* experiments = |
- testing::GetExperiments(&num_experiments); |
- |
- for (size_t i = 0; i < num_experiments; ++i) { |
- const Experiment& experiment = experiments[i]; |
- if (experiment.type == Experiment::SINGLE_VALUE) { |
- result.insert(experiment.command_line_switch); |
- } else if (experiment.type == Experiment::MULTI_VALUE) { |
- for (int j = 0; j < experiment.num_choices; ++j) { |
- result.insert(experiment.choices[j].command_line_switch); |
+ size_t num_entries = 0; |
+ const Entry* entries = testing::GetEntries(&num_entries); |
+ |
+ for (size_t i = 0; i < num_entries; ++i) { |
+ const Entry& entry = entries[i]; |
+ if (entry.type == Entry::SINGLE_VALUE) { |
+ result.insert(entry.command_line_switch); |
+ } else if (entry.type == Entry::MULTI_VALUE) { |
+ for (int j = 0; j < entry.num_choices; ++j) { |
+ result.insert(entry.choices[j].command_line_switch); |
} |
} else { |
- DCHECK_EQ(experiment.type, Experiment::ENABLE_DISABLE_VALUE); |
- result.insert(experiment.command_line_switch); |
- result.insert(experiment.disable_command_line_switch); |
+ DCHECK_EQ(entry.type, Entry::ENABLE_DISABLE_VALUE); |
+ result.insert(entry.command_line_switch); |
+ result.insert(entry.disable_command_line_switch); |
} |
} |
return result; |
@@ -211,21 +210,21 @@ std::set<std::string> GetAllSwitchesForTesting() { |
} // anonymous namespace |
-const Experiment::Choice kMultiChoices[] = { |
+const Entry::Choice kMultiChoices[] = { |
{ IDS_PRODUCT_NAME, "", "" }, |
{ IDS_PRODUCT_NAME, kMultiSwitch1, "" }, |
{ IDS_PRODUCT_NAME, kMultiSwitch2, kValueForMultiSwitch2 }, |
}; |
-// The experiments that are set for these tests. The 3rd experiment is not |
-// supported on the current platform, all others are. |
-static Experiment kExperiments[] = { |
+// The entries that are set for these tests. The 3rd entry is not supported on |
+// the current platform, all others are. |
+static Entry kEntries[] = { |
{ |
kFlags1, |
IDS_PRODUCT_NAME, |
IDS_PRODUCT_NAME, |
0, // Ends up being mapped to the current platform. |
- Experiment::SINGLE_VALUE, |
+ Entry::SINGLE_VALUE, |
kSwitch1, |
"", |
NULL, |
@@ -238,7 +237,7 @@ static Experiment kExperiments[] = { |
IDS_PRODUCT_NAME, |
IDS_PRODUCT_NAME, |
0, // Ends up being mapped to the current platform. |
- Experiment::SINGLE_VALUE, |
+ Entry::SINGLE_VALUE, |
kSwitch2, |
kValueForSwitch2, |
NULL, |
@@ -251,7 +250,7 @@ static Experiment kExperiments[] = { |
IDS_PRODUCT_NAME, |
IDS_PRODUCT_NAME, |
0, // This ends up enabling for an OS other than the current. |
- Experiment::SINGLE_VALUE, |
+ Entry::SINGLE_VALUE, |
kSwitch3, |
"", |
NULL, |
@@ -264,7 +263,7 @@ static Experiment kExperiments[] = { |
IDS_PRODUCT_NAME, |
IDS_PRODUCT_NAME, |
0, // Ends up being mapped to the current platform. |
- Experiment::MULTI_VALUE, |
+ Entry::MULTI_VALUE, |
"", |
"", |
"", |
@@ -277,7 +276,7 @@ static Experiment kExperiments[] = { |
IDS_PRODUCT_NAME, |
IDS_PRODUCT_NAME, |
0, // Ends up being mapped to the current platform. |
- Experiment::ENABLE_DISABLE_VALUE, |
+ Entry::ENABLE_DISABLE_VALUE, |
kSwitch1, |
kEnableDisableValue1, |
kSwitch2, |
@@ -295,18 +294,18 @@ class AboutFlagsTest : public ::testing::Test { |
} |
void SetUp() override { |
- for (size_t i = 0; i < arraysize(kExperiments); ++i) |
- kExperiments[i].supported_platforms = GetCurrentPlatform(); |
+ for (size_t i = 0; i < arraysize(kEntries); ++i) |
+ kEntries[i].supported_platforms = GetCurrentPlatform(); |
int os_other_than_current = 1; |
while (os_other_than_current == GetCurrentPlatform()) |
os_other_than_current <<= 1; |
- kExperiments[2].supported_platforms = os_other_than_current; |
+ kEntries[2].supported_platforms = os_other_than_current; |
- testing::SetExperiments(kExperiments, arraysize(kExperiments)); |
+ testing::SetEntries(kEntries, arraysize(kEntries)); |
} |
- void TearDown() override { testing::SetExperiments(NULL, 0); } |
+ void TearDown() override { testing::SetEntries(NULL, 0); } |
TestingPrefServiceSimple prefs_; |
PrefServiceFlagsStorage flags_storage_; |
@@ -315,76 +314,76 @@ class AboutFlagsTest : public ::testing::Test { |
TEST_F(AboutFlagsTest, NoChangeNoRestart) { |
EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
- SetExperimentEnabled(&flags_storage_, kFlags1, false); |
+ SetEntryEnabled(&flags_storage_, kFlags1, false); |
EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
} |
TEST_F(AboutFlagsTest, ChangeNeedsRestart) { |
EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
} |
TEST_F(AboutFlagsTest, MultiFlagChangeNeedsRestart) { |
- const Experiment& experiment = kExperiments[3]; |
- ASSERT_EQ(kFlags4, experiment.internal_name); |
+ const Entry& entry = kEntries[3]; |
+ ASSERT_EQ(kFlags4, entry.internal_name); |
EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
// Enable the 2nd choice of the multi-value. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
testing::ClearState(); |
EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
// Enable the default choice now. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
} |
TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) { |
- // Add two experiments, check they're there. |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
- SetExperimentEnabled(&flags_storage_, kFlags2, true); |
+ // Add two entries, check they're there. |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags2, true); |
- const base::ListValue* experiments_list = prefs_.GetList( |
+ const base::ListValue* entry_list = prefs_.GetList( |
prefs::kEnabledLabsExperiments); |
- ASSERT_TRUE(experiments_list != NULL); |
+ ASSERT_TRUE(entry_list != NULL); |
- ASSERT_EQ(2u, experiments_list->GetSize()); |
+ ASSERT_EQ(2u, entry_list->GetSize()); |
std::string s0; |
- ASSERT_TRUE(experiments_list->GetString(0, &s0)); |
+ ASSERT_TRUE(entry_list->GetString(0, &s0)); |
std::string s1; |
- ASSERT_TRUE(experiments_list->GetString(1, &s1)); |
+ ASSERT_TRUE(entry_list->GetString(1, &s1)); |
EXPECT_TRUE(s0 == kFlags1 || s1 == kFlags1); |
EXPECT_TRUE(s0 == kFlags2 || s1 == kFlags2); |
- // Remove one experiment, check the other's still around. |
- SetExperimentEnabled(&flags_storage_, kFlags2, false); |
+ // Remove one entry, check the other's still around. |
+ SetEntryEnabled(&flags_storage_, kFlags2, false); |
- experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); |
- ASSERT_TRUE(experiments_list != NULL); |
- ASSERT_EQ(1u, experiments_list->GetSize()); |
- ASSERT_TRUE(experiments_list->GetString(0, &s0)); |
+ entry_list = prefs_.GetList(prefs::kEnabledLabsExperiments); |
+ ASSERT_TRUE(entry_list != NULL); |
+ ASSERT_EQ(1u, entry_list->GetSize()); |
+ ASSERT_TRUE(entry_list->GetString(0, &s0)); |
EXPECT_TRUE(s0 == kFlags1); |
} |
TEST_F(AboutFlagsTest, AddTwoFlagsRemoveBoth) { |
- // Add two experiments, check the pref exists. |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
- SetExperimentEnabled(&flags_storage_, kFlags2, true); |
- const base::ListValue* experiments_list = prefs_.GetList( |
+ // Add two entries, check the pref exists. |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags2, true); |
+ const base::ListValue* entry_list = prefs_.GetList( |
prefs::kEnabledLabsExperiments); |
- ASSERT_TRUE(experiments_list != NULL); |
+ ASSERT_TRUE(entry_list != NULL); |
// Remove both, the pref should have been removed completely. |
- SetExperimentEnabled(&flags_storage_, kFlags1, false); |
- SetExperimentEnabled(&flags_storage_, kFlags2, false); |
- experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); |
- EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); |
+ SetEntryEnabled(&flags_storage_, kFlags1, false); |
+ SetEntryEnabled(&flags_storage_, kFlags2, false); |
+ entry_list = prefs_.GetList(prefs::kEnabledLabsExperiments); |
+ EXPECT_TRUE(entry_list == NULL || entry_list->GetSize() == 0); |
} |
TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
command_line.AppendSwitch("foo"); |
@@ -417,7 +416,7 @@ base::CommandLine::StringType CreateSwitch(const std::string& value) { |
} |
TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
const std::string kDoubleDash("--"); |
@@ -449,8 +448,8 @@ TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { |
} |
// Now both have flags but different. |
- SetExperimentEnabled(&flags_storage_, kFlags1, false); |
- SetExperimentEnabled(&flags_storage_, kFlags2, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, false); |
+ SetEntryEnabled(&flags_storage_, kFlags2, true); |
base::CommandLine another_command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels); |
@@ -476,7 +475,7 @@ TEST_F(AboutFlagsTest, RemoveFlagSwitches) { |
switch_list[switches::kFlagSwitchesEnd] = base::CommandLine::StringType(); |
switch_list["foo"] = base::CommandLine::StringType(); |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
// This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. |
RemoveFlagsSwitches(&switch_list); |
@@ -502,28 +501,28 @@ TEST_F(AboutFlagsTest, RemoveFlagSwitches) { |
// Tests enabling experiments that aren't supported on the current platform. |
TEST_F(AboutFlagsTest, PersistAndPrune) { |
// Enable experiments 1 and 3. |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
- SetExperimentEnabled(&flags_storage_, kFlags3, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags3, true); |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
- // Convert the flags to switches. Experiment 3 shouldn't be among the switches |
+ // Convert the flags to switches. Entry 3 shouldn't be among the switches |
// as it is not applicable to the current platform. |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
- // Experiment 3 should show still be persisted in preferences though. |
- const base::ListValue* experiments_list = |
+ // Entry 3 should show still be persisted in preferences though. |
+ const base::ListValue* entry_list = |
prefs_.GetList(prefs::kEnabledLabsExperiments); |
- ASSERT_TRUE(experiments_list); |
- EXPECT_EQ(2U, experiments_list->GetSize()); |
+ ASSERT_TRUE(entry_list); |
+ EXPECT_EQ(2U, entry_list->GetSize()); |
std::string s0; |
- ASSERT_TRUE(experiments_list->GetString(0, &s0)); |
+ ASSERT_TRUE(entry_list->GetString(0, &s0)); |
EXPECT_EQ(kFlags1, s0); |
std::string s1; |
- ASSERT_TRUE(experiments_list->GetString(1, &s1)); |
+ ASSERT_TRUE(entry_list->GetString(1, &s1)); |
EXPECT_EQ(kFlags3, s1); |
} |
@@ -531,8 +530,8 @@ TEST_F(AboutFlagsTest, PersistAndPrune) { |
// line. |
TEST_F(AboutFlagsTest, CheckValues) { |
// Enable experiments 1 and 2. |
- SetExperimentEnabled(&flags_storage_, kFlags1, true); |
- SetExperimentEnabled(&flags_storage_, kFlags2, true); |
+ SetEntryEnabled(&flags_storage_, kFlags1, true); |
+ SetEntryEnabled(&flags_storage_, kFlags2, true); |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
@@ -572,22 +571,22 @@ TEST_F(AboutFlagsTest, CheckValues) { |
#endif |
// And it should persist. |
- const base::ListValue* experiments_list = |
+ const base::ListValue* entry_list = |
prefs_.GetList(prefs::kEnabledLabsExperiments); |
- ASSERT_TRUE(experiments_list); |
- EXPECT_EQ(2U, experiments_list->GetSize()); |
+ ASSERT_TRUE(entry_list); |
+ EXPECT_EQ(2U, entry_list->GetSize()); |
std::string s0; |
- ASSERT_TRUE(experiments_list->GetString(0, &s0)); |
+ ASSERT_TRUE(entry_list->GetString(0, &s0)); |
EXPECT_EQ(kFlags1, s0); |
std::string s1; |
- ASSERT_TRUE(experiments_list->GetString(1, &s1)); |
+ ASSERT_TRUE(entry_list->GetString(1, &s1)); |
EXPECT_EQ(kFlags2, s1); |
} |
// Tests multi-value type experiments. |
TEST_F(AboutFlagsTest, MultiValues) { |
- const Experiment& experiment = kExperiments[3]; |
- ASSERT_EQ(kFlags4, experiment.internal_name); |
+ const Entry& entry = kEntries[3]; |
+ ASSERT_EQ(kFlags4, entry.internal_name); |
// Initially, the first "deactivated" option of the multi experiment should |
// be set. |
@@ -599,7 +598,7 @@ TEST_F(AboutFlagsTest, MultiValues) { |
} |
// Enable the 2nd choice of the multi-value. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
{ |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
@@ -609,8 +608,8 @@ TEST_F(AboutFlagsTest, MultiValues) { |
command_line.GetSwitchValueASCII(kMultiSwitch2)); |
} |
- // Disable the multi-value experiment. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); |
+ // Disable the multi-value entry. |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
{ |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
@@ -620,8 +619,8 @@ TEST_F(AboutFlagsTest, MultiValues) { |
} |
TEST_F(AboutFlagsTest, EnableDisableValues) { |
- const Experiment& experiment = kExperiments[4]; |
- ASSERT_EQ(kFlags5, experiment.internal_name); |
+ const Entry& entry = kEntries[4]; |
+ ASSERT_EQ(kFlags5, entry.internal_name); |
// Nothing selected. |
{ |
@@ -632,7 +631,7 @@ TEST_F(AboutFlagsTest, EnableDisableValues) { |
} |
// "Enable" option selected. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(1), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(1), true); |
{ |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
@@ -642,7 +641,7 @@ TEST_F(AboutFlagsTest, EnableDisableValues) { |
} |
// "Disable" option selected. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
{ |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
@@ -652,7 +651,7 @@ TEST_F(AboutFlagsTest, EnableDisableValues) { |
} |
// "Default" option selected, same as nothing selected. |
- SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); |
+ SetEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
{ |
base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
@@ -663,11 +662,11 @@ TEST_F(AboutFlagsTest, EnableDisableValues) { |
// Makes sure there are no separators in any of the experiment names. |
TEST_F(AboutFlagsTest, NoSeparators) { |
- testing::SetExperiments(NULL, 0); |
+ testing::SetEntries(NULL, 0); |
size_t count; |
- const Experiment* experiments = testing::GetExperiments(&count); |
- for (size_t i = 0; i < count; ++i) { |
- std::string name = experiments->internal_name; |
+ const Entry* entries = testing::GetEntries(&count); |
+ for (size_t i = 0; i < count; ++i) { |
+ std::string name = entries[i].internal_name; |
EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; |
} |
} |