OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/interstitial_page.h" | 6 #include "chrome/browser/interstitial_page.h" |
7 #include "chrome/browser/navigation_controller.h" | 7 #include "chrome/browser/navigation_controller.h" |
8 #include "chrome/browser/navigation_entry.h" | 8 #include "chrome/browser/navigation_entry.h" |
9 #include "chrome/browser/render_view_host.h" | 9 #include "chrome/browser/render_view_host.h" |
10 #include "chrome/browser/render_widget_host_view.h" | 10 #include "chrome/browser/render_widget_host_view.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 bool is_showing_; | 75 bool is_showing_; |
76 }; | 76 }; |
77 | 77 |
78 // Subclass RenderViewHost so that it does not create a process. | 78 // Subclass RenderViewHost so that it does not create a process. |
79 class TestRenderViewHost : public RenderViewHost { | 79 class TestRenderViewHost : public RenderViewHost { |
80 public: | 80 public: |
81 TestRenderViewHost( | 81 TestRenderViewHost( |
82 SiteInstance* instance, | 82 SiteInstance* instance, |
83 RenderViewHostDelegate* delegate, | 83 RenderViewHostDelegate* delegate, |
84 int routing_id, | 84 int routing_id, |
85 HANDLE modal_dialog_event) | 85 base::WaitableEvent* modal_dialog_event) |
86 : RenderViewHost(instance, delegate, routing_id, modal_dialog_event), | 86 : RenderViewHost(instance, delegate, routing_id, modal_dialog_event), |
87 is_loading(false), | 87 is_loading(false), |
88 is_created(false), | 88 is_created(false), |
89 immediate_before_unload(true), | 89 immediate_before_unload(true), |
90 delete_counter_(NULL) { | 90 delete_counter_(NULL) { |
91 set_view(new TestRenderWidgetHostView()); | 91 set_view(new TestRenderWidgetHostView()); |
92 } | 92 } |
93 ~TestRenderViewHost() { | 93 ~TestRenderViewHost() { |
94 // Track the delete if we've been asked to. | 94 // Track the delete if we've been asked to. |
95 if (delete_counter_) | 95 if (delete_counter_) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 public: | 149 public: |
150 static TestRenderViewHostFactory* GetInstance() { | 150 static TestRenderViewHostFactory* GetInstance() { |
151 static TestRenderViewHostFactory instance; | 151 static TestRenderViewHostFactory instance; |
152 return &instance; | 152 return &instance; |
153 } | 153 } |
154 | 154 |
155 virtual RenderViewHost* CreateRenderViewHost( | 155 virtual RenderViewHost* CreateRenderViewHost( |
156 SiteInstance* instance, | 156 SiteInstance* instance, |
157 RenderViewHostDelegate* delegate, | 157 RenderViewHostDelegate* delegate, |
158 int routing_id, | 158 int routing_id, |
159 HANDLE modal_dialog_event) { | 159 base::WaitableEvent* modal_dialog_event) { |
160 return new TestRenderViewHost( | 160 return new TestRenderViewHost( |
161 instance, delegate, routing_id, modal_dialog_event); | 161 instance, delegate, routing_id, modal_dialog_event); |
162 } | 162 } |
163 | 163 |
164 private: | 164 private: |
165 TestRenderViewHostFactory() {} | 165 TestRenderViewHostFactory() {} |
166 }; | 166 }; |
167 | 167 |
168 // Subclass the TestingProfile so that it can return certain services we need. | 168 // Subclass the TestingProfile so that it can return certain services we need. |
169 class WebContentsTestingProfile : public TestingProfile { | 169 class WebContentsTestingProfile : public TestingProfile { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 // State accessor. | 211 // State accessor. |
212 bool cross_navigation_pending() { | 212 bool cross_navigation_pending() { |
213 return render_manager_.cross_navigation_pending_; | 213 return render_manager_.cross_navigation_pending_; |
214 } | 214 } |
215 | 215 |
216 // Ensure we create TestRenderViewHosts that don't spawn processes. | 216 // Ensure we create TestRenderViewHosts that don't spawn processes. |
217 RenderViewHost* CreateRenderViewHost(SiteInstance* instance, | 217 RenderViewHost* CreateRenderViewHost(SiteInstance* instance, |
218 RenderViewHostDelegate* delegate, | 218 RenderViewHostDelegate* delegate, |
219 int routing_id, | 219 int routing_id, |
220 HANDLE modal_dialog_event) { | 220 base::WaitableEvent* modal_dialog_event)
{ |
221 return new TestRenderViewHost( | 221 return new TestRenderViewHost( |
222 instance, delegate, routing_id, modal_dialog_event); | 222 instance, delegate, routing_id, modal_dialog_event); |
223 } | 223 } |
224 | 224 |
225 // Overrides WebContents::ShouldTransitionCrossSite so that we can test both | 225 // Overrides WebContents::ShouldTransitionCrossSite so that we can test both |
226 // alternatives without using command-line switches. | 226 // alternatives without using command-line switches. |
227 bool ShouldTransitionCrossSite() { return transition_cross_site; } | 227 bool ShouldTransitionCrossSite() { return transition_cross_site; } |
228 | 228 |
229 // Promote DidNavigate to public. | 229 // Promote DidNavigate to public. |
230 void TestDidNavigate(TestRenderViewHost* render_view_host, | 230 void TestDidNavigate(TestRenderViewHost* render_view_host, |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 interstitial = | 1262 interstitial = |
1263 new TestInterstitialPage(contents, true, url, &state, &deleted); | 1263 new TestInterstitialPage(contents, true, url, &state, &deleted); |
1264 interstitial->Show(); | 1264 interstitial->Show(); |
1265 interstitial->TestDidNavigate(1, url); | 1265 interstitial->TestDidNavigate(1, url); |
1266 // Simulate a renderer crash. | 1266 // Simulate a renderer crash. |
1267 interstitial->TestRendererGone(); | 1267 interstitial->TestRendererGone(); |
1268 // The interstitial should have been dismissed. | 1268 // The interstitial should have been dismissed. |
1269 EXPECT_TRUE(deleted); | 1269 EXPECT_TRUE(deleted); |
1270 EXPECT_EQ(TestInterstitialPage::CANCELED, state); | 1270 EXPECT_EQ(TestInterstitialPage::CANCELED, state); |
1271 } | 1271 } |
OLD | NEW |