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" |
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 | 1875 |
1876 bool EventSender::IsFlinging() const { | 1876 bool EventSender::IsFlinging() const { |
1877 return view()->isFlinging(); | 1877 return view()->isFlinging(); |
1878 } | 1878 } |
1879 | 1879 |
1880 void EventSender::GestureScrollFirstPoint(int x, int y) { | 1880 void EventSender::GestureScrollFirstPoint(int x, int y) { |
1881 current_gesture_location_ = WebPoint(x, y); | 1881 current_gesture_location_ = WebPoint(x, y); |
1882 } | 1882 } |
1883 | 1883 |
1884 bool EventSender::GetMovedBeyondSlopRegionArg(gin::Arguments* args) { | 1884 bool EventSender::GetMovedBeyondSlopRegionArg(gin::Arguments* args) { |
1885 std::string arg; | |
1886 if (args->PeekNext().IsEmpty()) | 1885 if (args->PeekNext().IsEmpty()) |
1887 return false; | 1886 return false; |
1888 | 1887 |
| 1888 std::string arg; |
1889 if(args->PeekNext()->IsString() && args->GetNext(&arg)) { | 1889 if(args->PeekNext()->IsString() && args->GetNext(&arg)) { |
1890 if (arg == "movedBeyondSlopRegion") | 1890 if (arg == "movedBeyondSlopRegion") |
1891 return true; | 1891 return true; |
1892 } | 1892 } |
1893 | 1893 |
1894 args->ThrowError(); | |
1895 return false; | 1894 return false; |
1896 } | 1895 } |
1897 | 1896 |
| 1897 uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) { |
| 1898 uint32_t unique_touch_event_id; |
| 1899 if(!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id)) |
| 1900 return unique_touch_event_id; |
| 1901 |
| 1902 return 0; |
| 1903 } |
| 1904 |
1898 void EventSender::TouchStart(gin::Arguments* args) { | 1905 void EventSender::TouchStart(gin::Arguments* args) { |
1899 SendCurrentTouchEvent(WebInputEvent::TouchStart, | 1906 SendCurrentTouchEvent(WebInputEvent::TouchStart, |
1900 GetMovedBeyondSlopRegionArg(args)); | 1907 GetMovedBeyondSlopRegionArg(args), |
| 1908 GetUniqueTouchEventId(args)); |
1901 } | 1909 } |
1902 | 1910 |
1903 void EventSender::TouchMove(gin::Arguments* args) { | 1911 void EventSender::TouchMove(gin::Arguments* args) { |
1904 SendCurrentTouchEvent(WebInputEvent::TouchMove, | 1912 SendCurrentTouchEvent(WebInputEvent::TouchMove, |
1905 GetMovedBeyondSlopRegionArg(args)); | 1913 GetMovedBeyondSlopRegionArg(args), |
| 1914 GetUniqueTouchEventId(args)); |
1906 } | 1915 } |
1907 | 1916 |
1908 void EventSender::TouchCancel(gin::Arguments* args) { | 1917 void EventSender::TouchCancel(gin::Arguments* args) { |
1909 SendCurrentTouchEvent(WebInputEvent::TouchCancel, | 1918 SendCurrentTouchEvent(WebInputEvent::TouchCancel, |
1910 GetMovedBeyondSlopRegionArg(args)); | 1919 GetMovedBeyondSlopRegionArg(args), |
| 1920 GetUniqueTouchEventId(args)); |
1911 } | 1921 } |
1912 | 1922 |
1913 void EventSender::TouchEnd(gin::Arguments* args) { | 1923 void EventSender::TouchEnd(gin::Arguments* args) { |
1914 SendCurrentTouchEvent(WebInputEvent::TouchEnd, | 1924 SendCurrentTouchEvent(WebInputEvent::TouchEnd, |
1915 GetMovedBeyondSlopRegionArg(args)); | 1925 GetMovedBeyondSlopRegionArg(args), |
| 1926 GetUniqueTouchEventId(args)); |
1916 } | 1927 } |
1917 | 1928 |
1918 void EventSender::NotifyStartOfTouchScroll() { | 1929 void EventSender::NotifyStartOfTouchScroll() { |
1919 WebTouchEvent event; | 1930 WebTouchEvent event; |
1920 event.type = WebInputEvent::TouchScrollStarted; | 1931 event.type = WebInputEvent::TouchScrollStarted; |
1921 HandleInputEventOnViewOrPopup(event); | 1932 HandleInputEventOnViewOrPopup(event); |
1922 } | 1933 } |
1923 | 1934 |
1924 void EventSender::LeapForward(int milliseconds) { | 1935 void EventSender::LeapForward(int milliseconds) { |
1925 if (is_drag_mode_ && | 1936 if (is_drag_mode_ && |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 double EventSender::GetCurrentEventTimeSec() { | 2172 double EventSender::GetCurrentEventTimeSec() { |
2162 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + | 2173 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + |
2163 time_offset_ms_ / 1000.0; | 2174 time_offset_ms_ / 1000.0; |
2164 } | 2175 } |
2165 | 2176 |
2166 void EventSender::DoLeapForward(int milliseconds) { | 2177 void EventSender::DoLeapForward(int milliseconds) { |
2167 time_offset_ms_ += milliseconds; | 2178 time_offset_ms_ += milliseconds; |
2168 } | 2179 } |
2169 | 2180 |
2170 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, | 2181 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, |
2171 bool movedBeyondSlopRegion) { | 2182 bool movedBeyondSlopRegion, |
| 2183 uint32_t uniqueTouchEventId) { |
2172 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), | 2184 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap), |
2173 touch_points_.size()); | 2185 touch_points_.size()); |
2174 if (force_layout_on_events_) | 2186 if (force_layout_on_events_) |
2175 view()->updateAllLifecyclePhases(); | 2187 view()->updateAllLifecyclePhases(); |
2176 | 2188 |
2177 WebTouchEvent touch_event; | 2189 WebTouchEvent touch_event; |
2178 touch_event.type = type; | 2190 touch_event.type = type; |
2179 touch_event.modifiers = touch_modifiers_; | 2191 touch_event.modifiers = touch_modifiers_; |
2180 touch_event.dispatchType = touch_cancelable_ | 2192 touch_event.dispatchType = touch_cancelable_ |
2181 ? WebInputEvent::Blocking | 2193 ? WebInputEvent::Blocking |
2182 : WebInputEvent::EventNonBlocking; | 2194 : WebInputEvent::EventNonBlocking; |
2183 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); | 2195 touch_event.timeStampSeconds = GetCurrentEventTimeSec(); |
2184 touch_event.movedBeyondSlopRegion = movedBeyondSlopRegion; | 2196 touch_event.movedBeyondSlopRegion = movedBeyondSlopRegion; |
| 2197 touch_event.uniqueTouchEventId = uniqueTouchEventId; |
2185 touch_event.touchesLength = touch_points_.size(); | 2198 touch_event.touchesLength = touch_points_.size(); |
2186 for (size_t i = 0; i < touch_points_.size(); ++i) | 2199 for (size_t i = 0; i < touch_points_.size(); ++i) |
2187 touch_event.touches[i] = touch_points_[i]; | 2200 touch_event.touches[i] = touch_points_[i]; |
2188 HandleInputEventOnViewOrPopup(touch_event); | 2201 HandleInputEventOnViewOrPopup(touch_event); |
2189 | 2202 |
2190 for (size_t i = 0; i < touch_points_.size(); ++i) { | 2203 for (size_t i = 0; i < touch_points_.size(); ++i) { |
2191 WebTouchPoint* touch_point = &touch_points_[i]; | 2204 WebTouchPoint* touch_point = &touch_points_[i]; |
2192 if (touch_point->state == WebTouchPoint::StateReleased | 2205 if (touch_point->state == WebTouchPoint::StateReleased |
2193 || touch_point->state == WebTouchPoint::StateCancelled) { | 2206 || touch_point->state == WebTouchPoint::StateCancelled) { |
2194 touch_points_.erase(touch_points_.begin() + i); | 2207 touch_points_.erase(touch_points_.begin() + i); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 event.y = y; | 2385 event.y = y; |
2373 event.data.showPress.width = width; | 2386 event.data.showPress.width = width; |
2374 event.data.showPress.height = height; | 2387 event.data.showPress.height = height; |
2375 break; | 2388 break; |
2376 } | 2389 } |
2377 case WebInputEvent::GestureTapCancel: | 2390 case WebInputEvent::GestureTapCancel: |
2378 event.x = x; | 2391 event.x = x; |
2379 event.y = y; | 2392 event.y = y; |
2380 break; | 2393 break; |
2381 case WebInputEvent::GestureLongPress: | 2394 case WebInputEvent::GestureLongPress: |
2382 event.x = x; | |
2383 event.y = y; | |
2384 if (!args->PeekNext().IsEmpty()) { | |
2385 float width; | |
2386 if (!args->GetNext(&width)) { | |
2387 args->ThrowError(); | |
2388 return; | |
2389 } | |
2390 event.data.longPress.width = width; | |
2391 if (!args->PeekNext().IsEmpty()) { | |
2392 float height; | |
2393 if (!args->GetNext(&height)) { | |
2394 args->ThrowError(); | |
2395 return; | |
2396 } | |
2397 event.data.longPress.height = height; | |
2398 } | |
2399 } | |
2400 break; | |
2401 case WebInputEvent::GestureLongTap: | 2395 case WebInputEvent::GestureLongTap: |
2402 event.x = x; | 2396 event.x = x; |
2403 event.y = y; | 2397 event.y = y; |
2404 if (!args->PeekNext().IsEmpty()) { | 2398 if (!args->PeekNext().IsEmpty()) { |
2405 float width; | 2399 float width; |
2406 if (!args->GetNext(&width)) { | 2400 if (!args->GetNext(&width)) { |
2407 args->ThrowError(); | 2401 args->ThrowError(); |
2408 return; | 2402 return; |
2409 } | 2403 } |
2410 event.data.longPress.width = width; | 2404 event.data.longPress.width = width; |
(...skipping 24 matching lines...) Expand all Loading... |
2435 return; | 2429 return; |
2436 } | 2430 } |
2437 event.data.twoFingerTap.firstFingerHeight = first_finger_height; | 2431 event.data.twoFingerTap.firstFingerHeight = first_finger_height; |
2438 } | 2432 } |
2439 } | 2433 } |
2440 break; | 2434 break; |
2441 default: | 2435 default: |
2442 NOTREACHED(); | 2436 NOTREACHED(); |
2443 } | 2437 } |
2444 | 2438 |
| 2439 if (!args->PeekNext().IsEmpty()) { |
| 2440 float unique_touch_event_id; |
| 2441 if (!args->GetNext(&unique_touch_event_id)) { |
| 2442 args->ThrowError(); |
| 2443 return; |
| 2444 } |
| 2445 event.uniqueTouchEventId = unique_touch_event_id; |
| 2446 } |
| 2447 |
2445 event.globalX = event.x; | 2448 event.globalX = event.x; |
2446 event.globalY = event.y; | 2449 event.globalY = event.y; |
2447 event.timeStampSeconds = GetCurrentEventTimeSec(); | 2450 event.timeStampSeconds = GetCurrentEventTimeSec(); |
2448 | 2451 |
2449 if (force_layout_on_events_) | 2452 if (force_layout_on_events_) |
2450 view()->updateAllLifecyclePhases(); | 2453 view()->updateAllLifecyclePhases(); |
2451 | 2454 |
2452 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); | 2455 WebInputEventResult result = HandleInputEventOnViewOrPopup(event); |
2453 | 2456 |
2454 // Long press might start a drag drop session. Complete it if so. | 2457 // Long press might start a drag drop session. Complete it if so. |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 | 2793 |
2791 const blink::WebView* EventSender::view() const { | 2794 const blink::WebView* EventSender::view() const { |
2792 return web_test_proxy_base_->web_view(); | 2795 return web_test_proxy_base_->web_view(); |
2793 } | 2796 } |
2794 | 2797 |
2795 blink::WebView* EventSender::view() { | 2798 blink::WebView* EventSender::view() { |
2796 return web_test_proxy_base_->web_view(); | 2799 return web_test_proxy_base_->web_view(); |
2797 } | 2800 } |
2798 | 2801 |
2799 } // namespace test_runner | 2802 } // namespace test_runner |
OLD | NEW |