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 #ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
15 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
16 #include "content/public/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" |
17 #include "content/public/test/test_renderer_host.h" | 17 #include "content/public/test/test_renderer_host.h" |
18 #include "content/test/test_render_frame_host.h" | 18 #include "content/test/test_render_frame_host.h" |
19 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" |
20 #include "ui/gfx/vector2d_f.h" | 20 #include "ui/gfx/vector2d_f.h" |
21 | 21 |
22 // This file provides a testing framework for mocking out the RenderProcessHost | 22 // This file provides a testing framework for mocking out the RenderProcessHost |
23 // layer. It allows you to test RenderViewHost, WebContentsImpl, | 23 // layer. It allows you to test RenderViewHost, WebContentsImpl, |
24 // NavigationController, and other layers above that without running an actual | 24 // NavigationController, and other layers above that without running an actual |
25 // renderer process. | 25 // renderer process. |
26 // | 26 // |
27 // To use, derive your test base class from RenderViewHostImplTestHarness. | 27 // To use, derive your test base class from RenderViewHostImplTestHarness. |
28 | 28 |
29 struct ViewHostMsg_FrameNavigate_Params; | 29 struct FrameHostMsg_DidCommitProvisionalLoad_Params; |
30 | 30 |
31 namespace gfx { | 31 namespace gfx { |
32 class Rect; | 32 class Rect; |
33 } | 33 } |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 | 36 |
37 class SiteInstance; | 37 class SiteInstance; |
38 class TestRenderFrameHost; | 38 class TestRenderFrameHost; |
39 class TestWebContents; | 39 class TestWebContents; |
40 | 40 |
41 // Utility function to initialize ViewHostMsg_NavigateParams_Params | 41 // Utility function to initialize ViewHostMsg_NavigateParams_Params |
42 // with given |page_id|, |url| and |transition_type|. | 42 // with given |page_id|, |url| and |transition_type|. |
43 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 43 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, |
44 int page_id, | 44 int page_id, |
45 const GURL& url, | 45 const GURL& url, |
46 PageTransition transition_type); | 46 PageTransition transition_type); |
47 | 47 |
48 // TestRenderViewHostView ------------------------------------------------------ | 48 // TestRenderViewHostView ------------------------------------------------------ |
49 | 49 |
50 // Subclass the RenderViewHost's view so that we can call Show(), etc., | 50 // Subclass the RenderViewHost's view so that we can call Show(), etc., |
51 // without having side-effects. | 51 // without having side-effects. |
52 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { | 52 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { |
53 public: | 53 public: |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 RenderViewHostDelegate* delegate, | 230 RenderViewHostDelegate* delegate, |
231 RenderWidgetHostDelegate* widget_delegate, | 231 RenderWidgetHostDelegate* widget_delegate, |
232 int routing_id, | 232 int routing_id, |
233 int main_frame_routing_id, | 233 int main_frame_routing_id, |
234 bool swapped_out); | 234 bool swapped_out); |
235 virtual ~TestRenderViewHost(); | 235 virtual ~TestRenderViewHost(); |
236 | 236 |
237 // RenderViewHostTester implementation. Note that CreateRenderView | 237 // RenderViewHostTester implementation. Note that CreateRenderView |
238 // is not specified since it is synonymous with the one from | 238 // is not specified since it is synonymous with the one from |
239 // RenderViewHostImpl, see below. | 239 // RenderViewHostImpl, see below. |
240 virtual void SendNavigate(int page_id, const GURL& url) OVERRIDE; | |
241 virtual void SendFailedNavigate(int page_id, const GURL& url) OVERRIDE; | |
242 virtual void SendNavigateWithTransition(int page_id, const GURL& url, | |
243 PageTransition transition) OVERRIDE; | |
244 virtual void SendShouldCloseACK(bool proceed) OVERRIDE; | 240 virtual void SendShouldCloseACK(bool proceed) OVERRIDE; |
245 virtual void SetContentsMimeType(const std::string& mime_type) OVERRIDE; | 241 virtual void SetContentsMimeType(const std::string& mime_type) OVERRIDE; |
246 virtual void SimulateSwapOutACK() OVERRIDE; | 242 virtual void SimulateSwapOutACK() OVERRIDE; |
247 virtual void SimulateWasHidden() OVERRIDE; | 243 virtual void SimulateWasHidden() OVERRIDE; |
248 virtual void SimulateWasShown() OVERRIDE; | 244 virtual void SimulateWasShown() OVERRIDE; |
249 | 245 |
| 246 // NOTE: These methods are deprecated and the equivalents in |
| 247 // TestRenderFrameHost should be used. |
| 248 virtual void SendNavigate(int page_id, const GURL& url) OVERRIDE; |
| 249 virtual void SendFailedNavigate(int page_id, const GURL& url) OVERRIDE; |
| 250 virtual void SendNavigateWithTransition(int page_id, const GURL& url, |
| 251 PageTransition transition) OVERRIDE; |
| 252 |
250 // Calls OnNavigate on the RenderViewHost with the given information, | 253 // Calls OnNavigate on the RenderViewHost with the given information, |
251 // including a custom original request URL. Sets the rest of the | 254 // including a custom original request URL. Sets the rest of the |
252 // parameters in the message to the "typical" values. This is a helper | 255 // parameters in the message to the "typical" values. This is a helper |
253 // function for simulating the most common types of loads. | 256 // function for simulating the most common types of loads. |
254 void SendNavigateWithOriginalRequestURL( | 257 void SendNavigateWithOriginalRequestURL( |
255 int page_id, const GURL& url, const GURL& original_request_url); | 258 int page_id, const GURL& url, const GURL& original_request_url); |
256 | 259 |
257 void SendNavigateWithFile( | 260 void SendNavigateWithFile( |
258 int page_id, const GURL& url, const base::FilePath& file_path); | 261 int page_id, const GURL& url, const base::FilePath& file_path); |
259 | 262 |
260 void SendNavigateWithParams(ViewHostMsg_FrameNavigate_Params* params); | 263 void SendNavigateWithParams( |
| 264 FrameHostMsg_DidCommitProvisionalLoad_Params* params); |
261 | 265 |
262 void TestOnUpdateStateWithFile( | 266 void TestOnUpdateStateWithFile( |
263 int process_id, const base::FilePath& file_path); | 267 int process_id, const base::FilePath& file_path); |
264 | 268 |
265 void TestOnStartDragging(const DropData& drop_data); | 269 void TestOnStartDragging(const DropData& drop_data); |
266 | 270 |
267 // If set, *delete_counter is incremented when this object destructs. | 271 // If set, *delete_counter is incremented when this object destructs. |
268 void set_delete_counter(int* delete_counter) { | 272 void set_delete_counter(int* delete_counter) { |
269 delete_counter_ = delete_counter; | 273 delete_counter_ = delete_counter; |
270 } | 274 } |
(...skipping 22 matching lines...) Expand all Loading... |
293 void set_is_swapped_out(bool is_swapped_out) { | 297 void set_is_swapped_out(bool is_swapped_out) { |
294 is_swapped_out_ = is_swapped_out; | 298 is_swapped_out_ = is_swapped_out; |
295 } | 299 } |
296 | 300 |
297 // If set, navigations will appear to have loaded through a proxy | 301 // If set, navigations will appear to have loaded through a proxy |
298 // (ViewHostMsg_FrameNavigte_Params::was_fetched_via_proxy). | 302 // (ViewHostMsg_FrameNavigte_Params::was_fetched_via_proxy). |
299 // False by default. | 303 // False by default. |
300 void set_simulate_fetch_via_proxy(bool proxy); | 304 void set_simulate_fetch_via_proxy(bool proxy); |
301 | 305 |
302 // If set, navigations will appear to have cleared the history list in the | 306 // If set, navigations will appear to have cleared the history list in the |
303 // RenderView (ViewHostMsg_FrameNavigate_Params::history_list_was_cleared). | 307 // RenderView |
| 308 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared). |
304 // False by default. | 309 // False by default. |
305 void set_simulate_history_list_was_cleared(bool cleared); | 310 void set_simulate_history_list_was_cleared(bool cleared); |
306 | 311 |
307 // The opener route id passed to CreateRenderView(). | 312 // The opener route id passed to CreateRenderView(). |
308 int opener_route_id() const { return opener_route_id_; } | 313 int opener_route_id() const { return opener_route_id_; } |
309 | 314 |
310 // TODO(creis): Remove the need for these methods. | 315 // TODO(creis): Remove the need for these methods. |
311 TestRenderFrameHost* main_render_frame_host() const { | 316 TestRenderFrameHost* main_render_frame_host() const { |
312 return main_render_frame_host_; | 317 return main_render_frame_host_; |
313 } | 318 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 private: | 389 private: |
385 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> | 390 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> |
386 ScopedSetSupportedScaleFactors; | 391 ScopedSetSupportedScaleFactors; |
387 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 392 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
388 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); | 393 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); |
389 }; | 394 }; |
390 | 395 |
391 } // namespace content | 396 } // namespace content |
392 | 397 |
393 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 398 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
OLD | NEW |