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

Side by Side Diff: chrome/browser/tab_contents/web_contents_unittest.cc

Issue 3051001: Adjust preference sync code to only sync user modifiable preferences. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: separate out the download_manager_unittest.cc fixes Created 10 years, 5 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/message_box_flags.h" 5 #include "app/message_box_flags.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "chrome/browser/pref_service.h" 7 #include "chrome/browser/pref_service.h"
8 #include "chrome/browser/pref_value_store.h" 8 #include "chrome/browser/pref_value_store.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/renderer_host/render_widget_host_view.h" 10 #include "chrome/browser/renderer_host/render_widget_host_view.h"
11 #include "chrome/browser/renderer_host/test/test_render_view_host.h" 11 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
12 #include "chrome/browser/chrome_thread.h" 12 #include "chrome/browser/chrome_thread.h"
13 #include "chrome/browser/tab_contents/interstitial_page.h" 13 #include "chrome/browser/tab_contents/interstitial_page.h"
14 #include "chrome/browser/tab_contents/navigation_controller.h" 14 #include "chrome/browser/tab_contents/navigation_controller.h"
15 #include "chrome/browser/tab_contents/navigation_entry.h" 15 #include "chrome/browser/tab_contents/navigation_entry.h"
16 #include "chrome/browser/tab_contents/test_tab_contents.h" 16 #include "chrome/browser/tab_contents/test_tab_contents.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/pref_names.h"
18 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
19 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
20 #include "chrome/test/testing_profile.h" 21 #include "chrome/test/testing_profile.h"
21 #include "ipc/ipc_channel.h" 22 #include "ipc/ipc_channel.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using webkit_glue::PasswordForm; 25 using webkit_glue::PasswordForm;
25 26
26 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, 27 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params,
27 int page_id, 28 int page_id,
28 const GURL& url) { 29 const GURL& url) {
29 params->page_id = page_id; 30 params->page_id = page_id;
30 params->url = url; 31 params->url = url;
31 params->referrer = GURL(); 32 params->referrer = GURL();
32 params->transition = PageTransition::TYPED; 33 params->transition = PageTransition::TYPED;
33 params->redirects = std::vector<GURL>(); 34 params->redirects = std::vector<GURL>();
34 params->should_update_history = false; 35 params->should_update_history = false;
35 params->searchable_form_url = GURL(); 36 params->searchable_form_url = GURL();
36 params->searchable_form_encoding = std::string(); 37 params->searchable_form_encoding = std::string();
37 params->password_form = PasswordForm(); 38 params->password_form = PasswordForm();
38 params->security_info = std::string(); 39 params->security_info = std::string();
39 params->gesture = NavigationGestureUser; 40 params->gesture = NavigationGestureUser;
40 params->is_post = false; 41 params->is_post = false;
41 } 42 }
42 43
43 // Subclass the TestingProfile so that it can return certain services we need.
44 class TabContentsTestingProfile : public TestingProfile {
45 public:
46 TabContentsTestingProfile() : TestingProfile() {
47 CreateBookmarkModel(false);
48 }
49
50 virtual PrefService* GetPrefs() {
51 if (!prefs_.get()) {
52 FilePath source_path;
53 PathService::Get(chrome::DIR_TEST_DATA, &source_path);
54 source_path = source_path.AppendASCII("profiles")
55 .AppendASCII("chrome_prefs").AppendASCII("Preferences");
56
57 // Create a preference service that only contains user defined
58 // preference values.
59 prefs_.reset(PrefService::CreateUserPrefService(source_path));
60 Profile::RegisterUserPrefs(prefs_.get());
61 browser::RegisterAllPrefs(prefs_.get(), prefs_.get());
62 }
63 return prefs_.get();
64 }
65 };
66
67 class TestInterstitialPage : public InterstitialPage { 44 class TestInterstitialPage : public InterstitialPage {
68 public: 45 public:
69 enum InterstitialState { 46 enum InterstitialState {
70 UNDECIDED = 0, // No decision taken yet. 47 UNDECIDED = 0, // No decision taken yet.
71 OKED, // Proceed was called. 48 OKED, // Proceed was called.
72 CANCELED // DontProceed was called. 49 CANCELED // DontProceed was called.
73 }; 50 };
74 51
75 class Delegate { 52 class Delegate {
76 public: 53 public:
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 public: 176 public:
200 TabContentsTest() 177 TabContentsTest()
201 : RenderViewHostTestHarness(), 178 : RenderViewHostTestHarness(),
202 ui_thread_(ChromeThread::UI, &message_loop_) { 179 ui_thread_(ChromeThread::UI, &message_loop_) {
203 } 180 }
204 181
205 private: 182 private:
206 // Supply our own profile so we use the correct profile data. The test harness 183 // Supply our own profile so we use the correct profile data. The test harness
207 // is not supposed to overwrite a profile if it's already created. 184 // is not supposed to overwrite a profile if it's already created.
208 virtual void SetUp() { 185 virtual void SetUp() {
209 profile_.reset(new TabContentsTestingProfile()); 186 TestingProfile* profile = new TestingProfile();
187 profile->CreateBookmarkModel(false);
188 profile_.reset(profile);
189
190 // Set some (WebKit) user preferences.
191 TestingPrefService* pref_services = profile->GetPrefs();
192 #if defined(TOOLKIT_USES_GTK)
193 pref_services->SetUserPref(prefs::kUsesSystemTheme,
194 Value::CreateBooleanValue(false));
195 #endif
196 pref_services->SetUserPref(prefs::kDefaultCharset,
197 Value::CreateStringValue("utf8"));
198 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize,
199 Value::CreateIntegerValue(20));
200 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable,
201 Value::CreateBooleanValue(false));
202 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector,
203 Value::CreateBooleanValue(true));
204 pref_services->SetUserPref(prefs::kWebKitStandardFontIsSerif,
205 Value::CreateBooleanValue(true));
206 pref_services->SetUserPref(L"webkit.webprefs.foo",
207 Value::CreateStringValue(L"bar"));
210 208
211 RenderViewHostTestHarness::SetUp(); 209 RenderViewHostTestHarness::SetUp();
212 } 210 }
213 211
214 virtual void TearDown() { 212 virtual void TearDown() {
215 RenderViewHostTestHarness::TearDown(); 213 RenderViewHostTestHarness::TearDown();
216 214
217 profile_.reset(NULL); 215 profile_.reset(NULL);
218 } 216 }
219 217
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 1467
1470 // While the interstitial is showing, let's simulate the hidden page 1468 // While the interstitial is showing, let's simulate the hidden page
1471 // attempting to show a JS message. 1469 // attempting to show a JS message.
1472 IPC::Message* dummy_message = new IPC::Message; 1470 IPC::Message* dummy_message = new IPC::Message;
1473 bool did_suppress_message = false; 1471 bool did_suppress_message = false;
1474 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", 1472 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK",
1475 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message, 1473 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message,
1476 &did_suppress_message); 1474 &did_suppress_message);
1477 EXPECT_TRUE(did_suppress_message); 1475 EXPECT_TRUE(did_suppress_message);
1478 } 1476 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_preference_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698