Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: components/test_runner/web_view_test_proxy.h

Issue 2171503005: Rename WebTestProxy to WebViewTestProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 5 #ifndef COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
6 #define COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 6 #define COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace test_runner { 43 namespace test_runner {
44 44
45 class AccessibilityController; 45 class AccessibilityController;
46 class EventSender; 46 class EventSender;
47 class TestInterfaces; 47 class TestInterfaces;
48 class TestRunnerForSpecificView; 48 class TestRunnerForSpecificView;
49 class TextInputController; 49 class TextInputController;
50 class WebTestDelegate; 50 class WebTestDelegate;
51 class WebTestInterfaces; 51 class WebTestInterfaces;
52 52
53 // WebTestProxyBase is the "brain" of WebTestProxy in the sense that 53 // WebViewTestProxyBase is the "brain" of WebViewTestProxy in the sense that
54 // WebTestProxy does the bridge between RenderViewImpl and WebTestProxyBase and 54 // WebViewTestProxy does the bridge between RenderViewImpl and
55 // when it requires a behavior to be different from the usual, it will call 55 // WebViewTestProxyBase and when it requires a behavior to be different from the
56 // WebTestProxyBase that implements the expected behavior. 56 // usual, it will call WebViewTestProxyBase that implements the expected
57 // See WebTestProxy class comments for more information. 57 // behavior. See WebViewTestProxy class comments for more information.
Łukasz Anforowicz 2016/07/21 19:14:50 This comment is not accurate (after my earlier CLs
lfg 2016/07/22 04:24:50 I see. Let's revisit this when I get WebWidgetTest
58 class TEST_RUNNER_EXPORT WebTestProxyBase { 58 class TEST_RUNNER_EXPORT WebViewTestProxyBase {
59 public: 59 public:
60 blink::WebWidget* web_widget() { return web_widget_; } 60 blink::WebWidget* web_widget() { return web_widget_; }
61 void set_web_widget(blink::WebWidget* widget) { 61 void set_web_widget(blink::WebWidget* widget) {
62 DCHECK(widget); 62 DCHECK(widget);
63 DCHECK(!web_widget_); 63 DCHECK(!web_widget_);
64 web_widget_ = widget; 64 web_widget_ = widget;
65 } 65 }
66 66
67 blink::WebView* web_view() { return web_view_; } 67 blink::WebView* web_view() { return web_view_; }
68 void set_web_view(blink::WebView* view) { 68 void set_web_view(blink::WebView* view) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 TestRunnerForSpecificView* view_test_runner() { 104 TestRunnerForSpecificView* view_test_runner() {
105 return view_test_runner_.get(); 105 return view_test_runner_.get();
106 } 106 }
107 107
108 void Reset(); 108 void Reset();
109 void BindTo(blink::WebLocalFrame* frame); 109 void BindTo(blink::WebLocalFrame* frame);
110 110
111 void GetScreenOrientationForTesting(blink::WebScreenInfo&); 111 void GetScreenOrientationForTesting(blink::WebScreenInfo&);
112 112
113 protected: 113 protected:
114 WebTestProxyBase(); 114 WebViewTestProxyBase();
115 ~WebTestProxyBase(); 115 ~WebViewTestProxyBase();
116 116
117 blink::WebViewClient* view_test_client() { return view_test_client_.get(); } 117 blink::WebViewClient* view_test_client() { return view_test_client_.get(); }
118 blink::WebWidgetClient* widget_test_client() { 118 blink::WebWidgetClient* widget_test_client() {
119 return widget_test_client_.get(); 119 return widget_test_client_.get();
120 } 120 }
121 121
122 private: 122 private:
123 TestInterfaces* test_interfaces_; 123 TestInterfaces* test_interfaces_;
124 WebTestDelegate* delegate_; 124 WebTestDelegate* delegate_;
125 blink::WebView* web_view_; 125 blink::WebView* web_view_;
126 blink::WebWidget* web_widget_; 126 blink::WebWidget* web_widget_;
127 std::unique_ptr<WebViewTestClient> view_test_client_; 127 std::unique_ptr<WebViewTestClient> view_test_client_;
128 std::unique_ptr<WebWidgetTestClient> widget_test_client_; 128 std::unique_ptr<WebWidgetTestClient> widget_test_client_;
129 std::unique_ptr<AccessibilityController> accessibility_controller_; 129 std::unique_ptr<AccessibilityController> accessibility_controller_;
130 std::unique_ptr<EventSender> event_sender_; 130 std::unique_ptr<EventSender> event_sender_;
131 std::unique_ptr<TextInputController> text_input_controller_; 131 std::unique_ptr<TextInputController> text_input_controller_;
132 std::unique_ptr<TestRunnerForSpecificView> view_test_runner_; 132 std::unique_ptr<TestRunnerForSpecificView> view_test_runner_;
133 133
134 DISALLOW_COPY_AND_ASSIGN(WebTestProxyBase); 134 DISALLOW_COPY_AND_ASSIGN(WebViewTestProxyBase);
135 }; 135 };
136 136
137 // WebTestProxy is used during LayoutTests and always instantiated, at time of 137 // WebViewTestProxy is used during LayoutTests and always instantiated, at time
138 // writing with Base=RenderViewImpl. It does not directly inherit from it for 138 // of writing with Base=RenderViewImpl. It does not directly inherit from it for
139 // layering purposes. 139 // layering purposes.
140 // The intent of that class is to wrap RenderViewImpl for tests purposes in 140 // The intent of that class is to wrap RenderViewImpl for tests purposes in
141 // order to reduce the amount of test specific code in the production code. 141 // order to reduce the amount of test specific code in the production code.
142 // WebTestProxy is only doing the glue between RenderViewImpl and 142 // WebViewTestProxy is only doing the glue between RenderViewImpl and
143 // WebTestProxyBase, that means that there is no logic living in this class 143 // WebViewTestProxyBase, that means that there is no logic living in this class
144 // except deciding which base class should be called (could be both). 144 // except deciding which base class should be called (could be both).
145 // 145 //
146 // Examples of usage: 146 // Examples of usage:
147 // * when a fooClient has a mock implementation, WebTestProxy can override the 147 // * when a fooClient has a mock implementation, WebViewTestProxy can override
148 // fooClient() call and have WebTestProxyBase return the mock implementation. 148 // the fooClient() call and have WebViewTestProxyBase return the mock
149 // * when a value needs to be overridden by LayoutTests, WebTestProxy can 149 // implementation.
150 // override RenderViewImpl's getter and call a getter from WebTestProxyBase 150 // * when a value needs to be overridden by LayoutTests, WebViewTestProxy can
151 // instead. In addition, WebTestProxyBase will have a public setter that 151 // override RenderViewImpl's getter and call a getter from
152 // could be called from the TestRunner. 152 // WebViewTestProxyBase instead. In addition, WebViewTestProxyBase will have
153 // a public setter that could be called from the TestRunner.
153 #if defined(OS_WIN) 154 #if defined(OS_WIN)
154 // WebTestProxy is a diamond-shaped hierarchy, with WebWidgetClient at the root. 155 // WebViewTestProxy is a diamond-shaped hierarchy, with WebWidgetClient at the
155 // VS warns when we inherit the WebWidgetClient method implementations from 156 // root. VS warns when we inherit the WebWidgetClient method implementations
156 // RenderWidget. It's safe to ignore that warning. 157 // from RenderWidget. It's safe to ignore that warning.
157 #pragma warning(disable: 4250) 158 #pragma warning(disable: 4250)
158 #endif 159 #endif
159 template <class Base, typename... Args> 160 template <class Base, typename... Args>
160 class WebTestProxy : public Base, public WebTestProxyBase { 161 class WebViewTestProxy : public Base, public WebViewTestProxyBase {
161 public: 162 public:
162 explicit WebTestProxy(Args... args) : Base(args...) {} 163 explicit WebViewTestProxy(Args... args) : Base(args...) {}
163 164
164 // WebWidgetClient implementation. 165 // WebWidgetClient implementation.
165 blink::WebScreenInfo screenInfo() override { 166 blink::WebScreenInfo screenInfo() override {
166 blink::WebScreenInfo info = Base::screenInfo(); 167 blink::WebScreenInfo info = Base::screenInfo();
167 blink::WebScreenInfo test_info = widget_test_client()->screenInfo(); 168 blink::WebScreenInfo test_info = widget_test_client()->screenInfo();
168 if (test_info.orientationType != blink::WebScreenOrientationUndefined) { 169 if (test_info.orientationType != blink::WebScreenOrientationUndefined) {
169 info.orientationType = test_info.orientationType; 170 info.orientationType = test_info.orientationType;
170 info.orientationAngle = test_info.orientationAngle; 171 info.orientationAngle = test_info.orientationAngle;
171 } 172 }
172 return info; 173 return info;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 211 }
211 blink::WebView* createView(blink::WebLocalFrame* creator, 212 blink::WebView* createView(blink::WebLocalFrame* creator,
212 const blink::WebURLRequest& request, 213 const blink::WebURLRequest& request,
213 const blink::WebWindowFeatures& features, 214 const blink::WebWindowFeatures& features,
214 const blink::WebString& frame_name, 215 const blink::WebString& frame_name,
215 blink::WebNavigationPolicy policy, 216 blink::WebNavigationPolicy policy,
216 bool suppress_opener) override { 217 bool suppress_opener) override {
217 if (!view_test_client()->createView(creator, request, features, frame_name, 218 if (!view_test_client()->createView(creator, request, features, frame_name,
218 policy, suppress_opener)) 219 policy, suppress_opener))
219 return nullptr; 220 return nullptr;
220 return Base::createView( 221 return Base::createView(creator, request, features, frame_name, policy,
221 creator, request, features, frame_name, policy, suppress_opener); 222 suppress_opener);
222 } 223 }
223 void setStatusText(const blink::WebString& text) override { 224 void setStatusText(const blink::WebString& text) override {
224 view_test_client()->setStatusText(text); 225 view_test_client()->setStatusText(text);
225 Base::setStatusText(text); 226 Base::setStatusText(text);
226 } 227 }
227 void printPage(blink::WebLocalFrame* frame) override { 228 void printPage(blink::WebLocalFrame* frame) override {
228 view_test_client()->printPage(frame); 229 view_test_client()->printPage(frame);
229 } 230 }
230 blink::WebSpeechRecognizer* speechRecognizer() override { 231 blink::WebSpeechRecognizer* speechRecognizer() override {
231 return view_test_client()->speechRecognizer(); 232 return view_test_client()->speechRecognizer();
232 } 233 }
233 void showValidationMessage( 234 void showValidationMessage(
234 const blink::WebRect& anchor_in_root_view, 235 const blink::WebRect& anchor_in_root_view,
235 const blink::WebString& main_message, 236 const blink::WebString& main_message,
236 blink::WebTextDirection main_message_hint, 237 blink::WebTextDirection main_message_hint,
237 const blink::WebString& sub_message, 238 const blink::WebString& sub_message,
238 blink::WebTextDirection sub_message_hint) override { 239 blink::WebTextDirection sub_message_hint) override {
239 view_test_client()->showValidationMessage(anchor_in_root_view, main_message, 240 view_test_client()->showValidationMessage(anchor_in_root_view, main_message,
240 main_message_hint, sub_message, 241 main_message_hint, sub_message,
241 sub_message_hint); 242 sub_message_hint);
242 } 243 }
243 blink::WebString acceptLanguages() override { 244 blink::WebString acceptLanguages() override {
244 return view_test_client()->acceptLanguages(); 245 return view_test_client()->acceptLanguages();
245 } 246 }
246 247
247 private: 248 private:
248 virtual ~WebTestProxy() {} 249 virtual ~WebViewTestProxy() {}
249 250
250 DISALLOW_COPY_AND_ASSIGN(WebTestProxy); 251 DISALLOW_COPY_AND_ASSIGN(WebViewTestProxy);
251 }; 252 };
252 253
253 } // namespace test_runner 254 } // namespace test_runner
254 255
255 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_ 256 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698