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 #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_task.h" | 15 #include "components/test_runner/web_task.h" |
16 #include "components/test_runner/web_test_delegate.h" | 16 #include "components/test_runner/web_test_delegate.h" |
17 #include "components/test_runner/web_test_proxy.h" | 17 #include "components/test_runner/web_view_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(TestRunner* test_runner, | 24 WebWidgetTestClient::WebWidgetTestClient( |
25 WebTestProxyBase* web_test_proxy_base) | 25 TestRunner* test_runner, |
| 26 WebViewTestProxyBase* web_view_test_proxy_base) |
26 : test_runner_(test_runner), | 27 : test_runner_(test_runner), |
27 web_test_proxy_base_(web_test_proxy_base), | 28 web_view_test_proxy_base_(web_view_test_proxy_base), |
28 animation_scheduled_(false), | 29 animation_scheduled_(false), |
29 weak_factory_(this) { | 30 weak_factory_(this) { |
30 DCHECK(test_runner); | 31 DCHECK(test_runner); |
31 DCHECK(web_test_proxy_base); | 32 DCHECK(web_view_test_proxy_base); |
32 } | 33 } |
33 | 34 |
34 WebWidgetTestClient::~WebWidgetTestClient() {} | 35 WebWidgetTestClient::~WebWidgetTestClient() {} |
35 | 36 |
36 void WebWidgetTestClient::scheduleAnimation() { | 37 void WebWidgetTestClient::scheduleAnimation() { |
37 if (!test_runner_->TestIsRunning()) | 38 if (!test_runner_->TestIsRunning()) |
38 return; | 39 return; |
39 | 40 |
40 if (!animation_scheduled_) { | 41 if (!animation_scheduled_) { |
41 animation_scheduled_ = true; | 42 animation_scheduled_ = true; |
42 test_runner_->OnAnimationScheduled(web_test_proxy_base_->web_widget()); | 43 test_runner_->OnAnimationScheduled(web_view_test_proxy_base_->web_widget()); |
43 | 44 |
44 web_test_proxy_base_->delegate()->PostDelayedTask( | 45 web_view_test_proxy_base_->delegate()->PostDelayedTask( |
45 new WebCallbackTask(base::Bind(&WebWidgetTestClient::AnimateNow, | 46 new WebCallbackTask(base::Bind(&WebWidgetTestClient::AnimateNow, |
46 weak_factory_.GetWeakPtr())), | 47 weak_factory_.GetWeakPtr())), |
47 1); | 48 1); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 void WebWidgetTestClient::AnimateNow() { | 52 void WebWidgetTestClient::AnimateNow() { |
52 if (animation_scheduled_) { | 53 if (animation_scheduled_) { |
53 blink::WebWidget* web_widget = web_test_proxy_base_->web_widget(); | 54 blink::WebWidget* web_widget = web_view_test_proxy_base_->web_widget(); |
54 animation_scheduled_ = false; | 55 animation_scheduled_ = false; |
55 test_runner_->OnAnimationBegun(web_widget); | 56 test_runner_->OnAnimationBegun(web_widget); |
56 | 57 |
57 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks(); | 58 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks(); |
58 web_widget->beginFrame(animate_time.InSecondsF()); | 59 web_widget->beginFrame(animate_time.InSecondsF()); |
59 web_widget->updateAllLifecyclePhases(); | 60 web_widget->updateAllLifecyclePhases(); |
60 if (blink::WebPagePopup* popup = web_widget->pagePopup()) { | 61 if (blink::WebPagePopup* popup = web_widget->pagePopup()) { |
61 popup->beginFrame(animate_time.InSecondsF()); | 62 popup->beginFrame(animate_time.InSecondsF()); |
62 popup->updateAllLifecyclePhases(); | 63 popup->updateAllLifecyclePhases(); |
63 } | 64 } |
64 } | 65 } |
65 } | 66 } |
66 | 67 |
67 blink::WebScreenInfo WebWidgetTestClient::screenInfo() { | 68 blink::WebScreenInfo WebWidgetTestClient::screenInfo() { |
68 blink::WebScreenInfo screen_info; | 69 blink::WebScreenInfo screen_info; |
69 MockScreenOrientationClient* mock_client = | 70 MockScreenOrientationClient* mock_client = |
70 web_test_proxy_base_->test_interfaces() | 71 web_view_test_proxy_base_->test_interfaces() |
71 ->GetTestRunner() | 72 ->GetTestRunner() |
72 ->getMockScreenOrientationClient(); | 73 ->getMockScreenOrientationClient(); |
73 if (mock_client->IsDisabled()) { | 74 if (mock_client->IsDisabled()) { |
74 // Indicate to WebTestProxy that there is no test/mock info. | 75 // Indicate to WebViewTestProxy that there is no test/mock info. |
75 screen_info.orientationType = blink::WebScreenOrientationUndefined; | 76 screen_info.orientationType = blink::WebScreenOrientationUndefined; |
76 } else { | 77 } else { |
77 // Override screen orientation information with mock data. | 78 // Override screen orientation information with mock data. |
78 screen_info.orientationType = mock_client->CurrentOrientationType(); | 79 screen_info.orientationType = mock_client->CurrentOrientationType(); |
79 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); | 80 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); |
80 } | 81 } |
81 return screen_info; | 82 return screen_info; |
82 } | 83 } |
83 | 84 |
84 bool WebWidgetTestClient::requestPointerLock() { | 85 bool WebWidgetTestClient::requestPointerLock() { |
85 return web_test_proxy_base_->view_test_runner()->RequestPointerLock(); | 86 return web_view_test_proxy_base_->view_test_runner()->RequestPointerLock(); |
86 } | 87 } |
87 | 88 |
88 void WebWidgetTestClient::requestPointerUnlock() { | 89 void WebWidgetTestClient::requestPointerUnlock() { |
89 web_test_proxy_base_->view_test_runner()->RequestPointerUnlock(); | 90 web_view_test_proxy_base_->view_test_runner()->RequestPointerUnlock(); |
90 } | 91 } |
91 | 92 |
92 bool WebWidgetTestClient::isPointerLocked() { | 93 bool WebWidgetTestClient::isPointerLocked() { |
93 return web_test_proxy_base_->view_test_runner()->isPointerLocked(); | 94 return web_view_test_proxy_base_->view_test_runner()->isPointerLocked(); |
94 } | 95 } |
95 | 96 |
96 void WebWidgetTestClient::setToolTipText(const blink::WebString& text, | 97 void WebWidgetTestClient::setToolTipText(const blink::WebString& text, |
97 blink::WebTextDirection direction) { | 98 blink::WebTextDirection direction) { |
98 test_runner_->setToolTipText(text); | 99 test_runner_->setToolTipText(text); |
99 } | 100 } |
100 | 101 |
101 void WebWidgetTestClient::resetInputMethod() { | 102 void WebWidgetTestClient::resetInputMethod() { |
102 // If a composition text exists, then we need to let the browser process | 103 // If a composition text exists, then we need to let the browser process |
103 // to cancel the input method's ongoing composition session. | 104 // to cancel the input method's ongoing composition session. |
104 if (web_test_proxy_base_) | 105 if (web_view_test_proxy_base_) |
105 web_test_proxy_base_->web_widget()->confirmComposition(); | 106 web_view_test_proxy_base_->web_widget()->confirmComposition(); |
106 } | 107 } |
107 | 108 |
108 } // namespace test_runner | 109 } // namespace test_runner |
OLD | NEW |