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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class WebFrame; | 52 class WebFrame; |
53 class WebFrameWidget; | 53 class WebFrameWidget; |
54 class WebLocalFrame; | 54 class WebLocalFrame; |
55 class WebRemoteFrame; | 55 class WebRemoteFrame; |
56 class WebRemoteFrameImpl; | 56 class WebRemoteFrameImpl; |
57 enum class WebCachePolicy; | 57 enum class WebCachePolicy; |
58 | 58 |
59 namespace FrameTestHelpers { | 59 namespace FrameTestHelpers { |
60 | 60 |
61 class TestWebFrameClient; | 61 class TestWebFrameClient; |
| 62 using TestWebWidgetClient = WebWidgetClient; |
62 | 63 |
63 // Loads a url into the specified WebFrame for testing purposes. Pumps any | 64 // Loads a url into the specified WebFrame for testing purposes. Pumps any |
64 // pending resource requests, as well as waiting for the threaded parser to | 65 // pending resource requests, as well as waiting for the threaded parser to |
65 // finish, before returning. | 66 // finish, before returning. |
66 void loadFrame(WebFrame*, const std::string& url); | 67 void loadFrame(WebFrame*, const std::string& url); |
67 // Same as above, but for WebFrame::loadHTMLString(). | 68 // Same as above, but for WebFrame::loadHTMLString(). |
68 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL); | 69 void loadHTMLString(WebFrame*, const std::string& html, const WebURL& baseURL); |
69 // Same as above, but for WebFrame::loadHistoryItem(). | 70 // Same as above, but for WebFrame::loadHistoryItem(). |
70 void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebCa
chePolicy); | 71 void loadHistoryItem(WebFrame*, const WebHistoryItem&, WebHistoryLoadType, WebCa
chePolicy); |
71 // Same as above, but for WebFrame::reload(). | 72 // Same as above, but for WebFrame::reload(). |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 public: | 121 public: |
121 TestWebViewClient() : m_animationScheduled(false) { } | 122 TestWebViewClient() : m_animationScheduled(false) { } |
122 virtual ~TestWebViewClient() { } | 123 virtual ~TestWebViewClient() { } |
123 void initializeLayerTreeView() override; | 124 void initializeLayerTreeView() override; |
124 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); } | 125 WebLayerTreeView* layerTreeView() override { return m_layerTreeView.get(); } |
125 | 126 |
126 void scheduleAnimation() override { m_animationScheduled = true; } | 127 void scheduleAnimation() override { m_animationScheduled = true; } |
127 bool animationScheduled() { return m_animationScheduled; } | 128 bool animationScheduled() { return m_animationScheduled; } |
128 void clearAnimationScheduled() { m_animationScheduled = false; } | 129 void clearAnimationScheduled() { m_animationScheduled = false; } |
129 | 130 |
| 131 // TODO(lfg): This is a temporary method to retrieve the WebWidgetClient, |
| 132 // while we refactor WebView to not inherit from Webwidget. |
| 133 // Returns the WebWidgetClient. |
| 134 WebWidgetClient* widgetClient() { return this; } |
| 135 |
130 private: | 136 private: |
131 OwnPtr<WebLayerTreeView> m_layerTreeView; | 137 OwnPtr<WebLayerTreeView> m_layerTreeView; |
132 bool m_animationScheduled; | 138 bool m_animationScheduled; |
133 }; | 139 }; |
134 | 140 |
135 // Convenience class for handling the lifetime of a WebView and its associated m
ainframe in tests. | 141 // Convenience class for handling the lifetime of a WebView and its associated m
ainframe in tests. |
136 class WebViewHelper { | 142 class WebViewHelper { |
137 WTF_MAKE_NONCOPYABLE(WebViewHelper); | 143 WTF_MAKE_NONCOPYABLE(WebViewHelper); |
138 public: | 144 public: |
139 WebViewHelper(SettingOverrider* = 0); | 145 WebViewHelper(SettingOverrider* = 0); |
140 ~WebViewHelper(); | 146 ~WebViewHelper(); |
141 | 147 |
142 // Creates and initializes the WebView. Implicitly calls reset() first. If | 148 // Creates and initializes the WebView. Implicitly calls reset() first. If |
143 // a WebFrameClient or a WebViewClient are passed in, they must outlive the | 149 // a WebFrameClient or a WebViewClient are passed in, they must outlive the |
144 // WebViewHelper. | 150 // WebViewHelper. |
145 WebViewImpl* initializeWithOpener(WebFrame* opener, bool enableJavascript =
false, TestWebFrameClient* = nullptr, TestWebViewClient* = nullptr, void (*updat
eSettingsFunc)(WebSettings*) = nullptr); | 151 WebViewImpl* initializeWithOpener(WebFrame* opener, bool enableJavascript =
false, TestWebFrameClient* = nullptr, TestWebViewClient* = nullptr, TestWebWidge
tClient* = nullptr, void (*updateSettingsFunc)(WebSettings*) = nullptr); |
146 | 152 |
147 // Same as initializeWithOpener(), but always sets the opener to null. | 153 // Same as initializeWithOpener(), but always sets the opener to null. |
148 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* =
0, TestWebViewClient* = 0, void (*updateSettingsFunc)(WebSettings*) = 0); | 154 WebViewImpl* initialize(bool enableJavascript = false, TestWebFrameClient* =
nullptr, TestWebViewClient* = nullptr, TestWebWidgetClient* = nullptr, void (*u
pdateSettingsFunc)(WebSettings*) = 0); |
149 | 155 |
150 // Same as initialize() but also performs the initial load of the url. Only | 156 // Same as initialize() but also performs the initial load of the url. Only |
151 // returns once the load is complete. | 157 // returns once the load is complete. |
152 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript
= false, TestWebFrameClient* = 0, TestWebViewClient* = 0, void (*updateSettings
Func)(WebSettings*) = 0); | 158 WebViewImpl* initializeAndLoad(const std::string& url, bool enableJavascript
= false, TestWebFrameClient* = nullptr, TestWebViewClient* = nullptr, TestWebWi
dgetClient* = nullptr, void (*updateSettingsFunc)(WebSettings*) = 0); |
153 | 159 |
154 void resize(WebSize); | 160 void resize(WebSize); |
155 | 161 |
156 void reset(); | 162 void reset(); |
157 | 163 |
158 WebView* webView() const { return m_webView; } | 164 WebView* webView() const { return m_webView; } |
159 WebViewImpl* webViewImpl() const { return m_webView; } | 165 WebViewImpl* webViewImpl() const { return m_webView; } |
160 | 166 |
161 private: | 167 private: |
162 WebViewImpl* m_webView; | 168 WebViewImpl* m_webView; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 WebDOMMessageEvent) override { } | 206 WebDOMMessageEvent) override { } |
201 | 207 |
202 private: | 208 private: |
203 Persistent<WebRemoteFrameImpl> const m_frame; | 209 Persistent<WebRemoteFrameImpl> const m_frame; |
204 }; | 210 }; |
205 | 211 |
206 } // namespace FrameTestHelpers | 212 } // namespace FrameTestHelpers |
207 } // namespace blink | 213 } // namespace blink |
208 | 214 |
209 #endif // FrameTestHelpers_h | 215 #endif // FrameTestHelpers_h |
OLD | NEW |