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

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

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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
OLDNEW
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/memory/ptr_util.h"
6 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" 8 #include "chrome/browser/prefs/chrome_command_line_pref_store.h"
8 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "components/prefs/pref_registry_simple.h" 13 #include "components/prefs/pref_registry_simple.h"
13 #include "components/sync_preferences/testing_pref_service_syncable.h" 14 #include "components/sync_preferences/testing_pref_service_syncable.h"
14 #include "content/public/common/web_preferences.h" 15 #include "content/public/common/web_preferences.h"
15 #include "content/public/test/test_renderer_host.h" 16 #include "content/public/test/test_renderer_host.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 protected: 53 protected:
53 void SetUp() override { 54 void SetUp() override {
54 ChromeRenderViewHostTestHarness::SetUp(); 55 ChromeRenderViewHostTestHarness::SetUp();
55 56
56 // Supply our own profile so we use the correct profile data. The test 57 // Supply our own profile so we use the correct profile data. The test
57 // harness is not supposed to overwrite a profile if it's already created. 58 // harness is not supposed to overwrite a profile if it's already created.
58 59
59 // Set some (WebKit) user preferences. 60 // Set some (WebKit) user preferences.
60 sync_preferences::TestingPrefServiceSyncable* pref_services = 61 sync_preferences::TestingPrefServiceSyncable* pref_services =
61 profile()->GetTestingPrefService(); 62 profile()->GetTestingPrefService();
62 pref_services->SetUserPref(prefs::kDefaultCharset, new base::Value("utf8")); 63 pref_services->SetUserPref(prefs::kDefaultCharset,
64 base::MakeUnique<base::Value>("utf8"));
63 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, 65 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize,
64 new base::Value(20)); 66 base::MakeUnique<base::Value>(20));
65 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, 67 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable,
66 new base::Value(false)); 68 base::MakeUnique<base::Value>(false));
67 pref_services->SetUserPref("webkit.webprefs.foo", new base::Value("bar")); 69 pref_services->SetUserPref("webkit.webprefs.foo",
70 base::MakeUnique<base::Value>("bar"));
68 } 71 }
69 }; 72 };
70 73
71 // Tests to see that webkit preferences are properly loaded and copied over 74 // Tests to see that webkit preferences are properly loaded and copied over
72 // to a WebPreferences object. 75 // to a WebPreferences object.
73 TEST_F(ChromePrefServiceWebKitPrefs, PrefsCopied) { 76 TEST_F(ChromePrefServiceWebKitPrefs, PrefsCopied) {
74 WebPreferences webkit_prefs = 77 WebPreferences webkit_prefs =
75 RenderViewHostTester::For(rvh())->TestComputeWebkitPrefs(); 78 RenderViewHostTester::For(rvh())->TestComputeWebkitPrefs();
76 79
77 // These values have been overridden by the profile preferences. 80 // These values have been overridden by the profile preferences.
(...skipping 12 matching lines...) Expand all
90 const char kDefaultFont[] = "Times"; 93 const char kDefaultFont[] = "Times";
91 #elif defined(OS_CHROMEOS) 94 #elif defined(OS_CHROMEOS)
92 const char kDefaultFont[] = "Tinos"; 95 const char kDefaultFont[] = "Tinos";
93 #else 96 #else
94 const char kDefaultFont[] = "Times New Roman"; 97 const char kDefaultFont[] = "Times New Roman";
95 #endif 98 #endif
96 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont), 99 EXPECT_EQ(base::ASCIIToUTF16(kDefaultFont),
97 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]); 100 webkit_prefs.standard_font_family_map[prefs::kWebKitCommonScript]);
98 EXPECT_TRUE(webkit_prefs.javascript_enabled); 101 EXPECT_TRUE(webkit_prefs.javascript_enabled);
99 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_info_message_filter_unittest.cc ('k') | chrome/browser/prefs/incognito_mode_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698