OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void MoveValidationMessage(const blink::WebRect& anchorInRootView); | 104 void MoveValidationMessage(const blink::WebRect& anchorInRootView); |
105 | 105 |
106 std::string CaptureTree(bool debugRenderTree); | 106 std::string CaptureTree(bool debugRenderTree); |
107 void CapturePixelsForPrinting( | 107 void CapturePixelsForPrinting( |
108 const base::Callback<void(const SkBitmap&)>& callback); | 108 const base::Callback<void(const SkBitmap&)>& callback); |
109 void CapturePixelsAsync( | 109 void CapturePixelsAsync( |
110 const base::Callback<void(const SkBitmap&)>& callback); | 110 const base::Callback<void(const SkBitmap&)>& callback); |
111 | 111 |
112 void SetLogConsoleOutput(bool enabled); | 112 void SetLogConsoleOutput(bool enabled); |
113 | 113 |
114 // FIXME: Make this private again. | |
115 void ScheduleComposite(); | |
116 | |
117 void DidOpenChooser(); | 114 void DidOpenChooser(); |
118 void DidCloseChooser(); | 115 void DidCloseChooser(); |
119 bool IsChooserShown(); | 116 bool IsChooserShown(); |
120 | 117 |
121 void DisplayAsyncThen(const base::Closure& callback); | 118 void DisplayAsyncThen(const base::Closure& callback); |
122 | 119 |
123 void DiscardBackingStore(); | |
124 | |
125 blink::WebMIDIClientMock* GetMIDIClientMock(); | 120 blink::WebMIDIClientMock* GetMIDIClientMock(); |
126 MockWebSpeechRecognizer* GetSpeechRecognizerMock(); | 121 MockWebSpeechRecognizer* GetSpeechRecognizerMock(); |
127 | 122 |
128 WebTaskList* mutable_task_list() { return &task_list_; } | 123 WebTaskList* mutable_task_list() { return &task_list_; } |
129 | 124 |
130 blink::WebView* GetWebView() const; | 125 blink::WebView* GetWebView() const; |
131 | 126 |
132 void DidForceResize(); | |
133 | |
134 void PostSpellCheckEvent(const blink::WebString& eventName); | 127 void PostSpellCheckEvent(const blink::WebString& eventName); |
135 | 128 |
136 // WebCompositeAndReadbackAsyncCallback implementation. | 129 // WebCompositeAndReadbackAsyncCallback implementation. |
137 virtual void didCompositeAndReadback(const SkBitmap& bitmap); | 130 virtual void didCompositeAndReadback(const SkBitmap& bitmap); |
138 | 131 |
139 protected: | 132 protected: |
140 WebTestProxyBase(); | 133 WebTestProxyBase(); |
141 ~WebTestProxyBase(); | 134 ~WebTestProxyBase(); |
142 | 135 |
143 void DidInvalidateRect(const blink::WebRect&); | |
144 void DidScrollRect(int, int, const blink::WebRect&); | |
145 void ScheduleAnimation(); | 136 void ScheduleAnimation(); |
146 bool IsCompositorFramePending() const; | |
147 // FIXME: Remove once we switch to use didForceResize. | |
148 void SetWindowRect(const blink::WebRect&); | |
149 void Show(blink::WebNavigationPolicy); | |
150 void DidAutoResize(const blink::WebSize&); | |
151 void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent); | 137 void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent); |
152 void StartDragging(blink::WebLocalFrame*, const blink::WebDragData&, | 138 void StartDragging(blink::WebLocalFrame*, const blink::WebDragData&, |
153 blink::WebDragOperationsMask, const blink::WebImage&, | 139 blink::WebDragOperationsMask, const blink::WebImage&, |
154 const blink::WebPoint&); | 140 const blink::WebPoint&); |
155 void DidChangeSelection(bool isEmptySelection); | 141 void DidChangeSelection(bool isEmptySelection); |
156 void DidChangeContents(); | 142 void DidChangeContents(); |
157 void DidEndEditing(); | 143 void DidEndEditing(); |
158 bool CreateView(blink::WebLocalFrame* creator, const blink::WebURLRequest&, | 144 bool CreateView(blink::WebLocalFrame* creator, const blink::WebURLRequest&, |
159 const blink::WebWindowFeatures&, | 145 const blink::WebWindowFeatures&, |
160 const blink::WebString& frameName, blink::WebNavigationPolicy, | 146 const blink::WebString& frameName, blink::WebNavigationPolicy, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 bool WillCheckAndDispatchMessageEvent(blink::WebLocalFrame* sourceFrame, | 203 bool WillCheckAndDispatchMessageEvent(blink::WebLocalFrame* sourceFrame, |
218 blink::WebFrame* targetFrame, | 204 blink::WebFrame* targetFrame, |
219 blink::WebSecurityOrigin target, | 205 blink::WebSecurityOrigin target, |
220 blink::WebDOMMessageEvent); | 206 blink::WebDOMMessageEvent); |
221 void ResetInputMethod(); | 207 void ResetInputMethod(); |
222 | 208 |
223 private: | 209 private: |
224 template <class, typename, typename> | 210 template <class, typename, typename> |
225 friend class WebFrameTestProxy; | 211 friend class WebFrameTestProxy; |
226 void LocationChangeDone(blink::WebFrame*); | 212 void LocationChangeDone(blink::WebFrame*); |
227 void PaintPagesWithBoundaries(); | |
228 SkCanvas* GetCanvas(); | |
229 void InvalidateAll(); | |
230 void AnimateNow(); | 213 void AnimateNow(); |
231 void DrawSelectionRect(SkCanvas* canvas); | 214 void DrawSelectionRect(SkCanvas* canvas); |
232 void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap); | 215 void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap); |
233 | 216 |
234 blink::WebWidget* web_widget() const { return web_widget_; } | 217 blink::WebWidget* web_widget() const { return web_widget_; } |
235 | 218 |
236 TestInterfaces* test_interfaces_; | 219 TestInterfaces* test_interfaces_; |
237 WebTestDelegate* delegate_; | 220 WebTestDelegate* delegate_; |
238 blink::WebWidget* web_widget_; | 221 blink::WebWidget* web_widget_; |
239 | 222 |
240 WebTaskList task_list_; | 223 WebTaskList task_list_; |
241 | 224 |
242 scoped_ptr<SpellCheckClient> spellcheck_; | 225 scoped_ptr<SpellCheckClient> spellcheck_; |
243 scoped_ptr<WebUserMediaClientMock> user_media_client_; | 226 scoped_ptr<WebUserMediaClientMock> user_media_client_; |
244 | 227 |
245 // Painting. | |
246 scoped_ptr<SkCanvas> canvas_; | |
247 blink::WebRect paint_rect_; | |
248 bool is_painting_; | |
249 bool animate_scheduled_; | 228 bool animate_scheduled_; |
250 std::map<unsigned, std::string> resource_identifier_map_; | 229 std::map<unsigned, std::string> resource_identifier_map_; |
251 std::deque<base::Callback<void(const SkBitmap&)> > | 230 std::deque<base::Callback<void(const SkBitmap&)> > |
252 composite_and_readback_callbacks_; | 231 composite_and_readback_callbacks_; |
253 | 232 |
254 bool log_console_output_; | 233 bool log_console_output_; |
255 int chooser_count_; | 234 int chooser_count_; |
256 | 235 |
257 scoped_ptr<blink::WebMIDIClientMock> m_midiClient; | 236 scoped_ptr<blink::WebMIDIClientMock> m_midiClient; |
258 scoped_ptr<MockWebSpeechRecognizer> m_speechRecognizer; | 237 scoped_ptr<MockWebSpeechRecognizer> m_speechRecognizer; |
259 | 238 |
260 private: | 239 private: |
261 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); | 240 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); |
262 }; | 241 }; |
263 | 242 |
264 // Use this template to inject methods into your WebViewClient/WebFrameClient | 243 // Use this template to inject methods into your WebViewClient/WebFrameClient |
265 // implementation required for the running layout tests. | 244 // implementation required for the running layout tests. |
266 template <class Base, typename T> | 245 template <class Base, typename T> |
267 class WebTestProxy : public Base, public WebTestProxyBase { | 246 class WebTestProxy : public Base, public WebTestProxyBase { |
268 public: | 247 public: |
269 explicit WebTestProxy(T t) : Base(t) {} | 248 explicit WebTestProxy(T t) : Base(t) {} |
270 | 249 |
271 virtual ~WebTestProxy() {} | 250 virtual ~WebTestProxy() {} |
272 | 251 |
273 // WebViewClient implementation. | 252 // WebViewClient implementation. |
274 virtual void didInvalidateRect(const blink::WebRect& rect) { | |
275 WebTestProxyBase::DidInvalidateRect(rect); | |
276 } | |
277 virtual void didScrollRect(int dx, int dy, const blink::WebRect& clipRect) { | |
278 WebTestProxyBase::DidScrollRect(dx, dy, clipRect); | |
279 } | |
280 virtual void scheduleComposite() { WebTestProxyBase::ScheduleComposite(); } | |
281 virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); } | 253 virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); } |
282 virtual bool isCompositorFramePending() const { | |
283 return WebTestProxyBase::IsCompositorFramePending(); | |
284 } | |
285 virtual void setWindowRect(const blink::WebRect& rect) { | |
286 WebTestProxyBase::SetWindowRect(rect); | |
287 Base::setWindowRect(rect); | |
288 } | |
289 virtual void show(blink::WebNavigationPolicy policy) { | |
290 WebTestProxyBase::Show(policy); | |
291 Base::show(policy); | |
292 } | |
293 virtual void didAutoResize(const blink::WebSize& newSize) { | |
294 WebTestProxyBase::DidAutoResize(newSize); | |
295 Base::didAutoResize(newSize); | |
296 } | |
297 virtual void postAccessibilityEvent(const blink::WebAXObject& object, | 254 virtual void postAccessibilityEvent(const blink::WebAXObject& object, |
298 blink::WebAXEvent event) { | 255 blink::WebAXEvent event) { |
299 WebTestProxyBase::PostAccessibilityEvent(object, event); | 256 WebTestProxyBase::PostAccessibilityEvent(object, event); |
300 Base::postAccessibilityEvent(object, event); | 257 Base::postAccessibilityEvent(object, event); |
301 } | 258 } |
302 virtual void startDragging(blink::WebLocalFrame* frame, | 259 virtual void startDragging(blink::WebLocalFrame* frame, |
303 const blink::WebDragData& data, | 260 const blink::WebDragData& data, |
304 blink::WebDragOperationsMask mask, | 261 blink::WebDragOperationsMask mask, |
305 const blink::WebImage& image, | 262 const blink::WebImage& image, |
306 const blink::WebPoint& point) { | 263 const blink::WebPoint& point) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 WebTestProxyBase::PostSpellCheckEvent(eventName); | 339 WebTestProxyBase::PostSpellCheckEvent(eventName); |
383 } | 340 } |
384 | 341 |
385 private: | 342 private: |
386 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); | 343 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); |
387 }; | 344 }; |
388 | 345 |
389 } // namespace content | 346 } // namespace content |
390 | 347 |
391 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 348 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ |
OLD | NEW |