Chromium Code Reviews| 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; | 240 virtual void SendNavigate(int page_id, const GURL& url) OVERRIDE; |
|
Charlie Reis
2014/02/05 23:30:37
Can you add a note saying these navigation methods
nasko
2014/02/06 20:08:00
Done.
| |
| 241 virtual void SendFailedNavigate(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, | 242 virtual void SendNavigateWithTransition(int page_id, const GURL& url, |
| 243 PageTransition transition) OVERRIDE; | 243 PageTransition transition) OVERRIDE; |
| 244 virtual void SendShouldCloseACK(bool proceed) OVERRIDE; | 244 virtual void SendShouldCloseACK(bool proceed) OVERRIDE; |
| 245 virtual void SetContentsMimeType(const std::string& mime_type) OVERRIDE; | 245 virtual void SetContentsMimeType(const std::string& mime_type) OVERRIDE; |
| 246 virtual void SimulateSwapOutACK() OVERRIDE; | 246 virtual void SimulateSwapOutACK() OVERRIDE; |
| 247 virtual void SimulateWasHidden() OVERRIDE; | 247 virtual void SimulateWasHidden() OVERRIDE; |
| 248 virtual void SimulateWasShown() OVERRIDE; | 248 virtual void SimulateWasShown() OVERRIDE; |
| 249 | 249 |
| 250 // Calls OnNavigate on the RenderViewHost with the given information, | 250 // Calls OnNavigate on the RenderViewHost with the given information, |
| 251 // including a custom original request URL. Sets the rest of the | 251 // including a custom original request URL. Sets the rest of the |
| 252 // parameters in the message to the "typical" values. This is a helper | 252 // parameters in the message to the "typical" values. This is a helper |
| 253 // function for simulating the most common types of loads. | 253 // function for simulating the most common types of loads. |
| 254 void SendNavigateWithOriginalRequestURL( | 254 void SendNavigateWithOriginalRequestURL( |
| 255 int page_id, const GURL& url, const GURL& original_request_url); | 255 int page_id, const GURL& url, const GURL& original_request_url); |
| 256 | 256 |
| 257 void SendNavigateWithFile( | 257 void SendNavigateWithFile( |
| 258 int page_id, const GURL& url, const base::FilePath& file_path); | 258 int page_id, const GURL& url, const base::FilePath& file_path); |
| 259 | 259 |
| 260 void SendNavigateWithParams(ViewHostMsg_FrameNavigate_Params* params); | 260 void SendNavigateWithParams( |
| 261 FrameHostMsg_DidCommitProvisionalLoad_Params* params); | |
| 261 | 262 |
| 262 void TestOnUpdateStateWithFile( | 263 void TestOnUpdateStateWithFile( |
| 263 int process_id, const base::FilePath& file_path); | 264 int process_id, const base::FilePath& file_path); |
| 264 | 265 |
| 265 void TestOnStartDragging(const DropData& drop_data); | 266 void TestOnStartDragging(const DropData& drop_data); |
| 266 | 267 |
| 267 // If set, *delete_counter is incremented when this object destructs. | 268 // If set, *delete_counter is incremented when this object destructs. |
| 268 void set_delete_counter(int* delete_counter) { | 269 void set_delete_counter(int* delete_counter) { |
| 269 delete_counter_ = delete_counter; | 270 delete_counter_ = delete_counter; |
| 270 } | 271 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 293 void set_is_swapped_out(bool is_swapped_out) { | 294 void set_is_swapped_out(bool is_swapped_out) { |
| 294 is_swapped_out_ = is_swapped_out; | 295 is_swapped_out_ = is_swapped_out; |
| 295 } | 296 } |
| 296 | 297 |
| 297 // If set, navigations will appear to have loaded through a proxy | 298 // If set, navigations will appear to have loaded through a proxy |
| 298 // (ViewHostMsg_FrameNavigte_Params::was_fetched_via_proxy). | 299 // (ViewHostMsg_FrameNavigte_Params::was_fetched_via_proxy). |
| 299 // False by default. | 300 // False by default. |
| 300 void set_simulate_fetch_via_proxy(bool proxy); | 301 void set_simulate_fetch_via_proxy(bool proxy); |
| 301 | 302 |
| 302 // If set, navigations will appear to have cleared the history list in the | 303 // If set, navigations will appear to have cleared the history list in the |
| 303 // RenderView (ViewHostMsg_FrameNavigate_Params::history_list_was_cleared). | 304 // RenderView |
| 305 // (FrameHostMsg_DidCommitProvisionalLoad_Params::history_list_was_cleared). | |
| 304 // False by default. | 306 // False by default. |
| 305 void set_simulate_history_list_was_cleared(bool cleared); | 307 void set_simulate_history_list_was_cleared(bool cleared); |
| 306 | 308 |
| 307 // The opener route id passed to CreateRenderView(). | 309 // The opener route id passed to CreateRenderView(). |
| 308 int opener_route_id() const { return opener_route_id_; } | 310 int opener_route_id() const { return opener_route_id_; } |
| 309 | 311 |
| 310 // TODO(creis): Remove the need for these methods. | 312 // TODO(creis): Remove the need for these methods. |
| 311 TestRenderFrameHost* main_render_frame_host() const { | 313 TestRenderFrameHost* main_render_frame_host() const { |
| 312 return main_render_frame_host_; | 314 return main_render_frame_host_; |
| 313 } | 315 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 private: | 386 private: |
| 385 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> | 387 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> |
| 386 ScopedSetSupportedScaleFactors; | 388 ScopedSetSupportedScaleFactors; |
| 387 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 389 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
| 388 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); | 390 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); |
| 389 }; | 391 }; |
| 390 | 392 |
| 391 } // namespace content | 393 } // namespace content |
| 392 | 394 |
| 393 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 395 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
| OLD | NEW |