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

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

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified mac-specific parts of the code. 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
« no previous file with comments | « no previous file | chrome/browser/themes/browser_theme_pack.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 <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
55 TEST(PrefServiceTest, NoObserverFire) { 30 TEST(PrefServiceTest, NoObserverFire) {
56 TestingPrefService prefs; 31 TestingPrefService prefs;
57 32
58 const char pref_name[] = "homepage"; 33 const char pref_name[] = "homepage";
59 prefs.RegisterStringPref(pref_name, std::string()); 34 prefs.RegisterStringPref(pref_name, std::string());
60 35
61 const char new_pref_value[] = "http://www.google.com/"; 36 const char new_pref_value[] = "http://www.google.com/";
62 PrefObserverMock obs; 37 PrefObserverMock obs;
63 PrefChangeRegistrar registrar; 38 PrefChangeRegistrar registrar;
64 registrar.Init(&prefs); 39 registrar.Init(&prefs);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 223
249 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0); 224 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0);
250 prefs_.Set(kName, new_value); 225 prefs_.Set(kName, new_value);
251 Mock::VerifyAndClearExpectations(&observer_); 226 Mock::VerifyAndClearExpectations(&observer_);
252 227
253 ListValue empty; 228 ListValue empty;
254 observer_.Expect(&prefs_, kName, &empty); 229 observer_.Expect(&prefs_, kName, &empty);
255 prefs_.Set(kName, empty); 230 prefs_.Set(kName, empty);
256 Mock::VerifyAndClearExpectations(&observer_); 231 Mock::VerifyAndClearExpectations(&observer_);
257 } 232 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698