| 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/prefs/pref_registry_simple.h" | 5 #include "base/prefs/pref_registry_simple.h" |
| 6 #include "base/prefs/testing_pref_service.h" | 6 #include "base/prefs/testing_pref_service.h" |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/about_flags.h" | 10 #include "chrome/browser/about_flags.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 260 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 261 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 261 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
| 262 | 262 |
| 263 // Convert the flags to switches. Experiment 3 shouldn't be among the switches | 263 // Convert the flags to switches. Experiment 3 shouldn't be among the switches |
| 264 // as it is not applicable to the current platform. | 264 // as it is not applicable to the current platform. |
| 265 ConvertFlagsToSwitches(&prefs_, &command_line); | 265 ConvertFlagsToSwitches(&prefs_, &command_line); |
| 266 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 266 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
| 267 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 267 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
| 268 | 268 |
| 269 // Experiment 3 should show still be persisted in preferences though. | 269 // Experiment 3 should show still be persisted in preferences though. |
| 270 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); | 270 scoped_ptr<ListValue> switch_prefs( |
| 271 GetFlagsExperimentsData(&prefs_, kOwnerAccessToFlags)); |
| 271 ASSERT_TRUE(switch_prefs.get()); | 272 ASSERT_TRUE(switch_prefs.get()); |
| 272 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); | 273 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); |
| 273 } | 274 } |
| 274 | 275 |
| 275 // Tests that switches which should have values get them in the command | 276 // Tests that switches which should have values get them in the command |
| 276 // line. | 277 // line. |
| 277 TEST_F(AboutFlagsTest, CheckValues) { | 278 TEST_F(AboutFlagsTest, CheckValues) { |
| 278 // Enable experiments 1 and 2. | 279 // Enable experiments 1 and 2. |
| 279 SetExperimentEnabled(&prefs_, kFlags1, true); | 280 SetExperimentEnabled(&prefs_, kFlags1, true); |
| 280 SetExperimentEnabled(&prefs_, kFlags2, true); | 281 SetExperimentEnabled(&prefs_, kFlags2, true); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 310 #if defined(OS_WIN) | 311 #if defined(OS_WIN) |
| 311 EXPECT_NE(std::wstring::npos, | 312 EXPECT_NE(std::wstring::npos, |
| 312 command_line.GetCommandLineString().find( | 313 command_line.GetCommandLineString().find( |
| 313 ASCIIToWide(switch2_with_equals))); | 314 ASCIIToWide(switch2_with_equals))); |
| 314 #else | 315 #else |
| 315 EXPECT_NE(std::string::npos, | 316 EXPECT_NE(std::string::npos, |
| 316 command_line.GetCommandLineString().find(switch2_with_equals)); | 317 command_line.GetCommandLineString().find(switch2_with_equals)); |
| 317 #endif | 318 #endif |
| 318 | 319 |
| 319 // And it should persist | 320 // And it should persist |
| 320 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); | 321 scoped_ptr<ListValue> switch_prefs( |
| 322 GetFlagsExperimentsData(&prefs_, kOwnerAccessToFlags)); |
| 321 ASSERT_TRUE(switch_prefs.get()); | 323 ASSERT_TRUE(switch_prefs.get()); |
| 322 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); | 324 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); |
| 323 } | 325 } |
| 324 | 326 |
| 325 // Tests multi-value type experiments. | 327 // Tests multi-value type experiments. |
| 326 TEST_F(AboutFlagsTest, MultiValues) { | 328 TEST_F(AboutFlagsTest, MultiValues) { |
| 327 const Experiment& experiment = kExperiments[3]; | 329 const Experiment& experiment = kExperiments[3]; |
| 328 ASSERT_EQ(kFlags4, experiment.internal_name); | 330 ASSERT_EQ(kFlags4, experiment.internal_name); |
| 329 | 331 |
| 330 // Initially, the first "deactivated" option of the multi experiment should | 332 // Initially, the first "deactivated" option of the multi experiment should |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 testing::SetExperiments(NULL, 0); | 406 testing::SetExperiments(NULL, 0); |
| 405 size_t count; | 407 size_t count; |
| 406 const Experiment* experiments = testing::GetExperiments(&count); | 408 const Experiment* experiments = testing::GetExperiments(&count); |
| 407 for (size_t i = 0; i < count; ++i) { | 409 for (size_t i = 0; i < count; ++i) { |
| 408 std::string name = experiments->internal_name; | 410 std::string name = experiments->internal_name; |
| 409 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; | 411 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; |
| 410 } | 412 } |
| 411 } | 413 } |
| 412 | 414 |
| 413 } // namespace about_flags | 415 } // namespace about_flags |
| OLD | NEW |