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 COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 6 #define COMPONENTS_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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "content/shell/renderer/test_runner/web_task.h" | 15 #include "components/test_runner/web_task.h" |
16 #include "third_party/WebKit/public/platform/WebImage.h" | 16 #include "third_party/WebKit/public/platform/WebImage.h" |
17 #include "third_party/WebKit/public/platform/WebRect.h" | 17 #include "third_party/WebKit/public/platform/WebRect.h" |
18 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 18 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
19 #include "third_party/WebKit/public/platform/WebURLError.h" | 19 #include "third_party/WebKit/public/platform/WebURLError.h" |
20 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 20 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
21 #include "third_party/WebKit/public/web/WebAXEnums.h" | 21 #include "third_party/WebKit/public/web/WebAXEnums.h" |
22 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 22 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
23 #include "third_party/WebKit/public/web/WebDataSource.h" | 23 #include "third_party/WebKit/public/web/WebDataSource.h" |
24 #include "third_party/WebKit/public/web/WebDragOperation.h" | 24 #include "third_party/WebKit/public/web/WebDragOperation.h" |
25 #include "third_party/WebKit/public/web/WebFrame.h" | 25 #include "third_party/WebKit/public/web/WebFrame.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // WebTestProxyBase, that means that there is no logic living in this class | 283 // WebTestProxyBase, that means that there is no logic living in this class |
284 // except deciding which base class should be called (could be both). | 284 // except deciding which base class should be called (could be both). |
285 // | 285 // |
286 // Examples of usage: | 286 // Examples of usage: |
287 // * when a fooClient has a mock implementation, WebTestProxy can override the | 287 // * when a fooClient has a mock implementation, WebTestProxy can override the |
288 // fooClient() call and have WebTestProxyBase return the mock implementation. | 288 // fooClient() call and have WebTestProxyBase return the mock implementation. |
289 // * when a value needs to be overridden by LayoutTests, WebTestProxy can | 289 // * when a value needs to be overridden by LayoutTests, WebTestProxy can |
290 // override RenderViewImpl's getter and call a getter from WebTestProxyBase | 290 // override RenderViewImpl's getter and call a getter from WebTestProxyBase |
291 // instead. In addition, WebTestProxyBase will have a public setter that | 291 // instead. In addition, WebTestProxyBase will have a public setter that |
292 // could be called from the TestRunner. | 292 // could be called from the TestRunner. |
| 293 #if defined(OS_WIN) |
| 294 // WebTestProxy is a diamond-shaped hierarchy, with WebWidgetClient at the root. |
| 295 // VS warns when we inherit the WebWidgetClient method implementations from |
| 296 // RenderWidget. It's safe to ignore that warning. |
| 297 #pragma warning(disable: 4250) |
| 298 #endif |
293 template <class Base, typename T> | 299 template <class Base, typename T> |
294 class WebTestProxy : public Base, public WebTestProxyBase { | 300 class WebTestProxy : public Base, public WebTestProxyBase { |
295 public: | 301 public: |
296 explicit WebTestProxy(T t) : Base(t) {} | 302 explicit WebTestProxy(T t) : Base(t) {} |
297 | 303 |
298 // WebWidgetClient implementation. | 304 // WebWidgetClient implementation. |
299 virtual blink::WebScreenInfo screenInfo() { | 305 virtual blink::WebScreenInfo screenInfo() { |
300 blink::WebScreenInfo info = Base::screenInfo(); | 306 blink::WebScreenInfo info = Base::screenInfo(); |
301 WebTestProxyBase::GetScreenOrientationForTesting(info); | 307 WebTestProxyBase::GetScreenOrientationForTesting(info); |
302 return info; | 308 return info; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return WebTestProxyBase::RunFileChooser(params, completion); | 376 return WebTestProxyBase::RunFileChooser(params, completion); |
371 } | 377 } |
372 virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view, | 378 virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view, |
373 const blink::WebString& main_message, | 379 const blink::WebString& main_message, |
374 blink::WebTextDirection main_message_hint, | 380 blink::WebTextDirection main_message_hint, |
375 const blink::WebString& sub_message, | 381 const blink::WebString& sub_message, |
376 blink::WebTextDirection sub_message_hint) { | 382 blink::WebTextDirection sub_message_hint) { |
377 base::string16 wrapped_main_text = main_message; | 383 base::string16 wrapped_main_text = main_message; |
378 base::string16 wrapped_sub_text = sub_message; | 384 base::string16 wrapped_sub_text = sub_message; |
379 | 385 |
380 Base::SetValidationMessageDirection( | 386 Base::SetValidationMessageDirection(&wrapped_main_text, main_message_hint, |
381 &wrapped_main_text, main_message_hint, &wrapped_sub_text, sub_message_hi
nt); | 387 &wrapped_sub_text, sub_message_hint); |
382 | 388 |
383 WebTestProxyBase::ShowValidationMessage( | 389 WebTestProxyBase::ShowValidationMessage( |
384 wrapped_main_text, wrapped_sub_text); | 390 wrapped_main_text, wrapped_sub_text); |
385 } | 391 } |
386 virtual void postSpellCheckEvent(const blink::WebString& event_name) { | 392 virtual void postSpellCheckEvent(const blink::WebString& event_name) { |
387 WebTestProxyBase::PostSpellCheckEvent(event_name); | 393 WebTestProxyBase::PostSpellCheckEvent(event_name); |
388 } | 394 } |
389 virtual blink::WebString acceptLanguages() { | 395 virtual blink::WebString acceptLanguages() { |
390 return WebTestProxyBase::acceptLanguages(); | 396 return WebTestProxyBase::acceptLanguages(); |
391 } | 397 } |
392 | 398 |
393 private: | 399 private: |
394 virtual ~WebTestProxy() {} | 400 virtual ~WebTestProxy() {} |
395 | 401 |
396 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); | 402 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); |
397 }; | 403 }; |
398 | 404 |
399 } // namespace content | 405 } // namespace content |
400 | 406 |
401 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 407 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ |
OLD | NEW |