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

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

Issue 106433007: Update some uses of Value in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 12 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/accessibility/accessibility_events.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Enable the default choice now. 162 // Enable the default choice now.
163 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); 163 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true);
164 EXPECT_TRUE(IsRestartNeededToCommitChanges()); 164 EXPECT_TRUE(IsRestartNeededToCommitChanges());
165 } 165 }
166 166
167 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) { 167 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) {
168 // Add two experiments, check they're there. 168 // Add two experiments, check they're there.
169 SetExperimentEnabled(&flags_storage_, kFlags1, true); 169 SetExperimentEnabled(&flags_storage_, kFlags1, true);
170 SetExperimentEnabled(&flags_storage_, kFlags2, true); 170 SetExperimentEnabled(&flags_storage_, kFlags2, true);
171 171
172 const ListValue* experiments_list = prefs_.GetList( 172 const base::ListValue* experiments_list = prefs_.GetList(
173 prefs::kEnabledLabsExperiments); 173 prefs::kEnabledLabsExperiments);
174 ASSERT_TRUE(experiments_list != NULL); 174 ASSERT_TRUE(experiments_list != NULL);
175 175
176 ASSERT_EQ(2u, experiments_list->GetSize()); 176 ASSERT_EQ(2u, experiments_list->GetSize());
177 177
178 std::string s0; 178 std::string s0;
179 ASSERT_TRUE(experiments_list->GetString(0, &s0)); 179 ASSERT_TRUE(experiments_list->GetString(0, &s0));
180 std::string s1; 180 std::string s1;
181 ASSERT_TRUE(experiments_list->GetString(1, &s1)); 181 ASSERT_TRUE(experiments_list->GetString(1, &s1));
182 182
183 EXPECT_TRUE(s0 == kFlags1 || s1 == kFlags1); 183 EXPECT_TRUE(s0 == kFlags1 || s1 == kFlags1);
184 EXPECT_TRUE(s0 == kFlags2 || s1 == kFlags2); 184 EXPECT_TRUE(s0 == kFlags2 || s1 == kFlags2);
185 185
186 // Remove one experiment, check the other's still around. 186 // Remove one experiment, check the other's still around.
187 SetExperimentEnabled(&flags_storage_, kFlags2, false); 187 SetExperimentEnabled(&flags_storage_, kFlags2, false);
188 188
189 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); 189 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments);
190 ASSERT_TRUE(experiments_list != NULL); 190 ASSERT_TRUE(experiments_list != NULL);
191 ASSERT_EQ(1u, experiments_list->GetSize()); 191 ASSERT_EQ(1u, experiments_list->GetSize());
192 ASSERT_TRUE(experiments_list->GetString(0, &s0)); 192 ASSERT_TRUE(experiments_list->GetString(0, &s0));
193 EXPECT_TRUE(s0 == kFlags1); 193 EXPECT_TRUE(s0 == kFlags1);
194 } 194 }
195 195
196 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveBoth) { 196 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveBoth) {
197 // Add two experiments, check the pref exists. 197 // Add two experiments, check the pref exists.
198 SetExperimentEnabled(&flags_storage_, kFlags1, true); 198 SetExperimentEnabled(&flags_storage_, kFlags1, true);
199 SetExperimentEnabled(&flags_storage_, kFlags2, true); 199 SetExperimentEnabled(&flags_storage_, kFlags2, true);
200 const ListValue* experiments_list = prefs_.GetList( 200 const base::ListValue* experiments_list = prefs_.GetList(
201 prefs::kEnabledLabsExperiments); 201 prefs::kEnabledLabsExperiments);
202 ASSERT_TRUE(experiments_list != NULL); 202 ASSERT_TRUE(experiments_list != NULL);
203 203
204 // Remove both, the pref should have been removed completely. 204 // Remove both, the pref should have been removed completely.
205 SetExperimentEnabled(&flags_storage_, kFlags1, false); 205 SetExperimentEnabled(&flags_storage_, kFlags1, false);
206 SetExperimentEnabled(&flags_storage_, kFlags2, false); 206 SetExperimentEnabled(&flags_storage_, kFlags2, false);
207 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); 207 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments);
208 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); 208 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0);
209 } 209 }
210 210
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); 300 EXPECT_FALSE(command_line.HasSwitch(kSwitch1));
301 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); 301 EXPECT_FALSE(command_line.HasSwitch(kSwitch3));
302 302
303 // Convert the flags to switches. Experiment 3 shouldn't be among the switches 303 // Convert the flags to switches. Experiment 3 shouldn't be among the switches
304 // as it is not applicable to the current platform. 304 // as it is not applicable to the current platform.
305 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); 305 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels);
306 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); 306 EXPECT_TRUE(command_line.HasSwitch(kSwitch1));
307 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); 307 EXPECT_FALSE(command_line.HasSwitch(kSwitch3));
308 308
309 // Experiment 3 should show still be persisted in preferences though. 309 // Experiment 3 should show still be persisted in preferences though.
310 const ListValue* experiments_list = 310 const base::ListValue* experiments_list =
311 prefs_.GetList(prefs::kEnabledLabsExperiments); 311 prefs_.GetList(prefs::kEnabledLabsExperiments);
312 ASSERT_TRUE(experiments_list); 312 ASSERT_TRUE(experiments_list);
313 EXPECT_EQ(2U, experiments_list->GetSize()); 313 EXPECT_EQ(2U, experiments_list->GetSize());
314 std::string s0; 314 std::string s0;
315 ASSERT_TRUE(experiments_list->GetString(0, &s0)); 315 ASSERT_TRUE(experiments_list->GetString(0, &s0));
316 EXPECT_EQ(kFlags1, s0); 316 EXPECT_EQ(kFlags1, s0);
317 std::string s1; 317 std::string s1;
318 ASSERT_TRUE(experiments_list->GetString(1, &s1)); 318 ASSERT_TRUE(experiments_list->GetString(1, &s1));
319 EXPECT_EQ(kFlags3, s1); 319 EXPECT_EQ(kFlags3, s1);
320 } 320 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 #if defined(OS_WIN) 357 #if defined(OS_WIN)
358 EXPECT_NE(std::wstring::npos, 358 EXPECT_NE(std::wstring::npos,
359 command_line.GetCommandLineString().find( 359 command_line.GetCommandLineString().find(
360 ASCIIToWide(switch2_with_equals))); 360 ASCIIToWide(switch2_with_equals)));
361 #else 361 #else
362 EXPECT_NE(std::string::npos, 362 EXPECT_NE(std::string::npos,
363 command_line.GetCommandLineString().find(switch2_with_equals)); 363 command_line.GetCommandLineString().find(switch2_with_equals));
364 #endif 364 #endif
365 365
366 // And it should persist. 366 // And it should persist.
367 const ListValue* experiments_list = 367 const base::ListValue* experiments_list =
368 prefs_.GetList(prefs::kEnabledLabsExperiments); 368 prefs_.GetList(prefs::kEnabledLabsExperiments);
369 ASSERT_TRUE(experiments_list); 369 ASSERT_TRUE(experiments_list);
370 EXPECT_EQ(2U, experiments_list->GetSize()); 370 EXPECT_EQ(2U, experiments_list->GetSize());
371 std::string s0; 371 std::string s0;
372 ASSERT_TRUE(experiments_list->GetString(0, &s0)); 372 ASSERT_TRUE(experiments_list->GetString(0, &s0));
373 EXPECT_EQ(kFlags1, s0); 373 EXPECT_EQ(kFlags1, s0);
374 std::string s1; 374 std::string s1;
375 ASSERT_TRUE(experiments_list->GetString(1, &s1)); 375 ASSERT_TRUE(experiments_list->GetString(1, &s1));
376 EXPECT_EQ(kFlags2, s1); 376 EXPECT_EQ(kFlags2, s1);
377 } 377 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 testing::SetExperiments(NULL, 0); 458 testing::SetExperiments(NULL, 0);
459 size_t count; 459 size_t count;
460 const Experiment* experiments = testing::GetExperiments(&count); 460 const Experiment* experiments = testing::GetExperiments(&count);
461 for (size_t i = 0; i < count; ++i) { 461 for (size_t i = 0; i < count; ++i) {
462 std::string name = experiments->internal_name; 462 std::string name = experiments->internal_name;
463 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 463 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
464 } 464 }
465 } 465 }
466 466
467 } // namespace about_flags 467 } // namespace about_flags
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/accessibility/accessibility_events.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698