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

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: Rebased to ToT and addressed Nico's comments. 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 EXPECT_TRUE(command_line.HasSwitch("foo")); 217 EXPECT_TRUE(command_line.HasSwitch("foo"));
218 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); 218 EXPECT_FALSE(command_line.HasSwitch(kSwitch1));
219 219
220 ConvertFlagsToSwitches(&flags_storage_, &command_line); 220 ConvertFlagsToSwitches(&flags_storage_, &command_line);
221 221
222 EXPECT_TRUE(command_line.HasSwitch("foo")); 222 EXPECT_TRUE(command_line.HasSwitch("foo"));
223 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); 223 EXPECT_TRUE(command_line.HasSwitch(kSwitch1));
224 } 224 }
225 225
226 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) {
227 SetExperimentEnabled(&flags_storage_, kFlags1, true);
228
229 CommandLine command_line(CommandLine::NO_PROGRAM);
230 command_line.AppendSwitch("foo");
231
232 CommandLine new_command_line(CommandLine::NO_PROGRAM);
233 ConvertFlagsToSwitches(&flags_storage_, &new_command_line);
234
235 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
236 command_line));
237
238 ConvertFlagsToSwitches(&flags_storage_, &command_line);
239
240 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
241 command_line));
242
243 // Now both have flags but different.
244 SetExperimentEnabled(&flags_storage_, kFlags1, false);
245 SetExperimentEnabled(&flags_storage_, kFlags2, true);
246
247 CommandLine another_command_line(CommandLine::NO_PROGRAM);
248 ConvertFlagsToSwitches(&flags_storage_, &another_command_line);
249
250 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine(new_command_line,
251 another_command_line));
252 }
253
226 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { 254 TEST_F(AboutFlagsTest, RemoveFlagSwitches) {
227 std::map<std::string, CommandLine::StringType> switch_list; 255 std::map<std::string, CommandLine::StringType> switch_list;
228 switch_list[kSwitch1] = CommandLine::StringType(); 256 switch_list[kSwitch1] = CommandLine::StringType();
229 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType(); 257 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType();
230 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType(); 258 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType();
231 switch_list["foo"] = CommandLine::StringType(); 259 switch_list["foo"] = CommandLine::StringType();
232 260
233 SetExperimentEnabled(&flags_storage_, kFlags1, true); 261 SetExperimentEnabled(&flags_storage_, kFlags1, true);
234 262
235 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. 263 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 testing::SetExperiments(NULL, 0); 448 testing::SetExperiments(NULL, 0);
421 size_t count; 449 size_t count;
422 const Experiment* experiments = testing::GetExperiments(&count); 450 const Experiment* experiments = testing::GetExperiments(&count);
423 for (size_t i = 0; i < count; ++i) { 451 for (size_t i = 0; i < count; ++i) {
424 std::string name = experiments->internal_name; 452 std::string name = experiments->internal_name;
425 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 453 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
426 } 454 }
427 } 455 }
428 456
429 } // namespace about_flags 457 } // namespace about_flags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698