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_view_test_proxy.h" | 17 #include "components/test_runner/web_view_test_proxy.h" |
| 18 #include "components/test_runner/web_widget_test_proxy.h" |
18 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 19 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
19 #include "third_party/WebKit/public/web/WebPagePopup.h" | 20 #include "third_party/WebKit/public/web/WebPagePopup.h" |
20 #include "third_party/WebKit/public/web/WebWidget.h" | 21 #include "third_party/WebKit/public/web/WebWidget.h" |
21 | 22 |
22 namespace test_runner { | 23 namespace test_runner { |
23 | 24 |
24 WebWidgetTestClient::WebWidgetTestClient( | 25 WebWidgetTestClient::WebWidgetTestClient( |
25 TestRunner* test_runner, | 26 TestRunner* test_runner, |
26 WebViewTestProxyBase* web_view_test_proxy_base) | 27 WebWidgetTestProxyBase* web_widget_test_proxy_base) |
27 : test_runner_(test_runner), | 28 : test_runner_(test_runner), |
28 web_view_test_proxy_base_(web_view_test_proxy_base), | 29 web_view_test_proxy_base_(nullptr), |
| 30 web_widget_test_proxy_base_(web_widget_test_proxy_base), |
29 animation_scheduled_(false), | 31 animation_scheduled_(false), |
30 weak_factory_(this) { | 32 weak_factory_(this) { |
31 DCHECK(test_runner); | 33 DCHECK(test_runner); |
32 DCHECK(web_view_test_proxy_base); | 34 DCHECK(web_widget_test_proxy_base_); |
33 } | 35 } |
34 | 36 |
35 WebWidgetTestClient::~WebWidgetTestClient() {} | 37 WebWidgetTestClient::~WebWidgetTestClient() {} |
36 | 38 |
37 void WebWidgetTestClient::scheduleAnimation() { | 39 void WebWidgetTestClient::scheduleAnimation() { |
38 if (!test_runner_->TestIsRunning()) | 40 if (!test_runner_->TestIsRunning()) |
39 return; | 41 return; |
40 | 42 |
41 if (!animation_scheduled_) { | 43 if (!animation_scheduled_) { |
42 animation_scheduled_ = true; | 44 animation_scheduled_ = true; |
43 test_runner_->OnAnimationScheduled(web_view_test_proxy_base_->web_widget()); | 45 test_runner_->OnAnimationScheduled( |
| 46 web_widget_test_proxy_base_->web_widget()); |
44 | 47 |
45 web_view_test_proxy_base_->delegate()->PostDelayedTask( | 48 web_view_test_proxy_base_->delegate()->PostDelayedTask( |
46 new WebCallbackTask(base::Bind(&WebWidgetTestClient::AnimateNow, | 49 new WebCallbackTask(base::Bind(&WebWidgetTestClient::AnimateNow, |
47 weak_factory_.GetWeakPtr())), | 50 weak_factory_.GetWeakPtr())), |
48 1); | 51 1); |
49 } | 52 } |
50 } | 53 } |
51 | 54 |
52 void WebWidgetTestClient::AnimateNow() { | 55 void WebWidgetTestClient::AnimateNow() { |
53 if (animation_scheduled_) { | 56 if (animation_scheduled_) { |
54 blink::WebWidget* web_widget = web_view_test_proxy_base_->web_widget(); | 57 blink::WebWidget* web_widget = web_widget_test_proxy_base_->web_widget(); |
55 animation_scheduled_ = false; | 58 animation_scheduled_ = false; |
56 test_runner_->OnAnimationBegun(web_widget); | 59 test_runner_->OnAnimationBegun(web_widget); |
57 | 60 |
58 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks(); | 61 base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks(); |
59 web_widget->beginFrame(animate_time.InSecondsF()); | 62 web_widget->beginFrame(animate_time.InSecondsF()); |
60 web_widget->updateAllLifecyclePhases(); | 63 web_widget->updateAllLifecyclePhases(); |
61 if (blink::WebPagePopup* popup = web_widget->pagePopup()) { | 64 if (blink::WebPagePopup* popup = web_widget->pagePopup()) { |
62 popup->beginFrame(animate_time.InSecondsF()); | 65 popup->beginFrame(animate_time.InSecondsF()); |
63 popup->updateAllLifecyclePhases(); | 66 popup->updateAllLifecyclePhases(); |
64 } | 67 } |
65 } | 68 } |
66 } | 69 } |
67 | 70 |
68 blink::WebScreenInfo WebWidgetTestClient::screenInfo() { | 71 blink::WebScreenInfo WebWidgetTestClient::screenInfo() { |
69 blink::WebScreenInfo screen_info; | 72 blink::WebScreenInfo screen_info; |
70 MockScreenOrientationClient* mock_client = | 73 MockScreenOrientationClient* mock_client = |
71 web_view_test_proxy_base_->test_interfaces() | 74 test_runner_->getMockScreenOrientationClient(); |
72 ->GetTestRunner() | |
73 ->getMockScreenOrientationClient(); | |
74 if (mock_client->IsDisabled()) { | 75 if (mock_client->IsDisabled()) { |
75 // Indicate to WebViewTestProxy that there is no test/mock info. | 76 // Indicate to WebViewTestProxy that there is no test/mock info. |
76 screen_info.orientationType = blink::WebScreenOrientationUndefined; | 77 screen_info.orientationType = blink::WebScreenOrientationUndefined; |
77 } else { | 78 } else { |
78 // Override screen orientation information with mock data. | 79 // Override screen orientation information with mock data. |
79 screen_info.orientationType = mock_client->CurrentOrientationType(); | 80 screen_info.orientationType = mock_client->CurrentOrientationType(); |
80 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); | 81 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); |
81 } | 82 } |
82 return screen_info; | 83 return screen_info; |
83 } | 84 } |
(...skipping 11 matching lines...) Expand all Loading... |
95 } | 96 } |
96 | 97 |
97 void WebWidgetTestClient::setToolTipText(const blink::WebString& text, | 98 void WebWidgetTestClient::setToolTipText(const blink::WebString& text, |
98 blink::WebTextDirection direction) { | 99 blink::WebTextDirection direction) { |
99 test_runner_->setToolTipText(text); | 100 test_runner_->setToolTipText(text); |
100 } | 101 } |
101 | 102 |
102 void WebWidgetTestClient::resetInputMethod() { | 103 void WebWidgetTestClient::resetInputMethod() { |
103 // If a composition text exists, then we need to let the browser process | 104 // If a composition text exists, then we need to let the browser process |
104 // to cancel the input method's ongoing composition session. | 105 // to cancel the input method's ongoing composition session. |
105 if (web_view_test_proxy_base_) | 106 if (web_widget_test_proxy_base_) |
106 web_view_test_proxy_base_->web_widget()->confirmComposition(); | 107 web_widget_test_proxy_base_->web_widget()->confirmComposition(); |
107 } | 108 } |
108 | 109 |
109 } // namespace test_runner | 110 } // namespace test_runner |
OLD | NEW |