| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 5 #ifndef COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 
| 6 #define COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 6 #define COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 
| 7 | 7 | 
| 8 #include <memory> | 8 #include <memory> | 
| 9 | 9 | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 #include "components/test_runner/test_runner_export.h" | 12 #include "components/test_runner/test_runner_export.h" | 
| 13 #include "components/test_runner/web_widget_test_client.h" | 13 #include "components/test_runner/web_widget_test_client.h" | 
| 14 #include "third_party/WebKit/public/web/WebWidgetClient.h" | 14 #include "third_party/WebKit/public/web/WebWidgetClient.h" | 
| 15 | 15 | 
| 16 namespace blink { | 16 namespace blink { | 
|  | 17 class WebLocalFrame; | 
| 17 class WebString; | 18 class WebString; | 
| 18 class WebWidget; | 19 class WebWidget; | 
| 19 } | 20 } | 
| 20 | 21 | 
| 21 namespace test_runner { | 22 namespace test_runner { | 
| 22 | 23 | 
|  | 24 class EventSender; | 
|  | 25 class WebViewTestProxyBase; | 
|  | 26 | 
| 23 class TEST_RUNNER_EXPORT WebWidgetTestProxyBase { | 27 class TEST_RUNNER_EXPORT WebWidgetTestProxyBase { | 
| 24  public: | 28  public: | 
| 25   blink::WebWidget* web_widget() { return web_widget_; } | 29   blink::WebWidget* web_widget() { return web_widget_; } | 
| 26   void set_web_widget(blink::WebWidget* widget) { | 30   void set_web_widget(blink::WebWidget* widget) { | 
| 27     DCHECK(widget); | 31     DCHECK(widget); | 
| 28     DCHECK(!web_widget_); | 32     DCHECK(!web_widget_); | 
| 29     web_widget_ = widget; | 33     web_widget_ = widget; | 
| 30   } | 34   } | 
| 31 | 35 | 
| 32   void set_widget_test_client( | 36   void set_widget_test_client( | 
| 33       std::unique_ptr<WebWidgetTestClient> widget_test_client) { | 37       std::unique_ptr<WebWidgetTestClient> widget_test_client) { | 
| 34     DCHECK(widget_test_client); | 38     DCHECK(widget_test_client); | 
| 35     DCHECK(!widget_test_client_); | 39     DCHECK(!widget_test_client_); | 
| 36     widget_test_client_ = std::move(widget_test_client); | 40     widget_test_client_ = std::move(widget_test_client); | 
| 37   } | 41   } | 
| 38 | 42 | 
|  | 43   WebViewTestProxyBase* web_view_test_proxy_base() const { | 
|  | 44     return web_view_test_proxy_base_; | 
|  | 45   } | 
|  | 46   void set_web_view_test_proxy_base( | 
|  | 47       WebViewTestProxyBase* web_view_test_proxy_base) { | 
|  | 48     DCHECK(web_view_test_proxy_base); | 
|  | 49     DCHECK(!web_view_test_proxy_base_); | 
|  | 50     web_view_test_proxy_base_ = web_view_test_proxy_base; | 
|  | 51   } | 
|  | 52 | 
|  | 53   EventSender* event_sender() { return event_sender_.get(); } | 
|  | 54 | 
|  | 55   void Reset(); | 
|  | 56   void BindTo(blink::WebLocalFrame* frame); | 
|  | 57 | 
| 39  protected: | 58  protected: | 
| 40   WebWidgetTestProxyBase(); | 59   WebWidgetTestProxyBase(); | 
| 41   ~WebWidgetTestProxyBase(); | 60   ~WebWidgetTestProxyBase(); | 
| 42 | 61 | 
| 43   blink::WebWidgetClient* widget_test_client() { | 62   blink::WebWidgetClient* widget_test_client() { | 
| 44     return widget_test_client_.get(); | 63     return widget_test_client_.get(); | 
| 45   } | 64   } | 
| 46 | 65 | 
| 47  private: | 66  private: | 
| 48   blink::WebWidget* web_widget_; | 67   blink::WebWidget* web_widget_; | 
|  | 68   WebViewTestProxyBase* web_view_test_proxy_base_; | 
| 49   std::unique_ptr<WebWidgetTestClient> widget_test_client_; | 69   std::unique_ptr<WebWidgetTestClient> widget_test_client_; | 
|  | 70   std::unique_ptr<EventSender> event_sender_; | 
| 50 | 71 | 
| 51   DISALLOW_COPY_AND_ASSIGN(WebWidgetTestProxyBase); | 72   DISALLOW_COPY_AND_ASSIGN(WebWidgetTestProxyBase); | 
| 52 }; | 73 }; | 
| 53 | 74 | 
| 54 // WebWidgetTestProxy is used during LayoutTests and always instantiated, at | 75 // WebWidgetTestProxy is used during LayoutTests and always instantiated, at | 
| 55 // time of writing with Base=RenderWidget. It does not directly inherit from it | 76 // time of writing with Base=RenderWidget. It does not directly inherit from it | 
| 56 // for layering purposes. | 77 // for layering purposes. | 
| 57 // The intent of that class is to wrap RenderWidget for tests purposes in | 78 // The intent of that class is to wrap RenderWidget for tests purposes in | 
| 58 // order to reduce the amount of test specific code in the production code. | 79 // order to reduce the amount of test specific code in the production code. | 
| 59 // WebWidgetTestProxy is only doing the glue between RenderWidget and | 80 // WebWidgetTestProxy is only doing the glue between RenderWidget and | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 105 | 126 | 
| 106  private: | 127  private: | 
| 107   virtual ~WebWidgetTestProxy() {} | 128   virtual ~WebWidgetTestProxy() {} | 
| 108 | 129 | 
| 109   DISALLOW_COPY_AND_ASSIGN(WebWidgetTestProxy); | 130   DISALLOW_COPY_AND_ASSIGN(WebWidgetTestProxy); | 
| 110 }; | 131 }; | 
| 111 | 132 | 
| 112 }  // namespace test_runner | 133 }  // namespace test_runner | 
| 113 | 134 | 
| 114 #endif  // COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 135 #endif  // COMPONENTS_TEST_RUNNER_WEB_WIDGET_TEST_PROXY_H_ | 
| OLD | NEW | 
|---|