OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 14 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
15 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 15 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
16 #include "chrome/browser/prefs/browser_prefs.h" | 16 #include "chrome/browser/prefs/browser_prefs.h" |
17 #include "chrome/browser/prefs/command_line_pref_store.h" | 17 #include "chrome/browser/prefs/command_line_pref_store.h" |
18 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 18 #include "chrome/browser/prefs/pref_service_mock_factory.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/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
23 #include "chrome/test/base/testing_pref_service_syncable.h" | 23 #include "chrome/test/base/testing_pref_service_syncable.h" |
24 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
25 #include "components/user_prefs/pref_registry_syncable.h" | 25 #include "components/user_prefs/pref_registry_syncable.h" |
26 #include "content/public/test/web_contents_tester.h" | 26 #include "content/public/test/web_contents_tester.h" |
27 #include "ui/base/test/data/resource.h" | 27 #include "ui/base/test/data/resource.h" |
28 #include "webkit/common/webpreferences.h" | 28 #include "webkit/common/webpreferences.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Verifies that ListValue and DictionaryValue pref with non emtpy default | 91 // Verifies that ListValue and DictionaryValue pref with non emtpy default |
92 // preserves its empty value. | 92 // preserves its empty value. |
93 TEST_F(ChromePrefServiceUserFilePrefsTest, PreserveEmptyValue) { | 93 TEST_F(ChromePrefServiceUserFilePrefsTest, PreserveEmptyValue) { |
94 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); | 94 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); |
95 | 95 |
96 ASSERT_TRUE(base::CopyFile( | 96 ASSERT_TRUE(base::CopyFile( |
97 data_dir_.AppendASCII("read.need_empty_value.json"), | 97 data_dir_.AppendASCII("read.need_empty_value.json"), |
98 pref_file)); | 98 pref_file)); |
99 | 99 |
100 PrefServiceMockBuilder builder; | 100 PrefServiceMockFactory factory; |
101 builder.WithUserFilePrefs(pref_file, | 101 factory.SetUserPrefsFile(pref_file, |
102 message_loop_.message_loop_proxy().get()); | 102 message_loop_.message_loop_proxy().get()); |
103 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 103 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
104 new user_prefs::PrefRegistrySyncable); | 104 new user_prefs::PrefRegistrySyncable); |
105 scoped_ptr<PrefServiceSyncable> prefs(builder.CreateSyncable(registry.get())); | 105 scoped_ptr<PrefServiceSyncable> prefs(factory.CreateSyncable(registry.get())); |
106 | 106 |
107 // Register testing prefs. | 107 // Register testing prefs. |
108 registry->RegisterListPref("list", | 108 registry->RegisterListPref("list", |
109 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 109 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
110 registry->RegisterDictionaryPref( | 110 registry->RegisterDictionaryPref( |
111 "dict", | 111 "dict", |
112 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 112 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
113 | 113 |
114 base::ListValue* non_empty_list = new base::ListValue; | 114 base::ListValue* non_empty_list = new base::ListValue; |
115 non_empty_list->Append(base::Value::CreateStringValue("test")); | 115 non_empty_list->Append(base::Value::CreateStringValue("test")); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const char kDefaultFont[] = "Times"; | 186 const char kDefaultFont[] = "Times"; |
187 #elif defined(OS_CHROMEOS) | 187 #elif defined(OS_CHROMEOS) |
188 const char kDefaultFont[] = "Tinos"; | 188 const char kDefaultFont[] = "Tinos"; |
189 #else | 189 #else |
190 const char kDefaultFont[] = "Times New Roman"; | 190 const char kDefaultFont[] = "Times New Roman"; |
191 #endif | 191 #endif |
192 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), | 192 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), |
193 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); | 193 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); |
194 EXPECT_TRUE(webkit_prefs.javascript_enabled); | 194 EXPECT_TRUE(webkit_prefs.javascript_enabled); |
195 } | 195 } |
OLD | NEW |