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/strings/utf_string_conversions.h" | 8 #include "base/strings/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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 EXPECT_TRUE(command_line.HasSwitch("foo")); | 215 EXPECT_TRUE(command_line.HasSwitch("foo")); |
216 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 216 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
217 | 217 |
218 ConvertFlagsToSwitches(&prefs_, &command_line); | 218 ConvertFlagsToSwitches(&prefs_, &command_line); |
219 | 219 |
220 EXPECT_TRUE(command_line.HasSwitch("foo")); | 220 EXPECT_TRUE(command_line.HasSwitch("foo")); |
221 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 221 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
222 } | 222 } |
223 | 223 |
| 224 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { |
| 225 SetExperimentEnabled(&prefs_, kFlags1, true); |
| 226 |
| 227 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 228 command_line.AppendSwitch("foo"); |
| 229 |
| 230 CommandLine new_command_line(CommandLine::NO_PROGRAM); |
| 231 ConvertFlagsToSwitches(&prefs_, &new_command_line); |
| 232 |
| 233 EXPECT_FALSE(CompareSwitchesToCurrentCommandLine(new_command_line, |
| 234 command_line)); |
| 235 |
| 236 ConvertFlagsToSwitches(&prefs_, &command_line); |
| 237 |
| 238 EXPECT_TRUE(CompareSwitchesToCurrentCommandLine(new_command_line, |
| 239 command_line)); |
| 240 } |
| 241 |
224 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { | 242 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { |
225 std::map<std::string, CommandLine::StringType> switch_list; | 243 std::map<std::string, CommandLine::StringType> switch_list; |
226 switch_list[kSwitch1] = CommandLine::StringType(); | 244 switch_list[kSwitch1] = CommandLine::StringType(); |
227 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType(); | 245 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType(); |
228 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType(); | 246 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType(); |
229 switch_list["foo"] = CommandLine::StringType(); | 247 switch_list["foo"] = CommandLine::StringType(); |
230 | 248 |
231 SetExperimentEnabled(&prefs_, kFlags1, true); | 249 SetExperimentEnabled(&prefs_, kFlags1, true); |
232 | 250 |
233 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. | 251 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 testing::SetExperiments(NULL, 0); | 436 testing::SetExperiments(NULL, 0); |
419 size_t count; | 437 size_t count; |
420 const Experiment* experiments = testing::GetExperiments(&count); | 438 const Experiment* experiments = testing::GetExperiments(&count); |
421 for (size_t i = 0; i < count; ++i) { | 439 for (size_t i = 0; i < count; ++i) { |
422 std::string name = experiments->internal_name; | 440 std::string name = experiments->internal_name; |
423 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; | 441 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; |
424 } | 442 } |
425 } | 443 } |
426 | 444 |
427 } // namespace about_flags | 445 } // namespace about_flags |
OLD | NEW |