OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); | 132 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type); |
133 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state)
; | 133 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state)
; |
134 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo
sition.x); | 134 EXPECT_FLOAT_EQ(p0.screenPosition.x, webTouchBuilder.touches[0].screenPo
sition.x); |
135 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo
sition.y); | 135 EXPECT_FLOAT_EQ(p0.screenPosition.y, webTouchBuilder.touches[0].screenPo
sition.y); |
136 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); | 136 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); |
137 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); | 137 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); |
138 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); | 138 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); |
139 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); | 139 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); |
140 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng
le); | 140 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAng
le); |
141 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); | 141 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); |
| 142 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
142 } | 143 } |
143 | 144 |
| 145 // Test cancelable touchstart. |
| 146 { |
| 147 TouchList* touchList = TouchList::create(); |
| 148 touchList->append(touch0); |
| 149 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL
ist, EventTypeNames::touchstart, domWindow, PlatformEvent::NoModifiers, true, fa
lse, 0); |
| 150 |
| 151 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
| 152 EXPECT_EQ(WebInputEvent::Blocking, webTouchBuilder.dispatchType); |
| 153 } |
| 154 |
| 155 |
144 // Test touchmove. | 156 // Test touchmove. |
145 { | 157 { |
146 TouchList* activeTouchList = TouchList::create(); | 158 TouchList* activeTouchList = TouchList::create(); |
147 TouchList* movedTouchList = TouchList::create(); | 159 TouchList* movedTouchList = TouchList::create(); |
148 activeTouchList->append(touch0); | 160 activeTouchList->append(touch0); |
149 activeTouchList->append(touch1); | 161 activeTouchList->append(touch1); |
150 movedTouchList->append(touch0); | 162 movedTouchList->append(touch0); |
151 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod
ifiers, false, false, 0); | 163 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod
ifiers, false, false, 0); |
152 | 164 |
153 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 165 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
154 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 166 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
155 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); | 167 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); |
156 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); | 168 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); |
157 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); | 169 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].sta
te); |
158 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 170 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
159 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 171 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 172 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
160 } | 173 } |
161 | 174 |
162 // Test touchmove, different point yields same ordering. | 175 // Test touchmove, different point yields same ordering. |
163 { | 176 { |
164 TouchList* activeTouchList = TouchList::create(); | 177 TouchList* activeTouchList = TouchList::create(); |
165 TouchList* movedTouchList = TouchList::create(); | 178 TouchList* movedTouchList = TouchList::create(); |
166 activeTouchList->append(touch0); | 179 activeTouchList->append(touch0); |
167 activeTouchList->append(touch1); | 180 activeTouchList->append(touch1); |
168 movedTouchList->append(touch1); | 181 movedTouchList->append(touch1); |
169 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod
ifiers, false, false, 0); | 182 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, movedTouchList, EventTypeNames::touchmove, domWindow, PlatformEvent::NoMod
ifiers, false, false, 0); |
170 | 183 |
171 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 184 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
172 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 185 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
173 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); | 186 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type); |
174 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta
te); | 187 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta
te); |
175 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); | 188 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); |
176 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 189 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
177 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 190 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 191 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
178 } | 192 } |
179 | 193 |
180 // Test touchend. | 194 // Test touchend. |
181 { | 195 { |
182 TouchList* activeTouchList = TouchList::create(); | 196 TouchList* activeTouchList = TouchList::create(); |
183 TouchList* releasedTouchList = TouchList::create(); | 197 TouchList* releasedTouchList = TouchList::create(); |
184 activeTouchList->append(touch0); | 198 activeTouchList->append(touch0); |
185 releasedTouchList->append(touch1); | 199 releasedTouchList->append(touch1); |
186 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, releasedTouchList, EventTypeNames::touchend, domWindow, PlatformEvent::NoM
odifiers, false, false, 0); | 200 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, releasedTouchList, EventTypeNames::touchend, domWindow, PlatformEvent::NoM
odifiers, false, false, 0); |
187 | 201 |
188 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 202 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
189 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 203 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
190 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); | 204 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type); |
191 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta
te); | 205 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].sta
te); |
192 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state
); | 206 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state
); |
193 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 207 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
194 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 208 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 209 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
195 } | 210 } |
196 | 211 |
197 // Test touchcancel. | 212 // Test touchcancel. |
198 { | 213 { |
199 TouchList* activeTouchList = TouchList::create(); | 214 TouchList* activeTouchList = TouchList::create(); |
200 TouchList* cancelledTouchList = TouchList::create(); | 215 TouchList* cancelledTouchList = TouchList::create(); |
201 cancelledTouchList->append(touch0); | 216 cancelledTouchList->append(touch0); |
202 cancelledTouchList->append(touch1); | 217 cancelledTouchList->append(touch1); |
203 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, cancelledTouchList, EventTypeNames::touchcancel, domWindow, PlatformEvent:
:NoModifiers, false, false, 0); | 218 TouchEvent* touchEvent = TouchEvent::create(activeTouchList, activeTouch
List, cancelledTouchList, EventTypeNames::touchcancel, domWindow, PlatformEvent:
:NoModifiers, false, false, 0); |
204 | 219 |
205 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 220 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
206 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | 221 ASSERT_EQ(2u, webTouchBuilder.touchesLength); |
207 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); | 222 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type); |
208 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat
e); | 223 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].stat
e); |
209 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat
e); | 224 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].stat
e); |
210 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | 225 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); |
211 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | 226 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); |
| 227 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
212 } | 228 } |
213 | 229 |
214 // Test max point limit. | 230 // Test max point limit. |
215 { | 231 { |
216 TouchList* touchList = TouchList::create(); | 232 TouchList* touchList = TouchList::create(); |
217 TouchList* changedTouchList = TouchList::create(); | 233 TouchList* changedTouchList = TouchList::create(); |
218 for (int i = 0; i <= static_cast<int>(WebTouchEvent::touchesLengthCap) *
2; ++i) { | 234 for (int i = 0; i <= static_cast<int>(WebTouchEvent::touchesLengthCap) *
2; ++i) { |
219 Touch* touch = Touch::create(toLocalFrame(webViewImpl->page()->mainF
rame()), document, i, p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.r
adiusY), p0.rotationAngle, p0.force, String()); | 235 Touch* touch = Touch::create(toLocalFrame(webViewImpl->page()->mainF
rame()), document, i, p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.r
adiusY), p0.rotationAngle, p0.force, String()); |
220 touchList->append(touch); | 236 touchList->append(touch); |
221 changedTouchList->append(touch); | 237 changedTouchList->append(touch); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL
ist, EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, fa
lse, 0); | 486 TouchEvent* touchEvent = TouchEvent::create(touchList, touchList, touchL
ist, EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, fa
lse, 0); |
471 | 487 |
472 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | 488 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); |
473 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | 489 ASSERT_EQ(1u, webTouchBuilder.touchesLength); |
474 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); | 490 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); |
475 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); | 491 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); |
476 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); | 492 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); |
477 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); | 493 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); |
478 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); | 494 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); |
479 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); | 495 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); |
480 EXPECT_FALSE(webTouchBuilder.cancelable); | 496 EXPECT_EQ(WebInputEvent::NonBlocking, webTouchBuilder.dispatchType); |
481 } | 497 } |
482 } | 498 } |
483 | 499 |
484 TEST(WebInputEventConversionTest, InputEventsTransform) | 500 TEST(WebInputEventConversionTest, InputEventsTransform) |
485 { | 501 { |
486 const std::string baseURL("http://www.test2.com/"); | 502 const std::string baseURL("http://www.test2.com/"); |
487 const std::string fileName("fixed_layout.html"); | 503 const std::string fileName("fixed_layout.html"); |
488 | 504 |
489 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 505 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
490 FrameTestHelpers::WebViewHelper webViewHelper; | 506 FrameTestHelpers::WebViewHelper webViewHelper; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 EXPECT_EQ(5, platformGestureBuilder.position().y()); | 1073 EXPECT_EQ(5, platformGestureBuilder.position().y()); |
1058 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 1074 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); |
1059 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | 1075 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); |
1060 EXPECT_FALSE(platformGestureBuilder.inertial()); | 1076 EXPECT_FALSE(platformGestureBuilder.inertial()); |
1061 EXPECT_TRUE(platformGestureBuilder.synthetic()); | 1077 EXPECT_TRUE(platformGestureBuilder.synthetic()); |
1062 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); | 1078 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); |
1063 } | 1079 } |
1064 } | 1080 } |
1065 | 1081 |
1066 } // namespace blink | 1082 } // namespace blink |
OLD | NEW |