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 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/browser/renderer_host/mock_render_process_host.h" | 13 #include "content/browser/renderer_host/mock_render_process_host.h" |
14 #include "content/browser/renderer_host/render_view_host.h" | 14 #include "content/browser/renderer_host/render_view_host.h" |
15 #include "content/browser/renderer_host/render_view_host_factory.h" | 15 #include "content/browser/renderer_host/render_view_host_factory.h" |
16 #include "content/browser/renderer_host/render_widget_host_view.h" | 16 #include "content/browser/renderer_host/render_widget_host_view.h" |
17 #include "content/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class BrowserContext; | 21 class BrowserContext; |
22 } | 22 } |
23 | 23 |
24 namespace gfx { | 24 namespace gfx { |
25 class Rect; | 25 class Rect; |
26 } | 26 } |
27 | 27 |
28 class NavigationController; | 28 class NavigationController; |
29 class SiteInstance; | 29 class SiteInstance; |
30 class TestTabContents; | 30 class TestTabContents; |
31 struct WebMenuItem; | 31 struct WebMenuItem; |
32 struct ViewHostMsg_FrameNavigate_Params; | 32 struct ViewHostMsg_FrameNavigate_Params; |
33 | 33 |
34 // Utility function to initialize ViewHostMsg_NavigateParams_Params | 34 // Utility function to initialize ViewHostMsg_NavigateParams_Params |
35 // with given |page_id|, |url| and |transition_type|. | 35 // with given |page_id|, |url| and |transition_type|. |
36 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 36 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, |
37 int page_id, | 37 int page_id, |
38 const GURL& url, | 38 const GURL& url, |
39 PageTransition::Type transition_type); | 39 content::PageTransition transition_type); |
40 | 40 |
41 // This file provides a testing framework for mocking out the RenderProcessHost | 41 // This file provides a testing framework for mocking out the RenderProcessHost |
42 // layer. It allows you to test RenderViewHost, TabContents, | 42 // layer. It allows you to test RenderViewHost, TabContents, |
43 // NavigationController, and other layers above that without running an actual | 43 // NavigationController, and other layers above that without running an actual |
44 // renderer process. | 44 // renderer process. |
45 // | 45 // |
46 // To use, derive your test base class from RenderViewHostTestHarness. | 46 // To use, derive your test base class from RenderViewHostTestHarness. |
47 | 47 |
48 // TestRenderViewHostView ------------------------------------------------------ | 48 // TestRenderViewHostView ------------------------------------------------------ |
49 | 49 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Calls the RenderViewHosts' private OnMessageReceived function with the | 182 // Calls the RenderViewHosts' private OnMessageReceived function with the |
183 // given message. | 183 // given message. |
184 bool TestOnMessageReceived(const IPC::Message& msg); | 184 bool TestOnMessageReceived(const IPC::Message& msg); |
185 | 185 |
186 // Calls OnMsgNavigate on the RenderViewHost with the given information, | 186 // Calls OnMsgNavigate on the RenderViewHost with the given information, |
187 // setting the rest of the parameters in the message to the "typical" values. | 187 // setting the rest of the parameters in the message to the "typical" values. |
188 // This is a helper function for simulating the most common types of loads. | 188 // This is a helper function for simulating the most common types of loads. |
189 void SendNavigate(int page_id, const GURL& url); | 189 void SendNavigate(int page_id, const GURL& url); |
190 | 190 |
191 // Calls OnMsgNavigate on the RenderViewHost with the given information, | 191 // Calls OnMsgNavigate on the RenderViewHost with the given information, |
192 // including a custom PageTransition::Type. Sets the rest of the parameters | 192 // including a custom content::PageTransition. Sets the rest of the |
193 // in the message to the "typical" values. | 193 // parameters in the message to the "typical" values. This is a helper |
194 // This is a helper function for simulating the most common types of loads. | 194 // function for simulating the most common types of loads. |
195 void SendNavigateWithTransition(int page_id, const GURL& url, | 195 void SendNavigateWithTransition(int page_id, const GURL& url, |
196 PageTransition::Type transition); | 196 content::PageTransition transition); |
197 | 197 |
198 // Calls OnMsgShouldCloseACK on the RenderViewHost with the given parameter. | 198 // Calls OnMsgShouldCloseACK on the RenderViewHost with the given parameter. |
199 void SendShouldCloseACK(bool proceed); | 199 void SendShouldCloseACK(bool proceed); |
200 | 200 |
201 void TestOnMsgStartDragging(const WebDropData& drop_data); | 201 void TestOnMsgStartDragging(const WebDropData& drop_data); |
202 | 202 |
203 // If set, *delete_counter is incremented when this object destructs. | 203 // If set, *delete_counter is incremented when this object destructs. |
204 void set_delete_counter(int* delete_counter) { | 204 void set_delete_counter(int* delete_counter) { |
205 delete_counter_ = delete_counter; | 205 delete_counter_ = delete_counter; |
206 } | 206 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 MockRenderProcessHostFactory rph_factory_; | 337 MockRenderProcessHostFactory rph_factory_; |
338 TestRenderViewHostFactory rvh_factory_; | 338 TestRenderViewHostFactory rvh_factory_; |
339 | 339 |
340 private: | 340 private: |
341 scoped_ptr<TestTabContents> contents_; | 341 scoped_ptr<TestTabContents> contents_; |
342 | 342 |
343 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 343 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
344 }; | 344 }; |
345 | 345 |
346 #endif // CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ | 346 #endif // CONTENT_BROWSER_RENDERER_HOST_TEST_TEST_RENDER_VIEW_HOST_H_ |
OLD | NEW |