OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef FrameTestHelpers_h | 31 #ifndef FrameTestHelpers_h |
32 #define FrameTestHelpers_h | 32 #define FrameTestHelpers_h |
33 | 33 |
| 34 #include <gmock/gmock.h> |
| 35 #include <gtest/gtest.h> |
| 36 #include <memory> |
| 37 #include <string> |
| 38 #include "core/exported/WebViewBase.h" |
34 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
35 #include "platform/RuntimeEnabledFeatures.h" | 40 #include "platform/RuntimeEnabledFeatures.h" |
36 #include "platform/scroll/ScrollbarTheme.h" | 41 #include "platform/scroll/ScrollbarTheme.h" |
37 #include "public/platform/WebMouseEvent.h" | 42 #include "public/platform/WebMouseEvent.h" |
38 #include "public/platform/WebString.h" | 43 #include "public/platform/WebString.h" |
39 #include "public/platform/WebURLRequest.h" | 44 #include "public/platform/WebURLRequest.h" |
40 #include "public/web/WebFrameClient.h" | 45 #include "public/web/WebFrameClient.h" |
41 #include "public/web/WebFrameOwnerProperties.h" | 46 #include "public/web/WebFrameOwnerProperties.h" |
42 #include "public/web/WebHistoryItem.h" | 47 #include "public/web/WebHistoryItem.h" |
43 #include "public/web/WebRemoteFrameClient.h" | 48 #include "public/web/WebRemoteFrameClient.h" |
44 #include "public/web/WebSettings.h" | 49 #include "public/web/WebSettings.h" |
45 #include "public/web/WebViewClient.h" | 50 #include "public/web/WebViewClient.h" |
46 #include "web/WebViewImpl.h" | |
47 #include <gmock/gmock.h> | |
48 #include <gtest/gtest.h> | |
49 #include <memory> | |
50 #include <string> | |
51 | 51 |
52 namespace blink { | 52 namespace blink { |
53 | 53 |
54 class WebFrame; | 54 class WebFrame; |
55 class WebLocalFrameImpl; | 55 class WebLocalFrameImpl; |
56 class WebRemoteFrameImpl; | 56 class WebRemoteFrameImpl; |
57 class WebSettings; | 57 class WebSettings; |
58 enum class WebCachePolicy; | 58 enum class WebCachePolicy; |
59 | 59 |
60 namespace FrameTestHelpers { | 60 namespace FrameTestHelpers { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 class WebViewHelper { | 200 class WebViewHelper { |
201 WTF_MAKE_NONCOPYABLE(WebViewHelper); | 201 WTF_MAKE_NONCOPYABLE(WebViewHelper); |
202 | 202 |
203 public: | 203 public: |
204 WebViewHelper(SettingOverrider* = 0); | 204 WebViewHelper(SettingOverrider* = 0); |
205 ~WebViewHelper(); | 205 ~WebViewHelper(); |
206 | 206 |
207 // Creates and initializes the WebView. Implicitly calls reset() first. If | 207 // Creates and initializes the WebView. Implicitly calls reset() first. If |
208 // a WebFrameClient or a WebViewClient are passed in, they must outlive the | 208 // a WebFrameClient or a WebViewClient are passed in, they must outlive the |
209 // WebViewHelper. | 209 // WebViewHelper. |
210 WebViewImpl* InitializeWithOpener( | 210 WebViewBase* InitializeWithOpener( |
211 WebFrame* opener, | 211 WebFrame* opener, |
212 bool enable_javascript = false, | 212 bool enable_javascript = false, |
213 TestWebFrameClient* = nullptr, | 213 TestWebFrameClient* = nullptr, |
214 TestWebViewClient* = nullptr, | 214 TestWebViewClient* = nullptr, |
215 TestWebWidgetClient* = nullptr, | 215 TestWebWidgetClient* = nullptr, |
216 void (*update_settings_func)(WebSettings*) = nullptr); | 216 void (*update_settings_func)(WebSettings*) = nullptr); |
217 | 217 |
218 // Same as initializeWithOpener(), but always sets the opener to null. | 218 // Same as initializeWithOpener(), but always sets the opener to null. |
219 WebViewImpl* Initialize(bool enable_javascript = false, | 219 WebViewBase* Initialize(bool enable_javascript = false, |
220 TestWebFrameClient* = nullptr, | 220 TestWebFrameClient* = nullptr, |
221 TestWebViewClient* = nullptr, | 221 TestWebViewClient* = nullptr, |
222 TestWebWidgetClient* = nullptr, | 222 TestWebWidgetClient* = nullptr, |
223 void (*update_settings_func)(WebSettings*) = 0); | 223 void (*update_settings_func)(WebSettings*) = 0); |
224 | 224 |
225 // Same as initialize() but also performs the initial load of the url. Only | 225 // Same as initialize() but also performs the initial load of the url. Only |
226 // returns once the load is complete. | 226 // returns once the load is complete. |
227 WebViewImpl* InitializeAndLoad( | 227 WebViewBase* InitializeAndLoad( |
228 const std::string& url, | 228 const std::string& url, |
229 bool enable_javascript = false, | 229 bool enable_javascript = false, |
230 TestWebFrameClient* = nullptr, | 230 TestWebFrameClient* = nullptr, |
231 TestWebViewClient* = nullptr, | 231 TestWebViewClient* = nullptr, |
232 TestWebWidgetClient* = nullptr, | 232 TestWebWidgetClient* = nullptr, |
233 void (*update_settings_func)(WebSettings*) = 0); | 233 void (*update_settings_func)(WebSettings*) = 0); |
234 | 234 |
235 void Resize(WebSize); | 235 void Resize(WebSize); |
236 | 236 |
237 void Reset(); | 237 void Reset(); |
238 | 238 |
239 WebViewImpl* WebView() const { return web_view_; } | 239 WebViewBase* WebView() const { return web_view_; } |
240 | 240 |
241 private: | 241 private: |
242 WebViewImpl* web_view_; | 242 WebViewBase* web_view_; |
243 SettingOverrider* setting_overrider_; | 243 SettingOverrider* setting_overrider_; |
244 UseMockScrollbarSettings mock_scrollbar_settings_; | 244 UseMockScrollbarSettings mock_scrollbar_settings_; |
245 TestWebViewClient* test_web_view_client_; | 245 TestWebViewClient* test_web_view_client_; |
246 }; | 246 }; |
247 | 247 |
248 // Minimal implementation of WebFrameClient needed for unit tests that load | 248 // Minimal implementation of WebFrameClient needed for unit tests that load |
249 // frames. Tests that load frames and need further specialization of | 249 // frames. Tests that load frames and need further specialization of |
250 // WebFrameClient behavior should subclass this. | 250 // WebFrameClient behavior should subclass this. |
251 class TestWebFrameClient : public WebFrameClient { | 251 class TestWebFrameClient : public WebFrameClient { |
252 public: | 252 public: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 WebDOMMessageEvent) override {} | 295 WebDOMMessageEvent) override {} |
296 | 296 |
297 private: | 297 private: |
298 Persistent<WebRemoteFrameImpl> const frame_; | 298 Persistent<WebRemoteFrameImpl> const frame_; |
299 }; | 299 }; |
300 | 300 |
301 } // namespace FrameTestHelpers | 301 } // namespace FrameTestHelpers |
302 } // namespace blink | 302 } // namespace blink |
303 | 303 |
304 #endif // FrameTestHelpers_h | 304 #endif // FrameTestHelpers_h |
OLD | NEW |