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

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

Issue 13467023: Add differentiation between owner only and common flags on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 class AboutFlagsTest : public ::testing::Test { 112 class AboutFlagsTest : public ::testing::Test {
113 protected: 113 protected:
114 AboutFlagsTest() { 114 AboutFlagsTest() {
115 prefs_.registry()->RegisterListPref(prefs::kEnabledLabsExperiments); 115 prefs_.registry()->RegisterListPref(prefs::kEnabledLabsExperiments);
116 testing::ClearState(); 116 testing::ClearState();
117 } 117 }
118 118
119 virtual void SetUp() OVERRIDE { 119 virtual void SetUp() OVERRIDE {
120 for (size_t i = 0; i < arraysize(kExperiments); ++i) 120 for (size_t i = 0; i < arraysize(kExperiments); ++i)
121 kExperiments[i].supported_platforms = GetCurrentPlatform(); 121 kExperiments[i].supported_platforms = GetCurrentPlatform(true);
122 122
123 int os_other_than_current = 1; 123 int os_other_than_current = 1;
124 while (os_other_than_current == GetCurrentPlatform()) 124 while (os_other_than_current == GetCurrentPlatform(true))
125 os_other_than_current <<= 1; 125 os_other_than_current <<= 1;
126 kExperiments[2].supported_platforms = os_other_than_current; 126 kExperiments[2].supported_platforms = os_other_than_current;
127 127
128 testing::SetExperiments(kExperiments, arraysize(kExperiments)); 128 testing::SetExperiments(kExperiments, arraysize(kExperiments));
129 } 129 }
130 130
131 virtual void TearDown() OVERRIDE { 131 virtual void TearDown() OVERRIDE {
132 testing::SetExperiments(NULL, 0); 132 testing::SetExperiments(NULL, 0);
133 } 133 }
134 134
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(GetFlagsExperimentsData(&prefs_, true));
271 ASSERT_TRUE(switch_prefs.get()); 271 ASSERT_TRUE(switch_prefs.get());
272 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); 272 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize());
273 } 273 }
274 274
275 // Tests that switches which should have values get them in the command 275 // Tests that switches which should have values get them in the command
276 // line. 276 // line.
277 TEST_F(AboutFlagsTest, CheckValues) { 277 TEST_F(AboutFlagsTest, CheckValues) {
278 // Enable experiments 1 and 2. 278 // Enable experiments 1 and 2.
279 SetExperimentEnabled(&prefs_, kFlags1, true); 279 SetExperimentEnabled(&prefs_, kFlags1, true);
280 SetExperimentEnabled(&prefs_, kFlags2, true); 280 SetExperimentEnabled(&prefs_, kFlags2, true);
(...skipping 29 matching lines...) Expand all
310 #if defined(OS_WIN) 310 #if defined(OS_WIN)
311 EXPECT_NE(std::wstring::npos, 311 EXPECT_NE(std::wstring::npos,
312 command_line.GetCommandLineString().find( 312 command_line.GetCommandLineString().find(
313 ASCIIToWide(switch2_with_equals))); 313 ASCIIToWide(switch2_with_equals)));
314 #else 314 #else
315 EXPECT_NE(std::string::npos, 315 EXPECT_NE(std::string::npos,
316 command_line.GetCommandLineString().find(switch2_with_equals)); 316 command_line.GetCommandLineString().find(switch2_with_equals));
317 #endif 317 #endif
318 318
319 // And it should persist 319 // And it should persist
320 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); 320 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_, true));
321 ASSERT_TRUE(switch_prefs.get()); 321 ASSERT_TRUE(switch_prefs.get());
322 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize()); 322 EXPECT_EQ(arraysize(kExperiments), switch_prefs->GetSize());
323 } 323 }
324 324
325 // Tests multi-value type experiments. 325 // Tests multi-value type experiments.
326 TEST_F(AboutFlagsTest, MultiValues) { 326 TEST_F(AboutFlagsTest, MultiValues) {
327 const Experiment& experiment = kExperiments[3]; 327 const Experiment& experiment = kExperiments[3];
328 ASSERT_EQ(kFlags4, experiment.internal_name); 328 ASSERT_EQ(kFlags4, experiment.internal_name);
329 329
330 // Initially, the first "deactivated" option of the multi experiment should 330 // Initially, the first "deactivated" option of the multi experiment should
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 testing::SetExperiments(NULL, 0); 404 testing::SetExperiments(NULL, 0);
405 size_t count; 405 size_t count;
406 const Experiment* experiments = testing::GetExperiments(&count); 406 const Experiment* experiments = testing::GetExperiments(&count);
407 for (size_t i = 0; i < count; ++i) { 407 for (size_t i = 0; i < count; ++i) {
408 std::string name = experiments->internal_name; 408 std::string name = experiments->internal_name;
409 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 409 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
410 } 410 }
411 } 411 }
412 412
413 } // namespace about_flags 413 } // namespace about_flags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698