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

Side by Side Diff: components/test_runner/web_view_test_client.cc

Issue 1935593004: Extract WebWidgetTestClient out of WebTestProxyBase and WebViewTestClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-runner-for-specific-view-separate
Patch Set: Created 4 years, 7 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 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 #include "components/test_runner/web_view_test_client.h" 5 #include "components/test_runner/web_view_test_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 13 matching lines...) Expand all
24 #include "third_party/WebKit/public/web/WebPagePopup.h" 24 #include "third_party/WebKit/public/web/WebPagePopup.h"
25 #include "third_party/WebKit/public/web/WebPrintParams.h" 25 #include "third_party/WebKit/public/web/WebPrintParams.h"
26 #include "third_party/WebKit/public/web/WebView.h" 26 #include "third_party/WebKit/public/web/WebView.h"
27 #include "third_party/WebKit/public/web/WebWidget.h" 27 #include "third_party/WebKit/public/web/WebWidget.h"
28 28
29 namespace test_runner { 29 namespace test_runner {
30 30
31 WebViewTestClient::WebViewTestClient(TestRunner* test_runner, 31 WebViewTestClient::WebViewTestClient(TestRunner* test_runner,
32 WebTestProxyBase* web_test_proxy_base) 32 WebTestProxyBase* web_test_proxy_base)
33 : test_runner_(test_runner), 33 : test_runner_(test_runner),
34 web_test_proxy_base_(web_test_proxy_base), 34 web_test_proxy_base_(web_test_proxy_base) {
35 animation_scheduled_(false),
36 weak_factory_(this) {
37 DCHECK(test_runner); 35 DCHECK(test_runner);
38 DCHECK(web_test_proxy_base); 36 DCHECK(web_test_proxy_base);
39 } 37 }
40 38
41 WebViewTestClient::~WebViewTestClient() {} 39 WebViewTestClient::~WebViewTestClient() {}
42 40
43 void WebViewTestClient::scheduleAnimation() {
44 if (!test_runner_->TestIsRunning())
45 return;
46
47 if (!animation_scheduled_) {
48 animation_scheduled_ = true;
49 test_runner_->OnAnimationScheduled(web_test_proxy_base_->web_view());
50
51 delegate()->PostDelayedTask(
52 new WebCallbackTask(base::Bind(&WebViewTestClient::AnimateNow,
53 weak_factory_.GetWeakPtr())),
54 1);
55 }
56 }
57
58 void WebViewTestClient::AnimateNow() {
59 if (animation_scheduled_) {
60 blink::WebWidget* web_widget = web_test_proxy_base_->web_widget();
61 animation_scheduled_ = false;
62 test_runner_->OnAnimationBegun(web_test_proxy_base_->web_view());
63
64 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks();
65 web_widget->beginFrame(animate_time.InSecondsF());
66 web_widget->updateAllLifecyclePhases();
67 if (blink::WebPagePopup* popup = web_widget->pagePopup()) {
68 popup->beginFrame(animate_time.InSecondsF());
69 popup->updateAllLifecyclePhases();
70 }
71 }
72 }
73
74 void WebViewTestClient::startDragging(blink::WebLocalFrame* frame, 41 void WebViewTestClient::startDragging(blink::WebLocalFrame* frame,
75 const blink::WebDragData& data, 42 const blink::WebDragData& data,
76 blink::WebDragOperationsMask mask, 43 blink::WebDragOperationsMask mask,
77 const blink::WebImage& image, 44 const blink::WebImage& image,
78 const blink::WebPoint& point) { 45 const blink::WebPoint& point) {
79 test_runner_->setDragImage(image); 46 test_runner_->setDragImage(image);
80 47
81 // When running a test, we need to fake a drag drop operation otherwise 48 // When running a test, we need to fake a drag drop operation otherwise
82 // Windows waits for real mouse events to know when the drag is over. 49 // Windows waits for real mouse events to know when the drag is over.
83 web_test_proxy_base_->event_sender()->DoDragDrop(data, mask); 50 web_test_proxy_base_->event_sender()->DoDragDrop(data, mask);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 delegate()->PrintMessage("ValidationMessageClient: main-message=" + 139 delegate()->PrintMessage("ValidationMessageClient: main-message=" +
173 base::UTF16ToUTF8(wrapped_main_text) + 140 base::UTF16ToUTF8(wrapped_main_text) +
174 " sub-message=" + 141 " sub-message=" +
175 base::UTF16ToUTF8(wrapped_sub_text) + "\n"); 142 base::UTF16ToUTF8(wrapped_sub_text) + "\n");
176 } 143 }
177 144
178 blink::WebSpeechRecognizer* WebViewTestClient::speechRecognizer() { 145 blink::WebSpeechRecognizer* WebViewTestClient::speechRecognizer() {
179 return test_runner_->getMockWebSpeechRecognizer(); 146 return test_runner_->getMockWebSpeechRecognizer();
180 } 147 }
181 148
182 bool WebViewTestClient::requestPointerLock() {
183 return web_test_proxy_base_->view_test_runner()->RequestPointerLock();
184 }
185
186 void WebViewTestClient::requestPointerUnlock() {
187 web_test_proxy_base_->view_test_runner()->RequestPointerUnlock();
188 }
189
190 bool WebViewTestClient::isPointerLocked() {
191 return web_test_proxy_base_->view_test_runner()->isPointerLocked();
192 }
193
194 void WebViewTestClient::didFocus() {
195 test_runner_->SetFocus(web_test_proxy_base_->web_view(), true);
196 }
197
198 void WebViewTestClient::setToolTipText(const blink::WebString& text,
199 blink::WebTextDirection direction) {
200 test_runner_->setToolTipText(text);
201 }
202
203 void WebViewTestClient::resetInputMethod() {
204 // If a composition text exists, then we need to let the browser process
205 // to cancel the input method's ongoing composition session.
206 if (web_test_proxy_base_)
207 web_test_proxy_base_->web_widget()->confirmComposition();
208 }
209
210 blink::WebString WebViewTestClient::acceptLanguages() { 149 blink::WebString WebViewTestClient::acceptLanguages() {
211 return blink::WebString::fromUTF8(test_runner_->GetAcceptLanguages()); 150 return blink::WebString::fromUTF8(test_runner_->GetAcceptLanguages());
212 } 151 }
213 152
214 WebTestDelegate* WebViewTestClient::delegate() { 153 WebTestDelegate* WebViewTestClient::delegate() {
215 return web_test_proxy_base_->delegate(); 154 return web_test_proxy_base_->delegate();
216 } 155 }
217 156
218 } // namespace test_runner 157 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/web_view_test_client.h ('k') | components/test_runner/web_widget_test_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698