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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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/string_number_conversions.h" 5 #include "base/string_number_conversions.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/about_flags.h" 8 #include "chrome/browser/about_flags.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 "", 79 "",
80 "", 80 "",
81 kMultiChoices, 81 kMultiChoices,
82 arraysize(kMultiChoices) 82 arraysize(kMultiChoices)
83 }, 83 },
84 }; 84 };
85 85
86 class AboutFlagsTest : public ::testing::Test { 86 class AboutFlagsTest : public ::testing::Test {
87 protected: 87 protected:
88 AboutFlagsTest() { 88 AboutFlagsTest() {
89 prefs_.RegisterListPref(prefs::kEnabledLabsExperiments, 89 prefs_.RegisterListPref(prefs::kEnabledLabsExperiments);
90 PrefService::UNSYNCABLE_PREF);
91 testing::ClearState(); 90 testing::ClearState();
92 } 91 }
93 92
94 virtual void SetUp() { 93 virtual void SetUp() {
95 for (size_t i = 0; i < arraysize(kExperiments); ++i) 94 for (size_t i = 0; i < arraysize(kExperiments); ++i)
96 kExperiments[i].supported_platforms = GetCurrentPlatform(); 95 kExperiments[i].supported_platforms = GetCurrentPlatform();
97 96
98 int os_other_than_current = 1; 97 int os_other_than_current = 1;
99 while (os_other_than_current == GetCurrentPlatform()) 98 while (os_other_than_current == GetCurrentPlatform())
100 os_other_than_current <<= 1; 99 os_other_than_current <<= 1;
101 kExperiments[2].supported_platforms = os_other_than_current; 100 kExperiments[2].supported_platforms = os_other_than_current;
102 101
103 testing::SetExperiments(kExperiments, arraysize(kExperiments)); 102 testing::SetExperiments(kExperiments, arraysize(kExperiments));
104 } 103 }
105 104
106 virtual void TearDown() { 105 virtual void TearDown() {
107 testing::SetExperiments(NULL, 0); 106 testing::SetExperiments(NULL, 0);
108 } 107 }
109 108
110 TestingPrefService prefs_; 109 TestingPrefServiceSimple prefs_;
111 }; 110 };
112 111
113 TEST_F(AboutFlagsTest, ChangeNeedsRestart) { 112 TEST_F(AboutFlagsTest, ChangeNeedsRestart) {
114 EXPECT_FALSE(IsRestartNeededToCommitChanges()); 113 EXPECT_FALSE(IsRestartNeededToCommitChanges());
115 SetExperimentEnabled(&prefs_, kFlags1, true); 114 SetExperimentEnabled(&prefs_, kFlags1, true);
116 EXPECT_TRUE(IsRestartNeededToCommitChanges()); 115 EXPECT_TRUE(IsRestartNeededToCommitChanges());
117 } 116 }
118 117
119 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) { 118 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) {
120 // Add two experiments, check they're there. 119 // Add two experiments, check they're there.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ASCIIToWide(switch1_with_equals))); 253 ASCIIToWide(switch1_with_equals)));
255 #else 254 #else
256 EXPECT_EQ(std::string::npos, 255 EXPECT_EQ(std::string::npos,
257 command_line.GetCommandLineString().find(switch1_with_equals)); 256 command_line.GetCommandLineString().find(switch1_with_equals));
258 #endif 257 #endif
259 258
260 // And confirm there is a '=' for switches with values. 259 // And confirm there is a '=' for switches with values.
261 std::string switch2_with_equals = std::string("--") + 260 std::string switch2_with_equals = std::string("--") +
262 std::string(kSwitch2) + 261 std::string(kSwitch2) +
263 std::string("="); 262 std::string("=");
264 #if defined(OS_WIN) 263 #if defined(OS_WIN)
265 EXPECT_NE(std::wstring::npos, 264 EXPECT_NE(std::wstring::npos,
266 command_line.GetCommandLineString().find( 265 command_line.GetCommandLineString().find(
267 ASCIIToWide(switch2_with_equals))); 266 ASCIIToWide(switch2_with_equals)));
268 #else 267 #else
269 EXPECT_NE(std::string::npos, 268 EXPECT_NE(std::string::npos,
270 command_line.GetCommandLineString().find(switch2_with_equals)); 269 command_line.GetCommandLineString().find(switch2_with_equals));
271 #endif 270 #endif
272 271
273 // And it should persist 272 // And it should persist
274 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_)); 273 scoped_ptr<ListValue> switch_prefs(GetFlagsExperimentsData(&prefs_));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 testing::SetExperiments(NULL, 0); 316 testing::SetExperiments(NULL, 0);
318 size_t count; 317 size_t count;
319 const Experiment* experiments = testing::GetExperiments(&count); 318 const Experiment* experiments = testing::GetExperiments(&count);
320 for (size_t i = 0; i < count; ++i) { 319 for (size_t i = 0; i < count; ++i) {
321 std::string name = experiments->internal_name; 320 std::string name = experiments->internal_name;
322 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; 321 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i;
323 } 322 }
324 } 323 }
325 324
326 } // namespace about_flags 325 } // namespace about_flags
OLDNEW
« no previous file with comments | « base/prefs/public/pref_service_base.h ('k') | chrome/browser/accessibility/invert_bubble_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698