OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "components/test_runner/mock_spell_check.h" | 19 #include "components/test_runner/mock_spell_check.h" |
20 #include "components/test_runner/test_interfaces.h" | 20 #include "components/test_runner/test_interfaces.h" |
21 #include "components/test_runner/web_task.h" | 21 #include "components/test_runner/web_task.h" |
22 #include "components/test_runner/web_test_delegate.h" | 22 #include "components/test_runner/web_test_delegate.h" |
23 #include "components/test_runner/web_test_proxy.h" | 23 #include "components/test_runner/web_view_test_proxy.h" |
24 #include "gin/handle.h" | 24 #include "gin/handle.h" |
25 #include "gin/object_template_builder.h" | 25 #include "gin/object_template_builder.h" |
26 #include "gin/wrappable.h" | 26 #include "gin/wrappable.h" |
27 #include "third_party/WebKit/public/platform/WebPointerProperties.h" | 27 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
28 #include "third_party/WebKit/public/platform/WebString.h" | 28 #include "third_party/WebKit/public/platform/WebString.h" |
29 #include "third_party/WebKit/public/platform/WebVector.h" | 29 #include "third_party/WebKit/public/platform/WebVector.h" |
30 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 30 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
31 #include "third_party/WebKit/public/web/WebKit.h" | 31 #include "third_party/WebKit/public/web/WebKit.h" |
32 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
33 #include "third_party/WebKit/public/web/WebPagePopup.h" | 33 #include "third_party/WebKit/public/web/WebPagePopup.h" |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 | 1267 |
1268 WebMouseEvent::Button EventSender::last_button_type_ = | 1268 WebMouseEvent::Button EventSender::last_button_type_ = |
1269 WebMouseEvent::ButtonNone; | 1269 WebMouseEvent::ButtonNone; |
1270 | 1270 |
1271 EventSender::SavedEvent::SavedEvent() | 1271 EventSender::SavedEvent::SavedEvent() |
1272 : type(TYPE_UNSPECIFIED), | 1272 : type(TYPE_UNSPECIFIED), |
1273 button_type(WebMouseEvent::ButtonNone), | 1273 button_type(WebMouseEvent::ButtonNone), |
1274 milliseconds(0), | 1274 milliseconds(0), |
1275 modifiers(0) {} | 1275 modifiers(0) {} |
1276 | 1276 |
1277 EventSender::EventSender(WebTestProxyBase* web_test_proxy_base) | 1277 EventSender::EventSender(WebViewTestProxyBase* web_view_test_proxy_base) |
1278 : web_test_proxy_base_(web_test_proxy_base), | 1278 : web_view_test_proxy_base_(web_view_test_proxy_base), |
1279 replaying_saved_events_(false), | 1279 replaying_saved_events_(false), |
1280 weak_factory_(this) { | 1280 weak_factory_(this) { |
1281 Reset(); | 1281 Reset(); |
1282 } | 1282 } |
1283 | 1283 |
1284 EventSender::~EventSender() {} | 1284 EventSender::~EventSender() {} |
1285 | 1285 |
1286 void EventSender::Reset() { | 1286 void EventSender::Reset() { |
1287 DCHECK(current_drag_data_.isNull()); | 1287 DCHECK(current_drag_data_.isNull()); |
1288 current_drag_data_.reset(); | 1288 current_drag_data_.reset(); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 | 1773 |
1774 void EventSender::TextZoomIn() { | 1774 void EventSender::TextZoomIn() { |
1775 view()->setTextZoomFactor(view()->textZoomFactor() * 1.2f); | 1775 view()->setTextZoomFactor(view()->textZoomFactor() * 1.2f); |
1776 } | 1776 } |
1777 | 1777 |
1778 void EventSender::TextZoomOut() { | 1778 void EventSender::TextZoomOut() { |
1779 view()->setTextZoomFactor(view()->textZoomFactor() / 1.2f); | 1779 view()->setTextZoomFactor(view()->textZoomFactor() / 1.2f); |
1780 } | 1780 } |
1781 | 1781 |
1782 void EventSender::ZoomPageIn() { | 1782 void EventSender::ZoomPageIn() { |
1783 const std::vector<WebTestProxyBase*>& window_list = | 1783 const std::vector<WebViewTestProxyBase*>& window_list = |
1784 interfaces()->GetWindowList(); | 1784 interfaces()->GetWindowList(); |
1785 | 1785 |
1786 for (size_t i = 0; i < window_list.size(); ++i) { | 1786 for (size_t i = 0; i < window_list.size(); ++i) { |
1787 window_list.at(i)->web_view()->setZoomLevel( | 1787 window_list.at(i)->web_view()->setZoomLevel( |
1788 window_list.at(i)->web_view()->zoomLevel() + 1); | 1788 window_list.at(i)->web_view()->zoomLevel() + 1); |
1789 } | 1789 } |
1790 } | 1790 } |
1791 | 1791 |
1792 void EventSender::ZoomPageOut() { | 1792 void EventSender::ZoomPageOut() { |
1793 const std::vector<WebTestProxyBase*>& window_list = | 1793 const std::vector<WebViewTestProxyBase*>& window_list = |
1794 interfaces()->GetWindowList(); | 1794 interfaces()->GetWindowList(); |
1795 | 1795 |
1796 for (size_t i = 0; i < window_list.size(); ++i) { | 1796 for (size_t i = 0; i < window_list.size(); ++i) { |
1797 window_list.at(i)->web_view()->setZoomLevel( | 1797 window_list.at(i)->web_view()->setZoomLevel( |
1798 window_list.at(i)->web_view()->zoomLevel() - 1); | 1798 window_list.at(i)->web_view()->zoomLevel() - 1); |
1799 } | 1799 } |
1800 } | 1800 } |
1801 | 1801 |
1802 void EventSender::SetPageZoomFactor(double zoom_factor) { | 1802 void EventSender::SetPageZoomFactor(double zoom_factor) { |
1803 const std::vector<WebTestProxyBase*>& window_list = | 1803 const std::vector<WebViewTestProxyBase*>& window_list = |
1804 interfaces()->GetWindowList(); | 1804 interfaces()->GetWindowList(); |
1805 | 1805 |
1806 for (size_t i = 0; i < window_list.size(); ++i) { | 1806 for (size_t i = 0; i < window_list.size(); ++i) { |
1807 window_list.at(i)->web_view()->setZoomLevel(std::log(zoom_factor) / | 1807 window_list.at(i)->web_view()->setZoomLevel(std::log(zoom_factor) / |
1808 std::log(1.2)); | 1808 std::log(1.2)); |
1809 } | 1809 } |
1810 } | 1810 } |
1811 | 1811 |
1812 void EventSender::ClearTouchPoints() { | 1812 void EventSender::ClearTouchPoints() { |
1813 touch_points_.clear(); | 1813 touch_points_.clear(); |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2833 &end_event); | 2833 &end_event); |
2834 end_event.data.scrollEnd.deltaUnits = | 2834 end_event.data.scrollEnd.deltaUnits = |
2835 begin_event.data.scrollBegin.deltaHintUnits; | 2835 begin_event.data.scrollBegin.deltaHintUnits; |
2836 | 2836 |
2837 if (force_layout_on_events_) | 2837 if (force_layout_on_events_) |
2838 view()->updateAllLifecyclePhases(); | 2838 view()->updateAllLifecyclePhases(); |
2839 HandleInputEventOnViewOrPopup(end_event); | 2839 HandleInputEventOnViewOrPopup(end_event); |
2840 } | 2840 } |
2841 | 2841 |
2842 TestInterfaces* EventSender::interfaces() { | 2842 TestInterfaces* EventSender::interfaces() { |
2843 return web_test_proxy_base_->test_interfaces(); | 2843 return web_view_test_proxy_base_->test_interfaces(); |
2844 } | 2844 } |
2845 | 2845 |
2846 WebTestDelegate* EventSender::delegate() { | 2846 WebTestDelegate* EventSender::delegate() { |
2847 return web_test_proxy_base_->delegate(); | 2847 return web_view_test_proxy_base_->delegate(); |
2848 } | 2848 } |
2849 | 2849 |
2850 const blink::WebView* EventSender::view() const { | 2850 const blink::WebView* EventSender::view() const { |
2851 return web_test_proxy_base_->web_view(); | 2851 return web_view_test_proxy_base_->web_view(); |
2852 } | 2852 } |
2853 | 2853 |
2854 blink::WebView* EventSender::view() { | 2854 blink::WebView* EventSender::view() { |
2855 return web_test_proxy_base_->web_view(); | 2855 return web_view_test_proxy_base_->web_view(); |
2856 } | 2856 } |
2857 | 2857 |
2858 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( | 2858 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( |
2859 const WebInputEvent& event) { | 2859 const WebInputEvent& event) { |
2860 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event | 2860 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event |
2861 // does not have to be converted. | 2861 // does not have to be converted. |
2862 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | 2862 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); |
2863 } | 2863 } |
2864 | 2864 |
2865 } // namespace test_runner | 2865 } // namespace test_runner |
OLD | NEW |