OLD | NEW |
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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/dom_operation_notification_details.h" | 7 #include "chrome/browser/dom_operation_notification_details.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" | 9 #include "chrome/browser/tab_contents/chrome_interstitial_page.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
14 #include "chrome/test/base/testing_pref_service.h" | 15 #include "chrome/test/base/testing_pref_service.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "content/browser/browser_thread.h" | 17 #include "content/browser/browser_thread.h" |
17 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
18 #include "content/browser/renderer_host/render_widget_host_view.h" | 19 #include "content/browser/renderer_host/render_widget_host_view.h" |
19 #include "content/browser/renderer_host/test_render_view_host.h" | |
20 #include "content/browser/site_instance.h" | 20 #include "content/browser/site_instance.h" |
21 #include "content/browser/tab_contents/constrained_window.h" | 21 #include "content/browser/tab_contents/constrained_window.h" |
22 #include "content/browser/tab_contents/navigation_details.h" | 22 #include "content/browser/tab_contents/navigation_details.h" |
23 #include "content/browser/tab_contents/navigation_entry.h" | 23 #include "content/browser/tab_contents/navigation_entry.h" |
24 #include "content/browser/tab_contents/test_tab_contents.h" | 24 #include "content/browser/tab_contents/test_tab_contents.h" |
25 #include "content/common/bindings_policy.h" | 25 #include "content/common/bindings_policy.h" |
26 #include "content/common/notification_service.h" | 26 #include "content/common/notification_service.h" |
27 #include "content/common/notification_source.h" | 27 #include "content/common/notification_source.h" |
28 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 virtual void TestInterstitialPageDeleted(TestInterstitialPage* interstitial) { | 163 virtual void TestInterstitialPageDeleted(TestInterstitialPage* interstitial) { |
164 DCHECK(interstitial_page_ == interstitial); | 164 DCHECK(interstitial_page_ == interstitial); |
165 interstitial_page_ = NULL; | 165 interstitial_page_ = NULL; |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 TestInterstitialPage* interstitial_page_; | 169 TestInterstitialPage* interstitial_page_; |
170 }; | 170 }; |
171 | 171 |
172 class TabContentsTest : public RenderViewHostTestHarness { | 172 class TabContentsTest : public ChromeRenderViewHostTestHarness { |
173 public: | 173 public: |
174 TabContentsTest() | 174 TabContentsTest() : ui_thread_(BrowserThread::UI, &message_loop_) { |
175 : RenderViewHostTestHarness(), | |
176 ui_thread_(BrowserThread::UI, &message_loop_) { | |
177 } | 175 } |
178 | 176 |
179 private: | 177 private: |
180 // Supply our own profile so we use the correct profile data. The test harness | 178 // Supply our own profile so we use the correct profile data. The test harness |
181 // is not supposed to overwrite a profile if it's already created. | 179 // is not supposed to overwrite a profile if it's already created. |
182 virtual void SetUp() { | 180 virtual void SetUp() { |
183 TestingProfile* profile = new TestingProfile(); | 181 ChromeRenderViewHostTestHarness::SetUp(); |
184 profile_.reset(profile); | |
185 | 182 |
186 // Set some (WebKit) user preferences. | 183 // Set some (WebKit) user preferences. |
187 TestingPrefService* pref_services = profile->GetTestingPrefService(); | 184 TestingPrefService* pref_services = profile()->GetTestingPrefService(); |
188 #if defined(TOOLKIT_USES_GTK) | 185 #if defined(TOOLKIT_USES_GTK) |
189 pref_services->SetUserPref(prefs::kUsesSystemTheme, | 186 pref_services->SetUserPref(prefs::kUsesSystemTheme, |
190 Value::CreateBooleanValue(false)); | 187 Value::CreateBooleanValue(false)); |
191 #endif | 188 #endif |
192 pref_services->SetUserPref(prefs::kDefaultCharset, | 189 pref_services->SetUserPref(prefs::kDefaultCharset, |
193 Value::CreateStringValue("utf8")); | 190 Value::CreateStringValue("utf8")); |
194 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, | 191 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, |
195 Value::CreateIntegerValue(20)); | 192 Value::CreateIntegerValue(20)); |
196 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, | 193 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, |
197 Value::CreateBooleanValue(false)); | 194 Value::CreateBooleanValue(false)); |
198 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector, | 195 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector, |
199 Value::CreateBooleanValue(true)); | 196 Value::CreateBooleanValue(true)); |
200 pref_services->SetUserPref("webkit.webprefs.foo", | 197 pref_services->SetUserPref("webkit.webprefs.foo", |
201 Value::CreateStringValue("bar")); | 198 Value::CreateStringValue("bar")); |
202 | |
203 RenderViewHostTestHarness::SetUp(); | |
204 } | |
205 | |
206 virtual void TearDown() { | |
207 RenderViewHostTestHarness::TearDown(); | |
208 | |
209 profile_.reset(NULL); | |
210 } | 199 } |
211 | 200 |
212 BrowserThread ui_thread_; | 201 BrowserThread ui_thread_; |
213 }; | 202 }; |
214 | 203 |
215 // Test to make sure that title updates get stripped of whitespace. | 204 // Test to make sure that title updates get stripped of whitespace. |
216 TEST_F(TabContentsTest, UpdateTitle) { | 205 TEST_F(TabContentsTest, UpdateTitle) { |
217 ViewHostMsg_FrameNavigate_Params params; | 206 ViewHostMsg_FrameNavigate_Params params; |
218 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), | 207 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), |
219 PageTransition::TYPED); | 208 PageTransition::TYPED); |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 window.close_count = 0; | 1795 window.close_count = 0; |
1807 | 1796 |
1808 const int kWindowCount = 4; | 1797 const int kWindowCount = 4; |
1809 for (int i = 0; i < kWindowCount; i++) { | 1798 for (int i = 0; i < kWindowCount; i++) { |
1810 tab_contents->AddConstrainedDialog(&window); | 1799 tab_contents->AddConstrainedDialog(&window); |
1811 } | 1800 } |
1812 EXPECT_EQ(window.close_count, 0); | 1801 EXPECT_EQ(window.close_count, 0); |
1813 delete tab_contents; | 1802 delete tab_contents; |
1814 EXPECT_EQ(window.close_count, kWindowCount); | 1803 EXPECT_EQ(window.close_count, kWindowCount); |
1815 } | 1804 } |
OLD | NEW |