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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again; base::File changes conflicted. Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/prefs/json_pref_store.h" 12 #include "base/prefs/json_pref_store.h"
13 #include "base/prefs/public/pref_change_registrar.h" 13 #include "base/prefs/public/pref_change_registrar.h"
14 #include "base/prefs/testing_pref_store.h" 14 #include "base/prefs/testing_pref_store.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/policy/configuration_policy_pref_store.h" 17 #include "chrome/browser/policy/configuration_policy_pref_store.h"
18 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 18 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
19 #include "chrome/browser/prefs/browser_prefs.h" 19 #include "chrome/browser/prefs/browser_prefs.h"
20 #include "chrome/browser/prefs/command_line_pref_store.h" 20 #include "chrome/browser/prefs/command_line_pref_store.h"
21 #include "chrome/browser/prefs/mock_pref_change_callback.h" 21 #include "chrome/browser/prefs/mock_pref_change_callback.h"
22 #include "chrome/browser/prefs/pref_registry_simple.h" 22 #include "chrome/browser/prefs/pref_registry_simple.h"
23 #include "chrome/browser/prefs/pref_registry_syncable.h"
23 #include "chrome/browser/prefs/pref_service_mock_builder.h" 24 #include "chrome/browser/prefs/pref_service_mock_builder.h"
24 #include "chrome/browser/prefs/pref_value_store.h" 25 #include "chrome/browser/prefs/pref_value_store.h"
25 #include "chrome/browser/prefs/scoped_user_pref_update.h" 26 #include "chrome/browser/prefs/scoped_user_pref_update.h"
26 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 30 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
30 #include "chrome/test/base/testing_pref_service.h" 31 #include "chrome/test/base/testing_pref_service.h"
31 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
32 #include "content/public/test/test_browser_thread.h" 33 #include "content/public/test/test_browser_thread.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // preserves its empty value. 316 // preserves its empty value.
316 TEST_F(PrefServiceUserFilePrefsTest, PreserveEmptyValue) { 317 TEST_F(PrefServiceUserFilePrefsTest, PreserveEmptyValue) {
317 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json"); 318 base::FilePath pref_file = temp_dir_.path().AppendASCII("write.json");
318 319
319 ASSERT_TRUE(file_util::CopyFile( 320 ASSERT_TRUE(file_util::CopyFile(
320 data_dir_.AppendASCII("read.need_empty_value.json"), 321 data_dir_.AppendASCII("read.need_empty_value.json"),
321 pref_file)); 322 pref_file));
322 323
323 PrefServiceMockBuilder builder; 324 PrefServiceMockBuilder builder;
324 builder.WithUserFilePrefs(pref_file, message_loop_.message_loop_proxy()); 325 builder.WithUserFilePrefs(pref_file, message_loop_.message_loop_proxy());
325 scoped_ptr<PrefServiceSyncable> prefs(builder.CreateSyncable()); 326 scoped_refptr<PrefRegistrySyncable> registry(new PrefRegistrySyncable);
327 scoped_ptr<PrefServiceSyncable> prefs(builder.CreateSyncable(registry));
326 328
327 // Register testing prefs. 329 // Register testing prefs.
328 prefs->RegisterListPref("list", 330 registry->RegisterListPref("list",
329 PrefServiceSyncable::UNSYNCABLE_PREF); 331 PrefRegistrySyncable::UNSYNCABLE_PREF);
330 prefs->RegisterDictionaryPref("dict", 332 registry->RegisterDictionaryPref("dict",
331 PrefServiceSyncable::UNSYNCABLE_PREF); 333 PrefRegistrySyncable::UNSYNCABLE_PREF);
332 334
333 base::ListValue* non_empty_list = new base::ListValue; 335 base::ListValue* non_empty_list = new base::ListValue;
334 non_empty_list->Append(base::Value::CreateStringValue("test")); 336 non_empty_list->Append(base::Value::CreateStringValue("test"));
335 prefs->RegisterListPref("list_needs_empty_value", 337 registry->RegisterListPref("list_needs_empty_value",
336 non_empty_list, 338 non_empty_list,
337 PrefServiceSyncable::UNSYNCABLE_PREF); 339 PrefRegistrySyncable::UNSYNCABLE_PREF);
338 340
339 base::DictionaryValue* non_empty_dict = new base::DictionaryValue; 341 base::DictionaryValue* non_empty_dict = new base::DictionaryValue;
340 non_empty_dict->SetString("dummy", "whatever"); 342 non_empty_dict->SetString("dummy", "whatever");
341 prefs->RegisterDictionaryPref("dict_needs_empty_value", 343 registry->RegisterDictionaryPref("dict_needs_empty_value",
342 non_empty_dict, 344 non_empty_dict,
343 PrefServiceSyncable::UNSYNCABLE_PREF); 345 PrefRegistrySyncable::UNSYNCABLE_PREF);
344 346
345 // Set all testing prefs to empty. 347 // Set all testing prefs to empty.
346 ClearListValue(prefs.get(), "list"); 348 ClearListValue(prefs.get(), "list");
347 ClearListValue(prefs.get(), "list_needs_empty_value"); 349 ClearListValue(prefs.get(), "list_needs_empty_value");
348 ClearDictionaryValue(prefs.get(), "dict"); 350 ClearDictionaryValue(prefs.get(), "dict");
349 ClearDictionaryValue(prefs.get(), "dict_needs_empty_value"); 351 ClearDictionaryValue(prefs.get(), "dict_needs_empty_value");
350 352
351 // Write to file. 353 // Write to file.
352 prefs->CommitPendingWrite(); 354 prefs->CommitPendingWrite();
353 message_loop_.RunUntilIdle(); 355 message_loop_.RunUntilIdle();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 const char kDefaultFont[] = "Times"; 502 const char kDefaultFont[] = "Times";
501 #elif defined(OS_CHROMEOS) 503 #elif defined(OS_CHROMEOS)
502 const char kDefaultFont[] = "Tinos"; 504 const char kDefaultFont[] = "Tinos";
503 #else 505 #else
504 const char kDefaultFont[] = "Times New Roman"; 506 const char kDefaultFont[] = "Times New Roman";
505 #endif 507 #endif
506 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), 508 EXPECT_EQ(ASCIIToUTF16(kDefaultFont),
507 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); 509 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]);
508 EXPECT_TRUE(webkit_prefs.javascript_enabled); 510 EXPECT_TRUE(webkit_prefs.javascript_enabled);
509 } 511 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_syncable_builder.cc ('k') | chrome/browser/prefs/proxy_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698