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

Side by Side Diff: chrome/browser/prefs/pref_service_unittest.cc

Issue 7890060: This broke lots of layout tests on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 10 #include "chrome/browser/policy/configuration_policy_pref_store.h"
11 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 11 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
12 #include "chrome/browser/prefs/browser_prefs.h" 12 #include "chrome/browser/prefs/browser_prefs.h"
13 #include "chrome/browser/prefs/command_line_pref_store.h" 13 #include "chrome/browser/prefs/command_line_pref_store.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h" 14 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/prefs/pref_observer_mock.h" 15 #include "chrome/browser/prefs/pref_observer_mock.h"
16 #include "chrome/browser/prefs/pref_service_mock_builder.h" 16 #include "chrome/browser/prefs/pref_service_mock_builder.h"
17 #include "chrome/browser/prefs/pref_value_store.h" 17 #include "chrome/browser/prefs/pref_value_store.h"
18 #include "chrome/browser/prefs/testing_pref_store.h" 18 #include "chrome/browser/prefs/testing_pref_store.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/testing_pref_service.h" 22 #include "chrome/test/base/testing_pref_service.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/base/test/data/resource.h" 25 #include "ui/base/test/data/resource.h"
26 26
27 using testing::_; 27 using testing::_;
28 using testing::Mock; 28 using testing::Mock;
29 29
30 // TODO(port): port this test to POSIX.
31 #if defined(OS_WIN)
32 TEST(PrefServiceTest, LocalizedPrefs) {
33 TestingPrefService prefs;
34 const char kBoolean[] = "boolean";
35 const char kInteger[] = "integer";
36 const char kString[] = "string";
37 prefs.RegisterLocalizedBooleanPref(kBoolean, IDS_LOCALE_BOOL);
38 prefs.RegisterLocalizedIntegerPref(kInteger, IDS_LOCALE_INT);
39 prefs.RegisterLocalizedStringPref(kString, IDS_LOCALE_STRING);
40
41 // The locale default should take preference over the user default.
42 EXPECT_FALSE(prefs.GetBoolean(kBoolean));
43 EXPECT_EQ(1, prefs.GetInteger(kInteger));
44 EXPECT_EQ("hello", prefs.GetString(kString));
45
46 prefs.SetBoolean(kBoolean, true);
47 EXPECT_TRUE(prefs.GetBoolean(kBoolean));
48 prefs.SetInteger(kInteger, 5);
49 EXPECT_EQ(5, prefs.GetInteger(kInteger));
50 prefs.SetString(kString, "foo");
51 EXPECT_EQ("foo", prefs.GetString(kString));
52 }
53 #endif
54
30 TEST(PrefServiceTest, NoObserverFire) { 55 TEST(PrefServiceTest, NoObserverFire) {
31 TestingPrefService prefs; 56 TestingPrefService prefs;
32 57
33 const char pref_name[] = "homepage"; 58 const char pref_name[] = "homepage";
34 prefs.RegisterStringPref(pref_name, std::string()); 59 prefs.RegisterStringPref(pref_name, std::string());
35 60
36 const char new_pref_value[] = "http://www.google.com/"; 61 const char new_pref_value[] = "http://www.google.com/";
37 PrefObserverMock obs; 62 PrefObserverMock obs;
38 PrefChangeRegistrar registrar; 63 PrefChangeRegistrar registrar;
39 registrar.Init(&prefs); 64 registrar.Init(&prefs);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 248
224 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0); 249 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0);
225 prefs_.Set(kName, new_value); 250 prefs_.Set(kName, new_value);
226 Mock::VerifyAndClearExpectations(&observer_); 251 Mock::VerifyAndClearExpectations(&observer_);
227 252
228 ListValue empty; 253 ListValue empty;
229 observer_.Expect(&prefs_, kName, &empty); 254 observer_.Expect(&prefs_, kName, &empty);
230 prefs_.Set(kName, empty); 255 prefs_.Set(kName, empty);
231 Mock::VerifyAndClearExpectations(&observer_); 256 Mock::VerifyAndClearExpectations(&observer_);
232 } 257 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_regexes.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698