| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 68 }; |
| 69 static const InputHandlerProxyTestType test_types[] = { | 69 static const InputHandlerProxyTestType test_types[] = { |
| 70 ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, | 70 ROOT_SCROLL_NORMAL_HANDLER, ROOT_SCROLL_SYNCHRONOUS_HANDLER, |
| 71 CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER}; | 71 CHILD_SCROLL_NORMAL_HANDLER, CHILD_SCROLL_SYNCHRONOUS_HANDLER}; |
| 72 | 72 |
| 73 double InSecondsF(const base::TimeTicks& time) { | 73 double InSecondsF(const base::TimeTicks& time) { |
| 74 return (time - base::TimeTicks()).InSecondsF(); | 74 return (time - base::TimeTicks()).InSecondsF(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool WheelEventsMatch(const WebInputEvent& lhs, const WebInputEvent& rhs) { | 77 bool WheelEventsMatch(const WebInputEvent& lhs, const WebInputEvent& rhs) { |
| 78 if (lhs.size == rhs.size && lhs.type == rhs.type && | 78 if (lhs.size() == rhs.size() && lhs.type() == rhs.type() && |
| 79 lhs.type == WebInputEvent::MouseWheel) { | 79 lhs.type() == WebInputEvent::MouseWheel) { |
| 80 WebMouseWheelEvent rhs_timestamped = | 80 WebMouseWheelEvent rhs_timestamped = |
| 81 static_cast<const WebMouseWheelEvent&>(rhs); | 81 static_cast<const WebMouseWheelEvent&>(rhs); |
| 82 rhs_timestamped.timeStampSeconds = lhs.timeStampSeconds; | 82 rhs_timestamped.setTimeStampSeconds(lhs.timeStampSeconds()); |
| 83 return memcmp(&rhs_timestamped, &lhs, rhs.size) == 0; | 83 return memcmp(&rhs_timestamped, &lhs, rhs.size()) == 0; |
| 84 } | 84 } |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 | 87 |
| 88 MATCHER_P(WheelEventsMatch, expected, "") { | 88 MATCHER_P(WheelEventsMatch, expected, "") { |
| 89 return WheelEventsMatch(arg, expected); | 89 return WheelEventsMatch(arg, expected); |
| 90 } | 90 } |
| 91 | 91 |
| 92 WebGestureEvent CreateFling(base::TimeTicks timestamp, | 92 WebGestureEvent CreateFling(base::TimeTicks timestamp, |
| 93 WebGestureDevice source_device, | 93 WebGestureDevice source_device, |
| (...skipping 3108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3202 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 10.0f, 1, 10); | 3202 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 10.0f, 1, 10); |
| 3203 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -30); | 3203 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -30); |
| 3204 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.25f, 3, 30); | 3204 HandleGestureEvent(WebInputEvent::GesturePinchUpdate, 0.25f, 3, 30); |
| 3205 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10); | 3205 HandleGestureEvent(WebInputEvent::GestureScrollUpdate, -10); |
| 3206 HandleGestureEvent(WebInputEvent::GesturePinchEnd); | 3206 HandleGestureEvent(WebInputEvent::GesturePinchEnd); |
| 3207 | 3207 |
| 3208 // Only the first GSB was dispatched. | 3208 // Only the first GSB was dispatched. |
| 3209 EXPECT_EQ(7ul, event_queue().size()); | 3209 EXPECT_EQ(7ul, event_queue().size()); |
| 3210 EXPECT_EQ(1ul, event_disposition_recorder_.size()); | 3210 EXPECT_EQ(1ul, event_disposition_recorder_.size()); |
| 3211 | 3211 |
| 3212 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, event_queue()[0]->event().type); | 3212 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, |
| 3213 event_queue()[0]->event().type()); |
| 3213 EXPECT_EQ( | 3214 EXPECT_EQ( |
| 3214 -35, | 3215 -35, |
| 3215 ToWebGestureEvent(event_queue()[0]->event()).data.scrollUpdate.deltaY); | 3216 ToWebGestureEvent(event_queue()[0]->event()).data.scrollUpdate.deltaY); |
| 3216 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, event_queue()[1]->event().type); | 3217 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, |
| 3218 event_queue()[1]->event().type()); |
| 3217 EXPECT_EQ( | 3219 EXPECT_EQ( |
| 3218 2.0f, | 3220 2.0f, |
| 3219 ToWebGestureEvent(event_queue()[1]->event()).data.pinchUpdate.scale); | 3221 ToWebGestureEvent(event_queue()[1]->event()).data.pinchUpdate.scale); |
| 3220 EXPECT_EQ(WebInputEvent::GestureScrollEnd, event_queue()[2]->event().type); | 3222 EXPECT_EQ(WebInputEvent::GestureScrollEnd, event_queue()[2]->event().type()); |
| 3221 EXPECT_EQ(WebInputEvent::GesturePinchBegin, event_queue()[3]->event().type); | 3223 EXPECT_EQ(WebInputEvent::GesturePinchBegin, event_queue()[3]->event().type()); |
| 3222 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, event_queue()[4]->event().type); | 3224 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, |
| 3225 event_queue()[4]->event().type()); |
| 3223 EXPECT_EQ( | 3226 EXPECT_EQ( |
| 3224 -85, | 3227 -85, |
| 3225 ToWebGestureEvent(event_queue()[4]->event()).data.scrollUpdate.deltaY); | 3228 ToWebGestureEvent(event_queue()[4]->event()).data.scrollUpdate.deltaY); |
| 3226 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, event_queue()[5]->event().type); | 3229 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, |
| 3230 event_queue()[5]->event().type()); |
| 3227 EXPECT_EQ( | 3231 EXPECT_EQ( |
| 3228 0.5f, | 3232 0.5f, |
| 3229 ToWebGestureEvent(event_queue()[5]->event()).data.pinchUpdate.scale); | 3233 ToWebGestureEvent(event_queue()[5]->event()).data.pinchUpdate.scale); |
| 3230 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type); | 3234 EXPECT_EQ(WebInputEvent::GesturePinchEnd, event_queue()[6]->event().type()); |
| 3231 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); | 3235 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 3232 } | 3236 } |
| 3233 | 3237 |
| 3234 INSTANTIATE_TEST_CASE_P(AnimateInput, | 3238 INSTANTIATE_TEST_CASE_P(AnimateInput, |
| 3235 InputHandlerProxyTest, | 3239 InputHandlerProxyTest, |
| 3236 testing::ValuesIn(test_types)); | 3240 testing::ValuesIn(test_types)); |
| 3237 | 3241 |
| 3238 } // namespace test | 3242 } // namespace test |
| 3239 } // namespace ui | 3243 } // namespace ui |
| OLD | NEW |