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

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

Issue 8802024: Move web_contents_unittest.cc to content, where it belongs next to TabContents. Also rename it to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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/tab_contents/web_contents_unittest.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/utf_string_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 11 #include "chrome/browser/policy/configuration_policy_pref_store.h"
11 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 12 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
12 #include "chrome/browser/prefs/browser_prefs.h" 13 #include "chrome/browser/prefs/browser_prefs.h"
13 #include "chrome/browser/prefs/command_line_pref_store.h" 14 #include "chrome/browser/prefs/command_line_pref_store.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h" 15 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/prefs/pref_observer_mock.h" 16 #include "chrome/browser/prefs/pref_observer_mock.h"
16 #include "chrome/browser/prefs/pref_service_mock_builder.h" 17 #include "chrome/browser/prefs/pref_service_mock_builder.h"
17 #include "chrome/browser/prefs/pref_value_store.h" 18 #include "chrome/browser/prefs/pref_value_store.h"
18 #include "chrome/browser/prefs/testing_pref_store.h" 19 #include "chrome/browser/prefs/testing_pref_store.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
22 #include "chrome/test/base/testing_pref_service.h" 24 #include "chrome/test/base/testing_pref_service.h"
25 #include "chrome/test/base/testing_pref_service.h"
26 #include "chrome/test/base/testing_profile.h"
27 #include "content/browser/tab_contents/test_tab_contents.h"
28 #include "content/test/test_browser_thread.h"
23 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/base/test/data/resource.h" 31 #include "ui/base/test/data/resource.h"
26 32
33 using content::BrowserThread;
27 using testing::_; 34 using testing::_;
28 using testing::Mock; 35 using testing::Mock;
29 36
30 TEST(PrefServiceTest, NoObserverFire) { 37 TEST(PrefServiceTest, NoObserverFire) {
31 TestingPrefService prefs; 38 TestingPrefService prefs;
32 39
33 const char pref_name[] = "homepage"; 40 const char pref_name[] = "homepage";
34 prefs.RegisterStringPref(pref_name, std::string()); 41 prefs.RegisterStringPref(pref_name, std::string());
35 42
36 const char new_pref_value[] = "http://www.google.com/"; 43 const char new_pref_value[] = "http://www.google.com/";
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 230
224 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0); 231 EXPECT_CALL(observer_, Observe(_, _, _)).Times(0);
225 prefs_.Set(kName, new_value); 232 prefs_.Set(kName, new_value);
226 Mock::VerifyAndClearExpectations(&observer_); 233 Mock::VerifyAndClearExpectations(&observer_);
227 234
228 ListValue empty; 235 ListValue empty;
229 observer_.Expect(&prefs_, kName, &empty); 236 observer_.Expect(&prefs_, kName, &empty);
230 prefs_.Set(kName, empty); 237 prefs_.Set(kName, empty);
231 Mock::VerifyAndClearExpectations(&observer_); 238 Mock::VerifyAndClearExpectations(&observer_);
232 } 239 }
240
241 class PrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness {
242 protected:
243 PrefServiceWebKitPrefs() : ui_thread_(BrowserThread::UI, &message_loop_) {
244 }
245
246 virtual void SetUp() {
247 ChromeRenderViewHostTestHarness::SetUp();
248
249 // Supply our own profile so we use the correct profile data. The test
250 // harness is not supposed to overwrite a profile if it's already created.
251
252 // Set some (WebKit) user preferences.
253 TestingPrefService* pref_services = profile()->GetTestingPrefService();
254 #if defined(TOOLKIT_USES_GTK)
255 pref_services->SetUserPref(prefs::kUsesSystemTheme,
256 Value::CreateBooleanValue(false));
257 #endif
258 pref_services->SetUserPref(prefs::kDefaultCharset,
259 Value::CreateStringValue("utf8"));
260 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize,
261 Value::CreateIntegerValue(20));
262 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable,
263 Value::CreateBooleanValue(false));
264 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector,
265 Value::CreateBooleanValue(true));
266 pref_services->SetUserPref("webkit.webprefs.foo",
267 Value::CreateStringValue("bar"));
268 }
269
270 private:
271 content::TestBrowserThread ui_thread_;
272 };
273
274 // Tests to see that webkit preferences are properly loaded and copied over
275 // to a WebPreferences object.
276 TEST_F(PrefServiceWebKitPrefs, PrefsCopied) {
277 WebPreferences webkit_prefs = contents()->TestGetWebkitPrefs();
278
279 // These values have been overridden by the profile preferences.
280 EXPECT_EQ("UTF-8", webkit_prefs.default_encoding);
281 EXPECT_EQ(20, webkit_prefs.default_font_size);
282 EXPECT_FALSE(webkit_prefs.text_areas_are_resizable);
283 EXPECT_TRUE(webkit_prefs.uses_universal_detector);
284
285 // These should still be the default values.
286 #if defined(OS_MACOSX)
287 const char kDefaultFont[] = "Times";
288 #elif defined(OS_CHROMEOS)
289 const char kDefaultFont[] = "Tinos";
290 #else
291 const char kDefaultFont[] = "Times New Roman";
292 #endif
293 EXPECT_EQ(ASCIIToUTF16(kDefaultFont), webkit_prefs.standard_font_family);
294 EXPECT_TRUE(webkit_prefs.javascript_enabled);
295 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/tab_contents/web_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698