| 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" | |
| 22 #include "components/test_runner/web_test_delegate.h" | 21 #include "components/test_runner/web_test_delegate.h" |
| 23 #include "components/test_runner/web_view_test_proxy.h" | 22 #include "components/test_runner/web_view_test_proxy.h" |
| 24 #include "gin/handle.h" | 23 #include "gin/handle.h" |
| 25 #include "gin/object_template_builder.h" | 24 #include "gin/object_template_builder.h" |
| 26 #include "gin/wrappable.h" | 25 #include "gin/wrappable.h" |
| 27 #include "third_party/WebKit/public/platform/WebPointerProperties.h" | 26 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
| 28 #include "third_party/WebKit/public/platform/WebString.h" | 27 #include "third_party/WebKit/public/platform/WebString.h" |
| 29 #include "third_party/WebKit/public/platform/WebVector.h" | 28 #include "third_party/WebKit/public/platform/WebVector.h" |
| 30 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 29 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 31 #include "third_party/WebKit/public/web/WebKit.h" | 30 #include "third_party/WebKit/public/web/WebKit.h" |
| (...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2201 | 2200 |
| 2202 WebMouseEvent event; | 2201 WebMouseEvent event; |
| 2203 InitMouseEvent(WebInputEvent::MouseLeave, WebMouseEvent::Button::NoButton, 0, | 2202 InitMouseEvent(WebInputEvent::MouseLeave, WebMouseEvent::Button::NoButton, 0, |
| 2204 current_pointer_state_[kRawMousePointerId].last_pos_, | 2203 current_pointer_state_[kRawMousePointerId].last_pos_, |
| 2205 GetCurrentEventTimeSec(), click_count_, 0, &event); | 2204 GetCurrentEventTimeSec(), click_count_, 0, &event); |
| 2206 HandleInputEventOnViewOrPopup(event); | 2205 HandleInputEventOnViewOrPopup(event); |
| 2207 } | 2206 } |
| 2208 | 2207 |
| 2209 | 2208 |
| 2210 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { | 2209 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
| 2211 delegate()->PostTask(new WebCallbackTask( | 2210 delegate()->PostTask(base::Bind(&EventSender::MouseDown, |
| 2212 base::Bind(&EventSender::MouseDown, weak_factory_.GetWeakPtr(), | 2211 weak_factory_.GetWeakPtr(), button_number, |
| 2213 button_number, modifiers))); | 2212 modifiers)); |
| 2214 delegate()->PostTask(new WebCallbackTask( | 2213 delegate()->PostTask(base::Bind(&EventSender::MouseUp, |
| 2215 base::Bind(&EventSender::MouseUp, weak_factory_.GetWeakPtr(), | 2214 weak_factory_.GetWeakPtr(), button_number, |
| 2216 button_number, modifiers))); | 2215 modifiers)); |
| 2217 } | 2216 } |
| 2218 | 2217 |
| 2219 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, | 2218 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, |
| 2220 int modifiers, | 2219 int modifiers, |
| 2221 KeyLocationCode location) { | 2220 KeyLocationCode location) { |
| 2222 delegate()->PostTask(new WebCallbackTask( | 2221 delegate()->PostTask(base::Bind(&EventSender::KeyDown, |
| 2223 base::Bind(&EventSender::KeyDown, weak_factory_.GetWeakPtr(), code_str, | 2222 weak_factory_.GetWeakPtr(), code_str, |
| 2224 modifiers, location))); | 2223 modifiers, location)); |
| 2225 } | 2224 } |
| 2226 | 2225 |
| 2227 double EventSender::GetCurrentEventTimeSec() { | 2226 double EventSender::GetCurrentEventTimeSec() { |
| 2228 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + | 2227 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + |
| 2229 time_offset_ms_ / 1000.0; | 2228 time_offset_ms_ / 1000.0; |
| 2230 } | 2229 } |
| 2231 | 2230 |
| 2232 void EventSender::DoLeapForward(int milliseconds) { | 2231 void EventSender::DoLeapForward(int milliseconds) { |
| 2233 time_offset_ms_ += milliseconds; | 2232 time_offset_ms_ += milliseconds; |
| 2234 } | 2233 } |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 } | 2877 } |
| 2879 | 2878 |
| 2880 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( | 2879 std::unique_ptr<WebInputEvent> EventSender::ScaleEvent( |
| 2881 const WebInputEvent& event) { | 2880 const WebInputEvent& event) { |
| 2882 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event | 2881 // ui::ScaleWebInputEvent returns nullptr when the scale is 1.0f as the event |
| 2883 // does not have to be converted. | 2882 // does not have to be converted. |
| 2884 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); | 2883 return ui::ScaleWebInputEvent(event, delegate()->GetWindowToViewportScale()); |
| 2885 } | 2884 } |
| 2886 | 2885 |
| 2887 } // namespace test_runner | 2886 } // namespace test_runner |
| OLD | NEW |