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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 namespace content { | 75 namespace content { |
76 | 76 |
77 class MockWebSpeechRecognizer; | 77 class MockWebSpeechRecognizer; |
78 class RenderFrame; | 78 class RenderFrame; |
79 class SpellCheckClient; | 79 class SpellCheckClient; |
80 class TestInterfaces; | 80 class TestInterfaces; |
81 class WebTestDelegate; | 81 class WebTestDelegate; |
82 class WebTestInterfaces; | 82 class WebTestInterfaces; |
83 class WebUserMediaClientMock; | 83 class WebUserMediaClientMock; |
84 | 84 |
| 85 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that |
| 86 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and |
| 87 // when it requires a behavior to be different from the usual, it will call |
| 88 // WebTestProxyBase that implements the expected behavior. |
| 89 // See WebTestProxy class comments for more information. |
85 class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { | 90 class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { |
86 public: | 91 public: |
87 void SetInterfaces(WebTestInterfaces* interfaces); | 92 void SetInterfaces(WebTestInterfaces* interfaces); |
88 void SetDelegate(WebTestDelegate* delegate); | 93 void SetDelegate(WebTestDelegate* delegate); |
89 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; } | 94 void set_widget(blink::WebWidget* widget) { web_widget_ = widget; } |
90 | 95 |
91 void Reset(); | 96 void Reset(); |
92 | 97 |
93 blink::WebSpellCheckClient* GetSpellCheckClient() const; | 98 blink::WebSpellCheckClient* GetSpellCheckClient() const; |
94 blink::WebColorChooser* CreateColorChooser( | 99 blink::WebColorChooser* CreateColorChooser( |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 244 |
240 scoped_ptr<blink::WebMIDIClientMock> m_midiClient; | 245 scoped_ptr<blink::WebMIDIClientMock> m_midiClient; |
241 scoped_ptr<MockWebSpeechRecognizer> m_speechRecognizer; | 246 scoped_ptr<MockWebSpeechRecognizer> m_speechRecognizer; |
242 | 247 |
243 std::string accept_languages_; | 248 std::string accept_languages_; |
244 | 249 |
245 private: | 250 private: |
246 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); | 251 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); |
247 }; | 252 }; |
248 | 253 |
249 // Use this template to inject methods into your WebViewClient/WebFrameClient | 254 // WebTestProxy is used during LayoutTests and always instantiated, at time of |
250 // implementation required for the running layout tests. | 255 // writing with Base=RenderViewImpl. It does not directly inherit from it for |
| 256 // layering purposes. |
| 257 // The intent of that class is to wrap RenderViewImpl for tests purposes in |
| 258 // order to reduce the amount of test specific code in the production code. |
| 259 // WebTestProxy is only doing the glue between RenderViewImpl and |
| 260 // WebTestProxyBase, that means that there is no logic living in this class |
| 261 // except deciding which base class should be called (could be both). |
| 262 // |
| 263 // Examples of usage: |
| 264 // * when a fooClient has a mock implementation, WebTestProxy can override the |
| 265 // fooClient() call and have WebTestProxyBase return the mock implementation. |
| 266 // * when a value needs to be overridden by LayoutTests, WebTestProxy can |
| 267 // override RenderViewImpl's getter and call a getter from WebTestProxyBase |
| 268 // instead. In addition, WebTestProxyBase will have a public setter that |
| 269 // could be called from the TestRunner. |
251 template <class Base, typename T> | 270 template <class Base, typename T> |
252 class WebTestProxy : public Base, public WebTestProxyBase { | 271 class WebTestProxy : public Base, public WebTestProxyBase { |
253 public: | 272 public: |
254 explicit WebTestProxy(T t) : Base(t) {} | 273 explicit WebTestProxy(T t) : Base(t) {} |
255 | 274 |
256 virtual ~WebTestProxy() {} | 275 virtual ~WebTestProxy() {} |
257 | 276 |
258 // WebViewClient implementation. | 277 // WebViewClient implementation. |
259 virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); } | 278 virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); } |
260 virtual void postAccessibilityEvent(const blink::WebAXObject& object, | 279 virtual void postAccessibilityEvent(const blink::WebAXObject& object, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return WebTestProxy::acceptLanguages(); | 367 return WebTestProxy::acceptLanguages(); |
349 } | 368 } |
350 | 369 |
351 private: | 370 private: |
352 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); | 371 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); |
353 }; | 372 }; |
354 | 373 |
355 } // namespace content | 374 } // namespace content |
356 | 375 |
357 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ | 376 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_PROXY_H_ |
OLD | NEW |