OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/mock_content_browser_client.h" | |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 7 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
10 #include "content/browser/site_instance_impl.h" | 9 #include "content/browser/site_instance_impl.h" |
11 #include "content/browser/web_contents/interstitial_page_impl.h" | 10 #include "content/browser/web_contents/interstitial_page_impl.h" |
12 #include "content/browser/web_contents/navigation_entry_impl.h" | 11 #include "content/browser/web_contents/navigation_entry_impl.h" |
13 #include "content/browser/web_contents/test_web_contents.h" | 12 #include "content/browser/web_contents/test_web_contents.h" |
14 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
15 #include "content/public/browser/interstitial_page_delegate.h" | 14 #include "content/public/browser/interstitial_page_delegate.h" |
16 #include "content/public/browser/navigation_details.h" | 15 #include "content/public/browser/navigation_details.h" |
17 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
19 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
21 #include "content/public/browser/web_ui_controller.h" | 20 #include "content/public/browser/web_ui_controller.h" |
22 #include "content/public/browser/web_ui_controller_factory.h" | 21 #include "content/public/browser/web_ui_controller_factory.h" |
23 #include "content/public/common/bindings_policy.h" | 22 #include "content/public/common/bindings_policy.h" |
24 #include "content/public/common/content_constants.h" | 23 #include "content/public/common/content_constants.h" |
25 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
26 #include "content/public/test/mock_render_process_host.h" | 25 #include "content/public/test/mock_render_process_host.h" |
27 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 27 #include "content/test/test_content_browser_client.h" |
28 #include "content/test/test_content_client.h" | 28 #include "content/test/test_content_client.h" |
29 #include "googleurl/src/url_util.h" | 29 #include "googleurl/src/url_util.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "webkit/glue/webkit_glue.h" | 31 #include "webkit/glue/webkit_glue.h" |
32 | 32 |
33 using content::BrowserContext; | 33 using content::BrowserContext; |
34 using content::BrowserThread; | 34 using content::BrowserThread; |
35 using content::InterstitialPage; | 35 using content::InterstitialPage; |
36 using content::MockRenderProcessHost; | 36 using content::MockRenderProcessHost; |
37 using content::NavigationEntry; | 37 using content::NavigationEntry; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 public: | 87 public: |
88 WebContentsImplTestContentClient() { | 88 WebContentsImplTestContentClient() { |
89 } | 89 } |
90 | 90 |
91 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 91 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
92 return url.SchemeIs("webcontentsimpltest"); | 92 return url.SchemeIs("webcontentsimpltest"); |
93 } | 93 } |
94 }; | 94 }; |
95 | 95 |
96 class WebContentsImplTestBrowserClient | 96 class WebContentsImplTestBrowserClient |
97 : public content::MockContentBrowserClient { | 97 : public content::TestContentBrowserClient { |
98 public: | 98 public: |
99 WebContentsImplTestBrowserClient() { | 99 WebContentsImplTestBrowserClient() { |
100 } | 100 } |
101 | 101 |
102 virtual content::WebUIControllerFactory* | 102 virtual content::WebUIControllerFactory* |
103 GetWebUIControllerFactory() OVERRIDE { | 103 GetWebUIControllerFactory() OVERRIDE { |
104 return &factory_; | 104 return &factory_; |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 | 283 |
284 virtual void SetUp() { | 284 virtual void SetUp() { |
285 // These tests treat webcontentsimpltest as a privileged WebUI scheme. | 285 // These tests treat webcontentsimpltest as a privileged WebUI scheme. |
286 // We must register it similarly to kChromeUIScheme. | 286 // We must register it similarly to kChromeUIScheme. |
287 url_util::AddStandardScheme("webcontentsimpltest"); | 287 url_util::AddStandardScheme("webcontentsimpltest"); |
288 | 288 |
289 old_client_ = content::GetContentClient(); | 289 old_client_ = content::GetContentClient(); |
290 old_browser_client_ = content::GetContentClient()->browser(); | 290 old_browser_client_ = content::GetContentClient()->browser(); |
291 content::SetContentClient(&client_); | 291 content::SetContentClient(&client_); |
292 content::GetContentClient()->set_browser(&browser_client_); | 292 content::GetContentClient()->set_browser_for_testing(&browser_client_); |
293 RenderViewHostImplTestHarness::SetUp(); | 293 RenderViewHostImplTestHarness::SetUp(); |
294 } | 294 } |
295 | 295 |
296 virtual void TearDown() { | 296 virtual void TearDown() { |
297 content::GetContentClient()->set_browser(old_browser_client_); | 297 content::GetContentClient()->set_browser_for_testing(old_browser_client_); |
298 content::SetContentClient(old_client_); | 298 content::SetContentClient(old_client_); |
299 RenderViewHostImplTestHarness::TearDown(); | 299 RenderViewHostImplTestHarness::TearDown(); |
300 } | 300 } |
301 | 301 |
302 private: | 302 private: |
303 WebContentsImplTestContentClient client_; | 303 WebContentsImplTestContentClient client_; |
304 WebContentsImplTestBrowserClient browser_client_; | 304 WebContentsImplTestBrowserClient browser_client_; |
305 content::ContentClient* old_client_; | 305 content::ContentClient* old_client_; |
306 content::ContentBrowserClient* old_browser_client_; | 306 content::ContentBrowserClient* old_browser_client_; |
307 TestBrowserThread ui_thread_; | 307 TestBrowserThread ui_thread_; |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 // It should have a transient entry. | 1939 // It should have a transient entry. |
1940 EXPECT_TRUE(other_controller.GetTransientEntry()); | 1940 EXPECT_TRUE(other_controller.GetTransientEntry()); |
1941 | 1941 |
1942 // And the interstitial should be showing. | 1942 // And the interstitial should be showing. |
1943 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); | 1943 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); |
1944 | 1944 |
1945 // And the interstitial should do a reload on don't proceed. | 1945 // And the interstitial should do a reload on don't proceed. |
1946 EXPECT_TRUE(static_cast<InterstitialPageImpl*>( | 1946 EXPECT_TRUE(static_cast<InterstitialPageImpl*>( |
1947 other_contents->GetInterstitialPage())->reload_on_dont_proceed()); | 1947 other_contents->GetInterstitialPage())->reload_on_dont_proceed()); |
1948 } | 1948 } |
OLD | NEW |