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 "content/common/input/web_input_event_traits.h" | 5 #include "content/common/input/web_input_event_traits.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2); | 117 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2); |
118 touch0.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1); | 118 touch0.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1); |
119 touch1.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1); | 119 touch1.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1); |
120 touch0.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0); | 120 touch0.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0); |
121 touch1.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0); | 121 touch1.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0); |
122 WebInputEventTraits::Coalesce(touch0, &touch1); | 122 WebInputEventTraits::Coalesce(touch0, &touch1); |
123 ASSERT_EQ(1, touch1.touches[0].id); | 123 ASSERT_EQ(1, touch1.touches[0].id); |
124 ASSERT_EQ(0, touch1.touches[1].id); | 124 ASSERT_EQ(0, touch1.touches[1].id); |
125 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); | 125 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); |
126 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[1].state); | 126 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[1].state); |
| 127 |
| 128 // Touch moves with different dispatchTypes coalesce. |
| 129 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); |
| 130 touch0.dispatchType = WebInputEvent::DispatchType::Blocking; |
| 131 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); |
| 132 touch1.dispatchType = WebInputEvent::DispatchType::EventNonBlocking; |
| 133 touch0.touches[0] = touch1.touches[1] = |
| 134 CreateTouchPoint(WebTouchPoint::StateMoved, 1); |
| 135 touch0.touches[1] = touch1.touches[0] = |
| 136 CreateTouchPoint(WebTouchPoint::StateMoved, 0); |
| 137 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); |
| 138 WebInputEventTraits::Coalesce(touch0, &touch1); |
| 139 ASSERT_EQ(WebInputEvent::DispatchType::Blocking, touch1.dispatchType); |
| 140 |
| 141 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); |
| 142 touch0.dispatchType = |
| 143 WebInputEvent::DispatchType::ListenersForcedNonBlockingPassive; |
| 144 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); |
| 145 touch1.dispatchType = |
| 146 WebInputEvent::DispatchType::ListenersNonBlockingPassive; |
| 147 touch0.touches[0] = touch1.touches[1] = |
| 148 CreateTouchPoint(WebTouchPoint::StateMoved, 1); |
| 149 touch0.touches[1] = touch1.touches[0] = |
| 150 CreateTouchPoint(WebTouchPoint::StateMoved, 0); |
| 151 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); |
| 152 WebInputEventTraits::Coalesce(touch0, &touch1); |
| 153 ASSERT_EQ(WebInputEvent::DispatchType::ListenersNonBlockingPassive, |
| 154 touch1.dispatchType); |
127 } | 155 } |
128 | 156 |
129 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) { | 157 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) { |
130 WebGestureEvent pinch0 = | 158 WebGestureEvent pinch0 = |
131 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); | 159 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); |
132 WebGestureEvent pinch1 = | 160 WebGestureEvent pinch1 = |
133 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2); | 161 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2); |
134 | 162 |
135 // Only GesturePinchUpdate's coalesce. | 163 // Only GesturePinchUpdate's coalesce. |
136 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); | 164 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 WebGestureEvent gesture = | 255 WebGestureEvent gesture = |
228 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); | 256 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); |
229 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty()); | 257 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty()); |
230 | 258 |
231 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart); | 259 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart); |
232 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty()); | 260 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty()); |
233 } | 261 } |
234 | 262 |
235 } // namespace | 263 } // namespace |
236 } // namespace content | 264 } // namespace content |
OLD | NEW |