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() |
175 : RenderViewHostTestHarness(), | 175 : ChromeRenderViewHostTestHarness(), |
Paweł Hajdan Jr.
2011/09/13 19:16:36
nit: How about removing this?
| |
176 ui_thread_(BrowserThread::UI, &message_loop_) { | 176 ui_thread_(BrowserThread::UI, &message_loop_) { |
177 } | 177 } |
178 | 178 |
179 private: | 179 private: |
180 // Supply our own profile so we use the correct profile data. The test harness | 180 // 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. | 181 // is not supposed to overwrite a profile if it's already created. |
182 virtual void SetUp() { | 182 virtual void SetUp() { |
183 TestingProfile* profile = new TestingProfile(); | 183 TestingProfile* profile = new TestingProfile(); |
184 profile_.reset(profile); | 184 browser_context_.reset(profile); |
Paweł Hajdan Jr.
2011/09/13 19:16:36
nit: ChromeRender...TestHarness is going to initia
| |
185 | 185 |
186 // Set some (WebKit) user preferences. | 186 // Set some (WebKit) user preferences. |
187 TestingPrefService* pref_services = profile->GetTestingPrefService(); | 187 TestingPrefService* pref_services = profile->GetTestingPrefService(); |
188 #if defined(TOOLKIT_USES_GTK) | 188 #if defined(TOOLKIT_USES_GTK) |
189 pref_services->SetUserPref(prefs::kUsesSystemTheme, | 189 pref_services->SetUserPref(prefs::kUsesSystemTheme, |
190 Value::CreateBooleanValue(false)); | 190 Value::CreateBooleanValue(false)); |
191 #endif | 191 #endif |
192 pref_services->SetUserPref(prefs::kDefaultCharset, | 192 pref_services->SetUserPref(prefs::kDefaultCharset, |
193 Value::CreateStringValue("utf8")); | 193 Value::CreateStringValue("utf8")); |
194 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, | 194 pref_services->SetUserPref(prefs::kWebKitDefaultFontSize, |
195 Value::CreateIntegerValue(20)); | 195 Value::CreateIntegerValue(20)); |
196 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, | 196 pref_services->SetUserPref(prefs::kWebKitTextAreasAreResizable, |
197 Value::CreateBooleanValue(false)); | 197 Value::CreateBooleanValue(false)); |
198 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector, | 198 pref_services->SetUserPref(prefs::kWebKitUsesUniversalDetector, |
199 Value::CreateBooleanValue(true)); | 199 Value::CreateBooleanValue(true)); |
200 pref_services->SetUserPref("webkit.webprefs.foo", | 200 pref_services->SetUserPref("webkit.webprefs.foo", |
201 Value::CreateStringValue("bar")); | 201 Value::CreateStringValue("bar")); |
202 | 202 |
203 RenderViewHostTestHarness::SetUp(); | 203 ChromeRenderViewHostTestHarness::SetUp(); |
204 } | |
205 | |
206 virtual void TearDown() { | |
207 RenderViewHostTestHarness::TearDown(); | |
208 | |
209 profile_.reset(NULL); | |
210 } | 204 } |
211 | 205 |
212 BrowserThread ui_thread_; | 206 BrowserThread ui_thread_; |
213 }; | 207 }; |
214 | 208 |
215 // Test to make sure that title updates get stripped of whitespace. | 209 // Test to make sure that title updates get stripped of whitespace. |
216 TEST_F(TabContentsTest, UpdateTitle) { | 210 TEST_F(TabContentsTest, UpdateTitle) { |
217 ViewHostMsg_FrameNavigate_Params params; | 211 ViewHostMsg_FrameNavigate_Params params; |
218 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), | 212 InitNavigateParams(¶ms, 0, GURL(chrome::kAboutBlankURL), |
219 PageTransition::TYPED); | 213 PageTransition::TYPED); |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1806 window.close_count = 0; | 1800 window.close_count = 0; |
1807 | 1801 |
1808 const int kWindowCount = 4; | 1802 const int kWindowCount = 4; |
1809 for (int i = 0; i < kWindowCount; i++) { | 1803 for (int i = 0; i < kWindowCount; i++) { |
1810 tab_contents->AddConstrainedDialog(&window); | 1804 tab_contents->AddConstrainedDialog(&window); |
1811 } | 1805 } |
1812 EXPECT_EQ(window.close_count, 0); | 1806 EXPECT_EQ(window.close_count, 0); |
1813 delete tab_contents; | 1807 delete tab_contents; |
1814 EXPECT_EQ(window.close_count, kWindowCount); | 1808 EXPECT_EQ(window.close_count, kWindowCount); |
1815 } | 1809 } |
OLD | NEW |