Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/about_flags.h" | 8 #include "chrome/browser/about_flags.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 216 |
| 217 // Convert the flags to switches. Experiment 3 shouldn't be among the switches | 217 // Convert the flags to switches. Experiment 3 shouldn't be among the switches |
| 218 // as it is not applicable to the current platform. | 218 // as it is not applicable to the current platform. |
| 219 ConvertFlagsToSwitches(&prefs_, &command_line); | 219 ConvertFlagsToSwitches(&prefs_, &command_line); |
| 220 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 220 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
| 221 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 221 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
| 222 | 222 |
| 223 // Experiment 3 should show still be persisted in preferences though. | 223 // Experiment 3 should show still be persisted in preferences though. |
| 224 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); | 224 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); |
| 225 ASSERT_TRUE(switch_prefs.get()); | 225 ASSERT_TRUE(switch_prefs.get()); |
| 226 EXPECT_EQ(arraysize(kExperiments) - 1, switch_prefs->GetSize()); | 226 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); |
|
Tyler Breisacher (Chromium)
2011/12/19 23:23:26
The kExperiments array used for testing has a few
| |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Tests that switches which should have values get them in the command | 229 // Tests that switches which should have values get them in the command |
| 230 // line. | 230 // line. |
| 231 TEST_F(AboutFlagsTest, CheckValues) { | 231 TEST_F(AboutFlagsTest, CheckValues) { |
| 232 // Enable experiments 1 and 2. | 232 // Enable experiments 1 and 2. |
| 233 SetExperimentEnabled(&prefs_, kFlags1, true); | 233 SetExperimentEnabled(&prefs_, kFlags1, true); |
| 234 SetExperimentEnabled(&prefs_, kFlags2, true); | 234 SetExperimentEnabled(&prefs_, kFlags2, true); |
| 235 CommandLine command_line(CommandLine::NO_PROGRAM); | 235 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 236 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 236 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 266 command_line.GetCommandLineString().find( | 266 command_line.GetCommandLineString().find( |
| 267 ASCIIToWide(switch2_with_equals))); | 267 ASCIIToWide(switch2_with_equals))); |
| 268 #else | 268 #else |
| 269 EXPECT_NE(std::string::npos, | 269 EXPECT_NE(std::string::npos, |
| 270 command_line.GetCommandLineString().find(switch2_with_equals)); | 270 command_line.GetCommandLineString().find(switch2_with_equals)); |
| 271 #endif | 271 #endif |
| 272 | 272 |
| 273 // And it should persist | 273 // And it should persist |
| 274 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); | 274 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); |
| 275 ASSERT_TRUE(switch_prefs.get()); | 275 ASSERT_TRUE(switch_prefs.get()); |
| 276 EXPECT_EQ(arraysize(kExperiments) - 1, switch_prefs->GetSize()); | 276 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); |
| 277 } | 277 } |
| 278 | 278 |
| 279 // Tests multi-value type experiments. | 279 // Tests multi-value type experiments. |
| 280 TEST_F(AboutFlagsTest, MultiValues) { | 280 TEST_F(AboutFlagsTest, MultiValues) { |
| 281 // Initially, the first "deactivated" option of the multi experiment should | 281 // Initially, the first "deactivated" option of the multi experiment should |
| 282 // be set. | 282 // be set. |
| 283 { | 283 { |
| 284 CommandLine command_line(CommandLine::NO_PROGRAM); | 284 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 285 ConvertFlagsToSwitches(&prefs_, &command_line); | 285 ConvertFlagsToSwitches(&prefs_, &command_line); |
| 286 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 286 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 317 testing::SetExperiments(NULL, 0); | 317 testing::SetExperiments(NULL, 0); |
| 318 size_t count; | 318 size_t count; |
| 319 const Experiment* experiments = testing::GetExperiments(&count); | 319 const Experiment* experiments = testing::GetExperiments(&count); |
| 320 for (size_t i = 0; i < count; ++i) { | 320 for (size_t i = 0; i < count; ++i) { |
| 321 std::string name = experiments->internal_name; | 321 std::string name = experiments->internal_name; |
| 322 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; | 322 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace about_flags | 326 } // namespace about_flags |
| OLD | NEW |