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

Side by Side Diff: chrome/browser/about_flags_unittest.cc

Issue 16770002: Restart Chrome if per session flags have been specified on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed set intersection computation. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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));
Mattias Nissler (ping if slow) 2013/06/13 16:55:57 nit: indentation.
pastarmovj 2013/06/13 17:29:36 Done.
240
241 // Now both have flags but different.
242 SetExperimentEnabled(&prefs_, kFlags1, false);
243 SetExperimentEnabled(&prefs_, kFlags2, true);
244
245 CommandLine another_command_line(CommandLine::NO_PROGRAM);
246 ConvertFlagsToSwitches(&prefs_, &another_command_line);
247
248 EXPECT_FALSE(CompareSwitchesToCurrentCommandLine(new_command_line,
249 another_command_line));
250 }
251
224 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { 252 TEST_F(AboutFlagsTest, RemoveFlagSwitches) {
225 std::map<std::string, CommandLine::StringType> switch_list; 253 std::map<std::string, CommandLine::StringType> switch_list;
226 switch_list[kSwitch1] = CommandLine::StringType(); 254 switch_list[kSwitch1] = CommandLine::StringType();
227 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType(); 255 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType();
228 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType(); 256 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType();
229 switch_list["foo"] = CommandLine::StringType(); 257 switch_list["foo"] = CommandLine::StringType();
230 258
231 SetExperimentEnabled(&prefs_, kFlags1, true); 259 SetExperimentEnabled(&prefs_, kFlags1, true);
232 260
233 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. 261 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 testing::SetExperiments(NULL, 0); 446 testing::SetExperiments(NULL, 0);
419 size_t count; 447 size_t count;
420 const Experiment* experiments = testing::GetExperiments(&count); 448 const Experiment* experiments = testing::GetExperiments(&count);
421 for (size_t i = 0; i < count; ++i) { 449 for (size_t i = 0; i < count; ++i) {
422 std::string name = experiments->internal_name; 450 std::string name = experiments->internal_name;
423 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 451 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
424 } 452 }
425 } 453 }
426 454
427 } // namespace about_flags 455 } // namespace about_flags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698