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" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // preserves its empty value. | 94 // preserves its empty value. |
95 TEST_F(ChromePrefServiceUserFilePrefsTest, PreserveEmptyValue) { | 95 TEST_F(ChromePrefServiceUserFilePrefsTest, PreserveEmptyValue) { |
96 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); | 96 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); |
97 | 97 |
98 ASSERT_TRUE(file_util::CopyFile( | 98 ASSERT_TRUE(file_util::CopyFile( |
99 data_dir_.AppendASCII("read.need_empty_value.json"), | 99 data_dir_.AppendASCII("read.need_empty_value.json"), |
100 pref_file)); | 100 pref_file)); |
101 | 101 |
102 PrefServiceMockBuilder builder; | 102 PrefServiceMockBuilder builder; |
103 builder.WithUserFilePrefs(pref_file, message_loop_.message_loop_proxy()); | 103 builder.WithUserFilePrefs(pref_file, message_loop_.message_loop_proxy()); |
104 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable); | 104 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 105 new user_prefs::PrefRegistrySyncable); |
105 scoped_ptr<PrefServiceSyncable> prefs(builder.CreateSyncable(registry)); | 106 scoped_ptr<PrefServiceSyncable> prefs(builder.CreateSyncable(registry)); |
106 | 107 |
107 // Register testing prefs. | 108 // Register testing prefs. |
108 registry->RegisterListPref("list", | 109 registry->RegisterListPref("list", |
109 PrefRegistrySyncable::UNSYNCABLE_PREF); | 110 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
110 registry->RegisterDictionaryPref("dict", | 111 registry->RegisterDictionaryPref( |
111 PrefRegistrySyncable::UNSYNCABLE_PREF); | 112 "dict", |
| 113 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
112 | 114 |
113 base::ListValue* non_empty_list = new base::ListValue; | 115 base::ListValue* non_empty_list = new base::ListValue; |
114 non_empty_list->Append(base::Value::CreateStringValue("test")); | 116 non_empty_list->Append(base::Value::CreateStringValue("test")); |
115 registry->RegisterListPref("list_needs_empty_value", | 117 registry->RegisterListPref("list_needs_empty_value", |
116 non_empty_list, | 118 non_empty_list, |
117 PrefRegistrySyncable::UNSYNCABLE_PREF); | 119 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
118 | 120 |
119 base::DictionaryValue* non_empty_dict = new base::DictionaryValue; | 121 base::DictionaryValue* non_empty_dict = new base::DictionaryValue; |
120 non_empty_dict->SetString("dummy", "whatever"); | 122 non_empty_dict->SetString("dummy", "whatever"); |
121 registry->RegisterDictionaryPref("dict_needs_empty_value", | 123 registry->RegisterDictionaryPref( |
122 non_empty_dict, | 124 "dict_needs_empty_value", |
123 PrefRegistrySyncable::UNSYNCABLE_PREF); | 125 non_empty_dict, |
| 126 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
124 | 127 |
125 // Set all testing prefs to empty. | 128 // Set all testing prefs to empty. |
126 ClearListValue(prefs.get(), "list"); | 129 ClearListValue(prefs.get(), "list"); |
127 ClearListValue(prefs.get(), "list_needs_empty_value"); | 130 ClearListValue(prefs.get(), "list_needs_empty_value"); |
128 ClearDictionaryValue(prefs.get(), "dict"); | 131 ClearDictionaryValue(prefs.get(), "dict"); |
129 ClearDictionaryValue(prefs.get(), "dict_needs_empty_value"); | 132 ClearDictionaryValue(prefs.get(), "dict_needs_empty_value"); |
130 | 133 |
131 // Write to file. | 134 // Write to file. |
132 prefs->CommitPendingWrite(); | 135 prefs->CommitPendingWrite(); |
133 message_loop_.RunUntilIdle(); | 136 message_loop_.RunUntilIdle(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 const char kDefaultFont[] = "Times"; | 194 const char kDefaultFont[] = "Times"; |
192 #elif defined(OS_CHROMEOS) | 195 #elif defined(OS_CHROMEOS) |
193 const char kDefaultFont[] = "Tinos"; | 196 const char kDefaultFont[] = "Tinos"; |
194 #else | 197 #else |
195 const char kDefaultFont[] = "Times New Roman"; | 198 const char kDefaultFont[] = "Times New Roman"; |
196 #endif | 199 #endif |
197 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), | 200 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), |
198 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); | 201 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); |
199 EXPECT_TRUE(webkit_prefs.javascript_enabled); | 202 EXPECT_TRUE(webkit_prefs.javascript_enabled); |
200 } | 203 } |
OLD | NEW |