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

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

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