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

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

Issue 2036873002: Making EventSender talk to the right WebWidget (for OOPIF support). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use RenderWidget::viewRect() [rather than windowRect()] in TransformScreenToWidgetCoordinates. Created 4 years, 2 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_widget_test_client.h" 5 #include "components/test_runner/web_widget_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/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/test_runner/mock_screen_orientation_client.h" 11 #include "components/test_runner/mock_screen_orientation_client.h"
12 #include "components/test_runner/test_interfaces.h" 12 #include "components/test_runner/test_interfaces.h"
13 #include "components/test_runner/test_runner.h" 13 #include "components/test_runner/test_runner.h"
14 #include "components/test_runner/test_runner_for_specific_view.h" 14 #include "components/test_runner/test_runner_for_specific_view.h"
15 #include "components/test_runner/web_test_delegate.h" 15 #include "components/test_runner/web_test_delegate.h"
16 #include "components/test_runner/web_view_test_proxy.h" 16 #include "components/test_runner/web_view_test_proxy.h"
17 #include "components/test_runner/web_widget_test_proxy.h" 17 #include "components/test_runner/web_widget_test_proxy.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/web/WebPagePopup.h" 19 #include "third_party/WebKit/public/web/WebPagePopup.h"
20 #include "third_party/WebKit/public/web/WebWidget.h" 20 #include "third_party/WebKit/public/web/WebWidget.h"
21 21
22 namespace test_runner { 22 namespace test_runner {
23 23
24 WebWidgetTestClient::WebWidgetTestClient( 24 WebWidgetTestClient::WebWidgetTestClient(
25 TestRunner* test_runner,
26 WebWidgetTestProxyBase* web_widget_test_proxy_base) 25 WebWidgetTestProxyBase* web_widget_test_proxy_base)
27 : test_runner_(test_runner), 26 : web_widget_test_proxy_base_(web_widget_test_proxy_base),
28 web_view_test_proxy_base_(nullptr),
29 web_widget_test_proxy_base_(web_widget_test_proxy_base),
30 animation_scheduled_(false), 27 animation_scheduled_(false),
31 weak_factory_(this) { 28 weak_factory_(this) {
32 DCHECK(test_runner);
33 DCHECK(web_widget_test_proxy_base_); 29 DCHECK(web_widget_test_proxy_base_);
34 } 30 }
35 31
36 WebWidgetTestClient::~WebWidgetTestClient() {} 32 WebWidgetTestClient::~WebWidgetTestClient() {}
37 33
38 void WebWidgetTestClient::scheduleAnimation() { 34 void WebWidgetTestClient::scheduleAnimation() {
39 if (!test_runner_->TestIsRunning()) 35 if (!test_runner()->TestIsRunning())
40 return; 36 return;
41 37
42 if (!animation_scheduled_) { 38 if (!animation_scheduled_) {
43 animation_scheduled_ = true; 39 animation_scheduled_ = true;
44 test_runner_->OnAnimationScheduled( 40 test_runner()->OnAnimationScheduled(
45 web_widget_test_proxy_base_->web_widget()); 41 web_widget_test_proxy_base_->web_widget());
46 42
47 web_view_test_proxy_base_->delegate()->PostDelayedTask( 43 delegate()->PostDelayedTask(base::Bind(&WebWidgetTestClient::AnimateNow,
48 base::Bind(&WebWidgetTestClient::AnimateNow, 44 weak_factory_.GetWeakPtr()),
49 weak_factory_.GetWeakPtr()), 45 1);
50 1);
51 } 46 }
52 } 47 }
53 48
54 void WebWidgetTestClient::AnimateNow() { 49 void WebWidgetTestClient::AnimateNow() {
55 if (animation_scheduled_) { 50 if (animation_scheduled_) {
56 blink::WebWidget* web_widget = web_widget_test_proxy_base_->web_widget(); 51 blink::WebWidget* web_widget = web_widget_test_proxy_base_->web_widget();
57 animation_scheduled_ = false; 52 animation_scheduled_ = false;
58 test_runner_->OnAnimationBegun(web_widget); 53 test_runner()->OnAnimationBegun(web_widget);
59 54
60 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks(); 55 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks();
61 web_widget->beginFrame(animate_time.InSecondsF()); 56 web_widget->beginFrame(animate_time.InSecondsF());
62 web_widget->updateAllLifecyclePhases(); 57 web_widget->updateAllLifecyclePhases();
63 if (blink::WebPagePopup* popup = web_widget->pagePopup()) { 58 if (blink::WebPagePopup* popup = web_widget->pagePopup()) {
64 popup->beginFrame(animate_time.InSecondsF()); 59 popup->beginFrame(animate_time.InSecondsF());
65 popup->updateAllLifecyclePhases(); 60 popup->updateAllLifecyclePhases();
66 } 61 }
67 } 62 }
68 } 63 }
69 64
70 blink::WebScreenInfo WebWidgetTestClient::screenInfo() { 65 blink::WebScreenInfo WebWidgetTestClient::screenInfo() {
71 blink::WebScreenInfo screen_info; 66 blink::WebScreenInfo screen_info;
72 MockScreenOrientationClient* mock_client = 67 MockScreenOrientationClient* mock_client =
73 test_runner_->getMockScreenOrientationClient(); 68 test_runner()->getMockScreenOrientationClient();
74 if (mock_client->IsDisabled()) { 69 if (mock_client->IsDisabled()) {
75 // Indicate to WebViewTestProxy that there is no test/mock info. 70 // Indicate to WebViewTestProxy that there is no test/mock info.
76 screen_info.orientationType = blink::WebScreenOrientationUndefined; 71 screen_info.orientationType = blink::WebScreenOrientationUndefined;
77 } else { 72 } else {
78 // Override screen orientation information with mock data. 73 // Override screen orientation information with mock data.
79 screen_info.orientationType = mock_client->CurrentOrientationType(); 74 screen_info.orientationType = mock_client->CurrentOrientationType();
80 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); 75 screen_info.orientationAngle = mock_client->CurrentOrientationAngle();
81 } 76 }
82 return screen_info; 77 return screen_info;
83 } 78 }
84 79
85 bool WebWidgetTestClient::requestPointerLock() { 80 bool WebWidgetTestClient::requestPointerLock() {
86 return web_view_test_proxy_base_->view_test_runner()->RequestPointerLock(); 81 return view_test_runner()->RequestPointerLock();
87 } 82 }
88 83
89 void WebWidgetTestClient::requestPointerUnlock() { 84 void WebWidgetTestClient::requestPointerUnlock() {
90 web_view_test_proxy_base_->view_test_runner()->RequestPointerUnlock(); 85 view_test_runner()->RequestPointerUnlock();
91 } 86 }
92 87
93 bool WebWidgetTestClient::isPointerLocked() { 88 bool WebWidgetTestClient::isPointerLocked() {
94 return web_view_test_proxy_base_->view_test_runner()->isPointerLocked(); 89 return view_test_runner()->isPointerLocked();
95 } 90 }
96 91
97 void WebWidgetTestClient::setToolTipText(const blink::WebString& text, 92 void WebWidgetTestClient::setToolTipText(const blink::WebString& text,
98 blink::WebTextDirection direction) { 93 blink::WebTextDirection direction) {
99 test_runner_->setToolTipText(text); 94 test_runner()->setToolTipText(text);
100 } 95 }
101 96
102 void WebWidgetTestClient::resetInputMethod() { 97 void WebWidgetTestClient::resetInputMethod() {
103 // If a composition text exists, then we need to let the browser process 98 // If a composition text exists, then we need to let the browser process
104 // to cancel the input method's ongoing composition session. 99 // to cancel the input method's ongoing composition session.
105 if (web_widget_test_proxy_base_) 100 if (web_widget_test_proxy_base_)
106 web_widget_test_proxy_base_->web_widget()->finishComposingText( 101 web_widget_test_proxy_base_->web_widget()->finishComposingText(
107 blink::WebWidget::KeepSelection); 102 blink::WebWidget::KeepSelection);
108 } 103 }
109 104
105 TestRunnerForSpecificView* WebWidgetTestClient::view_test_runner() {
106 return web_widget_test_proxy_base_->web_view_test_proxy_base()
107 ->view_test_runner();
108 }
109
110 WebTestDelegate* WebWidgetTestClient::delegate() {
111 return web_widget_test_proxy_base_->web_view_test_proxy_base()->delegate();
112 }
113
114 TestRunner* WebWidgetTestClient::test_runner() {
115 return web_widget_test_proxy_base_->web_view_test_proxy_base()
116 ->test_interfaces()
117 ->GetTestRunner();
118 }
119
110 } // namespace test_runner 120 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/web_widget_test_client.h ('k') | components/test_runner/web_widget_test_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698