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_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // RenderFrameHost testing was enabled; use a | 47 // RenderFrameHost testing was enabled; use a |
48 // RenderViewHostTestEnabler instance (see below) to do this. | 48 // RenderViewHostTestEnabler instance (see below) to do this. |
49 static RenderFrameHostTester* For(RenderFrameHost* host); | 49 static RenderFrameHostTester* For(RenderFrameHost* host); |
50 | 50 |
51 virtual ~RenderFrameHostTester() {} | 51 virtual ~RenderFrameHostTester() {} |
52 | 52 |
53 // Gives tests access to RenderFrameHostImpl::OnCreateChild. The returned | 53 // Gives tests access to RenderFrameHostImpl::OnCreateChild. The returned |
54 // RenderFrameHost is owned by the parent RenderFrameHost. | 54 // RenderFrameHost is owned by the parent RenderFrameHost. |
55 virtual RenderFrameHost* AppendChild(const std::string& frame_name) = 0; | 55 virtual RenderFrameHost* AppendChild(const std::string& frame_name) = 0; |
56 | 56 |
57 // Calls OnMsgNavigate on the RenderViewHost with the given information, | 57 // Calls OnDidCommitProvisionalLoad on the RenderFrameHost with the given |
58 // including a custom PageTransition. Sets the rest of the | 58 // information, including a custom PageTransition. Sets the rest of the |
59 // parameters in the message to the "typical" values. This is a helper | 59 // parameters in the message to the "typical" values. This is a helper |
60 // function for simulating the most common types of loads. | 60 // function for simulating the most common types of loads. |
61 virtual void SendNavigateWithTransition(int page_id, | 61 virtual void SendNavigateWithTransition(int page_id, |
62 const GURL& url, | 62 const GURL& url, |
63 ui::PageTransition transition) = 0; | 63 ui::PageTransition transition) = 0; |
| 64 |
| 65 // Calls OnBeforeUnloadACK on this RenderFrameHost with the given parameter. |
| 66 virtual void SendBeforeUnloadACK(bool proceed) = 0; |
| 67 |
| 68 // Simulates the SwapOut_ACK that fires if you commit a cross-site |
| 69 // navigation without making any network requests. |
| 70 virtual void SimulateSwapOutACK() = 0; |
64 }; | 71 }; |
65 | 72 |
66 // An interface and utility for driving tests of RenderViewHost. | 73 // An interface and utility for driving tests of RenderViewHost. |
67 class RenderViewHostTester { | 74 class RenderViewHostTester { |
68 public: | 75 public: |
69 // Retrieves the RenderViewHostTester that drives the specified | 76 // Retrieves the RenderViewHostTester that drives the specified |
70 // RenderViewHost. The RenderViewHost must have been created while | 77 // RenderViewHost. The RenderViewHost must have been created while |
71 // RenderViewHost testing was enabled; use a | 78 // RenderViewHost testing was enabled; use a |
72 // RenderViewHostTestEnabler instance (see below) to do this. | 79 // RenderViewHostTestEnabler instance (see below) to do this. |
73 static RenderViewHostTester* For(RenderViewHost* host); | 80 static RenderViewHostTester* For(RenderViewHost* host); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 virtual void SendNavigate(int page_id, const GURL& url) = 0; | 113 virtual void SendNavigate(int page_id, const GURL& url) = 0; |
107 virtual void SendFailedNavigate(int page_id, const GURL& url) = 0; | 114 virtual void SendFailedNavigate(int page_id, const GURL& url) = 0; |
108 | 115 |
109 // Calls OnMsgNavigate on the RenderViewHost with the given information, | 116 // Calls OnMsgNavigate on the RenderViewHost with the given information, |
110 // including a custom PageTransition. Sets the rest of the | 117 // including a custom PageTransition. Sets the rest of the |
111 // parameters in the message to the "typical" values. This is a helper | 118 // parameters in the message to the "typical" values. This is a helper |
112 // function for simulating the most common types of loads. | 119 // function for simulating the most common types of loads. |
113 virtual void SendNavigateWithTransition(int page_id, const GURL& url, | 120 virtual void SendNavigateWithTransition(int page_id, const GURL& url, |
114 ui::PageTransition transition) = 0; | 121 ui::PageTransition transition) = 0; |
115 | 122 |
116 // Calls OnBeforeUnloadACK on the main RenderFrameHost with the given | |
117 // parameter. | |
118 virtual void SendBeforeUnloadACK(bool proceed) = 0; | |
119 | |
120 // If set, future loads will have |mime_type| set as the mime type. | 123 // If set, future loads will have |mime_type| set as the mime type. |
121 // If not set, the mime type will default to "text/html". | 124 // If not set, the mime type will default to "text/html". |
122 virtual void SetContentsMimeType(const std::string& mime_type) = 0; | 125 virtual void SetContentsMimeType(const std::string& mime_type) = 0; |
123 | 126 |
124 // Simulates the SwapOut_ACK that fires if you commit a cross-site | |
125 // navigation without making any network requests. | |
126 virtual void SimulateSwapOutACK() = 0; | |
127 | |
128 // Makes the WasHidden/WasShown calls to the RenderWidget that | 127 // Makes the WasHidden/WasShown calls to the RenderWidget that |
129 // tell it it has been hidden or restored from having been hidden. | 128 // tell it it has been hidden or restored from having been hidden. |
130 virtual void SimulateWasHidden() = 0; | 129 virtual void SimulateWasHidden() = 0; |
131 virtual void SimulateWasShown() = 0; | 130 virtual void SimulateWasShown() = 0; |
132 }; | 131 }; |
133 | 132 |
134 // You can instantiate only one class like this at a time. During its | 133 // You can instantiate only one class like this at a time. During its |
135 // lifetime, RenderViewHost and RenderFrameHost objects created may be used via | 134 // lifetime, RenderViewHost and RenderFrameHost objects created may be used via |
136 // RenderViewHostTester and RenderFrameHostTester respectively. | 135 // RenderViewHostTester and RenderFrameHostTester respectively. |
137 class RenderViewHostTestEnabler { | 136 class RenderViewHostTestEnabler { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 242 |
244 int thread_bundle_options_; | 243 int thread_bundle_options_; |
245 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; | 244 scoped_ptr<TestBrowserThreadBundle> thread_bundle_; |
246 | 245 |
247 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 246 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
248 }; | 247 }; |
249 | 248 |
250 } // namespace content | 249 } // namespace content |
251 | 250 |
252 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ | 251 #endif // CONTENT_PUBLIC_TEST_TEST_RENDERER_HOST_H_ |
OLD | NEW |