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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || | 95 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || |
96 modifiers & WebInputEvent::IsRight); | 96 modifiers & WebInputEvent::IsRight); |
97 } | 97 } |
98 | 98 |
99 TEST(WebInputEventConversionTest, WebMouseEventBuilder) { | 99 TEST(WebInputEventConversionTest, WebMouseEventBuilder) { |
100 TouchEvent* event = TouchEvent::create(); | 100 TouchEvent* event = TouchEvent::create(); |
101 WebMouseEventBuilder mouse(0, 0, *event); | 101 WebMouseEventBuilder mouse(0, 0, *event); |
102 EXPECT_EQ(WebInputEvent::Undefined, mouse.type()); | 102 EXPECT_EQ(WebInputEvent::Undefined, mouse.type()); |
103 } | 103 } |
104 | 104 |
105 TEST(WebInputEventConversionTest, WebTouchEventBuilder) { | |
106 const std::string baseURL("http://www.test0.com/"); | |
107 const std::string fileName("fixed_layout.html"); | |
108 | |
109 URLTestHelpers::registerMockedURLFromBaseURL( | |
110 WebString::fromUTF8(baseURL.c_str()), | |
111 WebString::fromUTF8("fixed_layout.html")); | |
112 FrameTestHelpers::WebViewHelper webViewHelper; | |
113 WebViewImpl* webViewImpl = | |
114 webViewHelper.initializeAndLoad(baseURL + fileName, true); | |
115 int pageWidth = 640; | |
116 int pageHeight = 480; | |
117 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
118 webViewImpl->updateAllLifecyclePhases(); | |
119 | |
120 Document* document = | |
121 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | |
122 LocalDOMWindow* domWindow = document->domWindow(); | |
123 LayoutViewItem documentLayoutView = document->layoutViewItem(); | |
124 | |
125 WebTouchPoint p0, p1; | |
126 p0.id = 1; | |
127 p1.id = 2; | |
128 p0.screenPosition = WebFloatPoint(100.f, 50.f); | |
129 p1.screenPosition = WebFloatPoint(150.f, 25.f); | |
130 p0.position = WebFloatPoint(10.f, 10.f); | |
131 p1.position = WebFloatPoint(5.f, 5.f); | |
132 p0.radiusX = p1.radiusY = 10.f; | |
133 p0.radiusY = p1.radiusX = 5.f; | |
134 p0.rotationAngle = p1.rotationAngle = 1.f; | |
135 p0.force = p1.force = 25.f; | |
136 | |
137 Touch* touch0 = Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), | |
138 document, p0.id, p0.screenPosition, p0.position, | |
139 FloatSize(p0.radiusX, p0.radiusY), | |
140 p0.rotationAngle, p0.force, String()); | |
141 Touch* touch1 = Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), | |
142 document, p1.id, p1.screenPosition, p1.position, | |
143 FloatSize(p1.radiusX, p1.radiusY), | |
144 p1.rotationAngle, p1.force, String()); | |
145 | |
146 // Test touchstart. | |
147 { | |
148 TouchList* touchList = TouchList::create(); | |
149 touchList->append(touch0); | |
150 TouchEvent* touchEvent = TouchEvent::create( | |
151 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, | |
152 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), | |
153 TouchActionAuto, WebPointerProperties::PointerType::Touch); | |
154 | |
155 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
156 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | |
157 EXPECT_EQ(WebInputEvent::TouchStart, webTouchBuilder.type()); | |
158 EXPECT_EQ(WebTouchPoint::StatePressed, webTouchBuilder.touches[0].state); | |
159 EXPECT_FLOAT_EQ(p0.screenPosition.x, | |
160 webTouchBuilder.touches[0].screenPosition.x); | |
161 EXPECT_FLOAT_EQ(p0.screenPosition.y, | |
162 webTouchBuilder.touches[0].screenPosition.y); | |
163 EXPECT_FLOAT_EQ(p0.position.x, webTouchBuilder.touches[0].position.x); | |
164 EXPECT_FLOAT_EQ(p0.position.y, webTouchBuilder.touches[0].position.y); | |
165 EXPECT_FLOAT_EQ(p0.radiusX, webTouchBuilder.touches[0].radiusX); | |
166 EXPECT_FLOAT_EQ(p0.radiusY, webTouchBuilder.touches[0].radiusY); | |
167 EXPECT_FLOAT_EQ(p0.rotationAngle, webTouchBuilder.touches[0].rotationAngle); | |
168 EXPECT_FLOAT_EQ(p0.force, webTouchBuilder.touches[0].force); | |
169 EXPECT_EQ(WebPointerProperties::PointerType::Touch, | |
170 webTouchBuilder.touches[0].pointerType); | |
171 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
172 } | |
173 | |
174 // Test cancelable touchstart. | |
175 { | |
176 TouchList* touchList = TouchList::create(); | |
177 touchList->append(touch0); | |
178 TouchEvent* touchEvent = TouchEvent::create( | |
179 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, | |
180 PlatformEvent::NoModifiers, true, false, true, TimeTicks(), | |
181 TouchActionAuto, WebPointerProperties::PointerType::Touch); | |
182 | |
183 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
184 EXPECT_EQ(WebInputEvent::Blocking, webTouchBuilder.dispatchType); | |
185 } | |
186 | |
187 // Test touchmove. | |
188 { | |
189 TouchList* activeTouchList = TouchList::create(); | |
190 TouchList* movedTouchList = TouchList::create(); | |
191 activeTouchList->append(touch0); | |
192 activeTouchList->append(touch1); | |
193 movedTouchList->append(touch0); | |
194 TouchEvent* touchEvent = TouchEvent::create( | |
195 activeTouchList, activeTouchList, movedTouchList, | |
196 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, | |
197 false, true, TimeTicks(), TouchActionAuto, | |
198 WebPointerProperties::PointerType::Touch); | |
199 | |
200 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
201 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | |
202 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type()); | |
203 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[0].state); | |
204 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[1].state); | |
205 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | |
206 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | |
207 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
208 } | |
209 | |
210 // Test touchmove, different point yields same ordering. | |
211 { | |
212 TouchList* activeTouchList = TouchList::create(); | |
213 TouchList* movedTouchList = TouchList::create(); | |
214 activeTouchList->append(touch0); | |
215 activeTouchList->append(touch1); | |
216 movedTouchList->append(touch1); | |
217 TouchEvent* touchEvent = TouchEvent::create( | |
218 activeTouchList, activeTouchList, movedTouchList, | |
219 EventTypeNames::touchmove, domWindow, PlatformEvent::NoModifiers, false, | |
220 false, true, TimeTicks(), TouchActionAuto, | |
221 WebPointerProperties::PointerType::Touch); | |
222 | |
223 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
224 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | |
225 EXPECT_EQ(WebInputEvent::TouchMove, webTouchBuilder.type()); | |
226 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); | |
227 EXPECT_EQ(WebTouchPoint::StateMoved, webTouchBuilder.touches[1].state); | |
228 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | |
229 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | |
230 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
231 } | |
232 | |
233 // Test touchend. | |
234 { | |
235 TouchList* activeTouchList = TouchList::create(); | |
236 TouchList* releasedTouchList = TouchList::create(); | |
237 activeTouchList->append(touch0); | |
238 releasedTouchList->append(touch1); | |
239 TouchEvent* touchEvent = TouchEvent::create( | |
240 activeTouchList, activeTouchList, releasedTouchList, | |
241 EventTypeNames::touchend, domWindow, PlatformEvent::NoModifiers, false, | |
242 false, false, TimeTicks(), TouchActionAuto, | |
243 WebPointerProperties::PointerType::Touch); | |
244 | |
245 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
246 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | |
247 EXPECT_EQ(WebInputEvent::TouchEnd, webTouchBuilder.type()); | |
248 EXPECT_EQ(WebTouchPoint::StateStationary, webTouchBuilder.touches[0].state); | |
249 EXPECT_EQ(WebTouchPoint::StateReleased, webTouchBuilder.touches[1].state); | |
250 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | |
251 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | |
252 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
253 } | |
254 | |
255 // Test touchcancel. | |
256 { | |
257 TouchList* activeTouchList = TouchList::create(); | |
258 TouchList* cancelledTouchList = TouchList::create(); | |
259 cancelledTouchList->append(touch0); | |
260 cancelledTouchList->append(touch1); | |
261 TouchEvent* touchEvent = TouchEvent::create( | |
262 activeTouchList, activeTouchList, cancelledTouchList, | |
263 EventTypeNames::touchcancel, domWindow, PlatformEvent::NoModifiers, | |
264 false, false, false, TimeTicks(), TouchActionAuto, | |
265 WebPointerProperties::PointerType::Touch); | |
266 | |
267 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
268 ASSERT_EQ(2u, webTouchBuilder.touchesLength); | |
269 EXPECT_EQ(WebInputEvent::TouchCancel, webTouchBuilder.type()); | |
270 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[0].state); | |
271 EXPECT_EQ(WebTouchPoint::StateCancelled, webTouchBuilder.touches[1].state); | |
272 EXPECT_EQ(p0.id, webTouchBuilder.touches[0].id); | |
273 EXPECT_EQ(p1.id, webTouchBuilder.touches[1].id); | |
274 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
275 } | |
276 | |
277 // Test max point limit. | |
278 { | |
279 TouchList* touchList = TouchList::create(); | |
280 TouchList* changedTouchList = TouchList::create(); | |
281 for (int i = 0; i <= static_cast<int>(WebTouchEvent::kTouchesLengthCap) * 2; | |
282 ++i) { | |
283 Touch* touch = Touch::create( | |
284 toLocalFrame(webViewImpl->page()->mainFrame()), document, i, | |
285 p0.screenPosition, p0.position, FloatSize(p0.radiusX, p0.radiusY), | |
286 p0.rotationAngle, p0.force, String()); | |
287 touchList->append(touch); | |
288 changedTouchList->append(touch); | |
289 } | |
290 TouchEvent* touchEvent = TouchEvent::create( | |
291 touchList, touchList, touchList, EventTypeNames::touchstart, domWindow, | |
292 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), | |
293 TouchActionAuto, WebPointerProperties::PointerType::Touch); | |
294 | |
295 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
296 ASSERT_EQ(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), | |
297 webTouchBuilder.touchesLength); | |
298 } | |
299 } | |
300 | |
301 TEST(WebInputEventConversionTest, InputEventsScaling) { | 105 TEST(WebInputEventConversionTest, InputEventsScaling) { |
302 const std::string baseURL("http://www.test1.com/"); | 106 const std::string baseURL("http://www.test1.com/"); |
303 const std::string fileName("fixed_layout.html"); | 107 const std::string fileName("fixed_layout.html"); |
304 | 108 |
305 URLTestHelpers::registerMockedURLFromBaseURL( | 109 URLTestHelpers::registerMockedURLFromBaseURL( |
306 WebString::fromUTF8(baseURL.c_str()), | 110 WebString::fromUTF8(baseURL.c_str()), |
307 WebString::fromUTF8("fixed_layout.html")); | 111 WebString::fromUTF8("fixed_layout.html")); |
308 FrameTestHelpers::WebViewHelper webViewHelper; | 112 FrameTestHelpers::WebViewHelper webViewHelper; |
309 WebViewImpl* webViewImpl = | 113 WebViewImpl* webViewImpl = |
310 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 114 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 webTouchEvent.touches[0].radiusX = 10.6f; | 309 webTouchEvent.touches[0].radiusX = 10.6f; |
506 webTouchEvent.touches[0].radiusY = 10.4f; | 310 webTouchEvent.touches[0].radiusY = 10.4f; |
507 | 311 |
508 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); | 312 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); |
509 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); | 313 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); |
510 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); | 314 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); |
511 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); | 315 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); |
512 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].radiusX); | 316 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].radiusX); |
513 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].radiusY); | 317 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].radiusY); |
514 | 318 |
515 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 319 WebTouchEvent transformedEvent = |
516 EXPECT_FLOAT_EQ(10.6f, | 320 TransformWebTouchEvent(view, webTouchEvent); |
517 platformTouchBuilder.touchPoints()[0].screenPos().x()); | 321 WebTouchPoint transformedPoint = transformedEvent.touchPointInRootFrame(0); |
518 EXPECT_FLOAT_EQ(10.4f, | 322 EXPECT_FLOAT_EQ(10.6f, transformedPoint.screenPosition.x); |
519 platformTouchBuilder.touchPoints()[0].screenPos().y()); | 323 EXPECT_FLOAT_EQ(10.4f, transformedPoint.screenPosition.y); |
520 EXPECT_FLOAT_EQ(5.3f, platformTouchBuilder.touchPoints()[0].pos().x()); | 324 EXPECT_FLOAT_EQ(5.3f, transformedPoint.position.x); |
521 EXPECT_FLOAT_EQ(5.2f, platformTouchBuilder.touchPoints()[0].pos().y()); | 325 EXPECT_FLOAT_EQ(5.2f, transformedPoint.position.y); |
522 EXPECT_FLOAT_EQ(5.3f, | 326 EXPECT_FLOAT_EQ(5.3f, transformedPoint.radiusX); |
523 platformTouchBuilder.touchPoints()[0].radius().width()); | 327 EXPECT_FLOAT_EQ(5.2f, transformedPoint.radiusY); |
524 EXPECT_FLOAT_EQ(5.2f, | |
525 platformTouchBuilder.touchPoints()[0].radius().height()); | |
526 } | 328 } |
527 | 329 |
528 // Reverse builders should *not* go back to physical pixels, as they are used | 330 // Reverse builders should *not* go back to physical pixels, as they are used |
529 // for plugins which expect CSS pixel coordinates. | 331 // for plugins which expect CSS pixel coordinates. |
530 { | 332 { |
531 PlatformMouseEvent platformMouseEvent( | 333 PlatformMouseEvent platformMouseEvent( |
532 IntPoint(10, 10), IntPoint(10, 10), WebPointerProperties::Button::Left, | 334 IntPoint(10, 10), IntPoint(10, 10), WebPointerProperties::Button::Left, |
533 PlatformEvent::MouseMoved, 1, PlatformEvent::NoModifiers, | 335 PlatformEvent::MouseMoved, 1, PlatformEvent::NoModifiers, |
534 PlatformMouseEvent::RealOrIndistinguishable, TimeTicks()); | 336 PlatformMouseEvent::RealOrIndistinguishable, TimeTicks()); |
535 MouseEvent* mouseEvent = MouseEvent::create( | 337 MouseEvent* mouseEvent = MouseEvent::create( |
(...skipping 12 matching lines...) Expand all Loading... |
548 PlatformMouseEvent platformMouseEvent( | 350 PlatformMouseEvent platformMouseEvent( |
549 IntPoint(10, 10), IntPoint(10, 10), | 351 IntPoint(10, 10), IntPoint(10, 10), |
550 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, | 352 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, |
551 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 353 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
552 TimeTicks()); | 354 TimeTicks()); |
553 MouseEvent* mouseEvent = MouseEvent::create( | 355 MouseEvent* mouseEvent = MouseEvent::create( |
554 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); | 356 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); |
555 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); | 357 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); |
556 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); | 358 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); |
557 } | 359 } |
558 | |
559 { | |
560 Touch* touch = | |
561 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, | |
562 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), | |
563 FloatSize(4, 4.5), 0, 0, String()); | |
564 TouchList* touchList = TouchList::create(); | |
565 touchList->append(touch); | |
566 TouchEvent* touchEvent = TouchEvent::create( | |
567 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, | |
568 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), | |
569 TouchActionAuto, WebPointerProperties::PointerType::Touch); | |
570 | |
571 WebTouchEventBuilder webTouchBuilder(documentLayoutView, *touchEvent); | |
572 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | |
573 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); | |
574 EXPECT_FLOAT_EQ(9.5, webTouchBuilder.touches[0].screenPosition.y); | |
575 EXPECT_FLOAT_EQ(3.5, webTouchBuilder.touches[0].position.x); | |
576 EXPECT_FLOAT_EQ(2, webTouchBuilder.touches[0].position.y); | |
577 EXPECT_FLOAT_EQ(4, webTouchBuilder.touches[0].radiusX); | |
578 EXPECT_FLOAT_EQ(4.5, webTouchBuilder.touches[0].radiusY); | |
579 EXPECT_EQ(WebInputEvent::EventNonBlocking, webTouchBuilder.dispatchType); | |
580 } | |
581 } | 360 } |
582 | 361 |
583 TEST(WebInputEventConversionTest, InputEventsTransform) { | 362 TEST(WebInputEventConversionTest, InputEventsTransform) { |
584 const std::string baseURL("http://www.test2.com/"); | 363 const std::string baseURL("http://www.test2.com/"); |
585 const std::string fileName("fixed_layout.html"); | 364 const std::string fileName("fixed_layout.html"); |
586 | 365 |
587 URLTestHelpers::registerMockedURLFromBaseURL( | 366 URLTestHelpers::registerMockedURLFromBaseURL( |
588 WebString::fromUTF8(baseURL.c_str()), | 367 WebString::fromUTF8(baseURL.c_str()), |
589 WebString::fromUTF8("fixed_layout.html")); | 368 WebString::fromUTF8("fixed_layout.html")); |
590 FrameTestHelpers::WebViewHelper webViewHelper; | 369 FrameTestHelpers::WebViewHelper webViewHelper; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 WebInputEvent::TimeStampForTesting); | 565 WebInputEvent::TimeStampForTesting); |
787 webTouchEvent.touchesLength = 1; | 566 webTouchEvent.touchesLength = 1; |
788 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 567 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
789 webTouchEvent.touches[0].screenPosition.x = 100; | 568 webTouchEvent.touches[0].screenPosition.x = 100; |
790 webTouchEvent.touches[0].screenPosition.y = 110; | 569 webTouchEvent.touches[0].screenPosition.y = 110; |
791 webTouchEvent.touches[0].position.x = 100; | 570 webTouchEvent.touches[0].position.x = 100; |
792 webTouchEvent.touches[0].position.y = 110; | 571 webTouchEvent.touches[0].position.y = 110; |
793 webTouchEvent.touches[0].radiusX = 30; | 572 webTouchEvent.touches[0].radiusX = 30; |
794 webTouchEvent.touches[0].radiusY = 30; | 573 webTouchEvent.touches[0].radiusY = 30; |
795 | 574 |
796 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 575 WebTouchEvent transformedEvent = |
797 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); | 576 TransformWebTouchEvent(view, webTouchEvent); |
798 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); | 577 |
799 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); | 578 WebTouchPoint transformedPoint = transformedEvent.touchPointInRootFrame(0); |
800 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); | 579 EXPECT_FLOAT_EQ(100, transformedPoint.screenPosition.x); |
801 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width()); | 580 EXPECT_FLOAT_EQ(110, transformedPoint.screenPosition.y); |
802 EXPECT_FLOAT_EQ(10, | 581 EXPECT_FLOAT_EQ(30, transformedPoint.position.x); |
803 platformTouchBuilder.touchPoints()[0].radius().height()); | 582 EXPECT_FLOAT_EQ(30, transformedPoint.position.y); |
| 583 EXPECT_FLOAT_EQ(10, transformedPoint.radiusX); |
| 584 EXPECT_FLOAT_EQ(10, transformedPoint.radiusY); |
804 } | 585 } |
805 | 586 |
806 { | 587 { |
807 WebTouchEvent webTouchEvent1(WebInputEvent::TouchMove, | 588 WebTouchEvent webTouchEvent1(WebInputEvent::TouchMove, |
808 WebInputEvent::NoModifiers, | 589 WebInputEvent::NoModifiers, |
809 WebInputEvent::TimeStampForTesting); | 590 WebInputEvent::TimeStampForTesting); |
810 webTouchEvent1.touchesLength = 1; | 591 webTouchEvent1.touchesLength = 1; |
811 webTouchEvent1.touches[0].state = WebTouchPoint::StateMoved; | 592 webTouchEvent1.touches[0].state = WebTouchPoint::StateMoved; |
812 webTouchEvent1.touches[0].screenPosition.x = 100; | 593 webTouchEvent1.touches[0].screenPosition.x = 100; |
813 webTouchEvent1.touches[0].screenPosition.y = 110; | 594 webTouchEvent1.touches[0].screenPosition.y = 110; |
814 webTouchEvent1.touches[0].position.x = 100; | 595 webTouchEvent1.touches[0].position.x = 100; |
815 webTouchEvent1.touches[0].position.y = 110; | 596 webTouchEvent1.touches[0].position.y = 110; |
816 webTouchEvent1.touches[0].radiusX = 30; | 597 webTouchEvent1.touches[0].radiusX = 30; |
817 webTouchEvent1.touches[0].radiusY = 30; | 598 webTouchEvent1.touches[0].radiusY = 30; |
818 | 599 |
819 WebTouchEvent webTouchEvent2 = webTouchEvent1; | 600 WebTouchEvent webTouchEvent2 = webTouchEvent1; |
820 webTouchEvent2.touches[0].screenPosition.x = 130; | 601 webTouchEvent2.touches[0].screenPosition.x = 130; |
821 webTouchEvent2.touches[0].position.x = 130; | 602 webTouchEvent2.touches[0].position.x = 130; |
822 webTouchEvent2.touches[0].radiusX = 60; | 603 webTouchEvent2.touches[0].radiusX = 60; |
823 | 604 |
824 std::vector<const WebInputEvent*> events; | 605 std::vector<const WebInputEvent*> events; |
825 events.push_back(&webTouchEvent1); | 606 events.push_back(&webTouchEvent1); |
826 events.push_back(&webTouchEvent2); | 607 events.push_back(&webTouchEvent2); |
827 | 608 |
828 Vector<PlatformTouchEvent> coalescedevents = | 609 Vector<WebTouchEvent> coalescedevents = |
829 createPlatformTouchEventVector(view, events); | 610 TransformWebTouchEventVector(view, events); |
830 EXPECT_EQ(events.size(), coalescedevents.size()); | 611 EXPECT_EQ(events.size(), coalescedevents.size()); |
831 | 612 |
832 EXPECT_FLOAT_EQ(100, coalescedevents[0].touchPoints()[0].screenPos().x()); | 613 WebTouchPoint transformedPoint = |
833 EXPECT_FLOAT_EQ(110, coalescedevents[0].touchPoints()[0].screenPos().y()); | 614 coalescedevents[0].touchPointInRootFrame(0); |
834 EXPECT_FLOAT_EQ(30, coalescedevents[0].touchPoints()[0].pos().x()); | 615 EXPECT_FLOAT_EQ(100, transformedPoint.screenPosition.x); |
835 EXPECT_FLOAT_EQ(30, coalescedevents[0].touchPoints()[0].pos().y()); | 616 EXPECT_FLOAT_EQ(110, transformedPoint.screenPosition.y); |
836 EXPECT_FLOAT_EQ(10, coalescedevents[0].touchPoints()[0].radius().width()); | 617 EXPECT_FLOAT_EQ(30, transformedPoint.position.x); |
837 EXPECT_FLOAT_EQ(10, coalescedevents[0].touchPoints()[0].radius().height()); | 618 EXPECT_FLOAT_EQ(30, transformedPoint.position.y); |
| 619 EXPECT_FLOAT_EQ(10, transformedPoint.radiusX); |
| 620 EXPECT_FLOAT_EQ(10, transformedPoint.radiusY); |
838 | 621 |
839 EXPECT_FLOAT_EQ(130, coalescedevents[1].touchPoints()[0].screenPos().x()); | 622 transformedPoint = coalescedevents[1].touchPointInRootFrame(0); |
840 EXPECT_FLOAT_EQ(110, coalescedevents[1].touchPoints()[0].screenPos().y()); | 623 EXPECT_FLOAT_EQ(130, transformedPoint.screenPosition.x); |
841 EXPECT_FLOAT_EQ(40, coalescedevents[1].touchPoints()[0].pos().x()); | 624 EXPECT_FLOAT_EQ(110, transformedPoint.screenPosition.y); |
842 EXPECT_FLOAT_EQ(30, coalescedevents[1].touchPoints()[0].pos().y()); | 625 EXPECT_FLOAT_EQ(40, transformedPoint.position.x); |
843 EXPECT_FLOAT_EQ(20, coalescedevents[1].touchPoints()[0].radius().width()); | 626 EXPECT_FLOAT_EQ(30, transformedPoint.position.y); |
844 EXPECT_FLOAT_EQ(10, coalescedevents[1].touchPoints()[0].radius().height()); | 627 EXPECT_FLOAT_EQ(20, transformedPoint.radiusX); |
| 628 EXPECT_FLOAT_EQ(10, transformedPoint.radiusY); |
845 } | 629 } |
846 } | 630 } |
847 | 631 |
848 TEST(WebInputEventConversionTest, InputEventsConversions) { | 632 TEST(WebInputEventConversionTest, InputEventsConversions) { |
849 const std::string baseURL("http://www.test3.com/"); | 633 const std::string baseURL("http://www.test3.com/"); |
850 const std::string fileName("fixed_layout.html"); | 634 const std::string fileName("fixed_layout.html"); |
851 | 635 |
852 URLTestHelpers::registerMockedURLFromBaseURL( | 636 URLTestHelpers::registerMockedURLFromBaseURL( |
853 WebString::fromUTF8(baseURL.c_str()), | 637 WebString::fromUTF8(baseURL.c_str()), |
854 WebString::fromUTF8("fixed_layout.html")); | 638 WebString::fromUTF8("fixed_layout.html")); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 760 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
977 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 761 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
978 webTouchEvent.touches[0].position.x = 10.6f; | 762 webTouchEvent.touches[0].position.x = 10.6f; |
979 webTouchEvent.touches[0].position.y = 10.4f; | 763 webTouchEvent.touches[0].position.y = 10.4f; |
980 | 764 |
981 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); | 765 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); |
982 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); | 766 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); |
983 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); | 767 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); |
984 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); | 768 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); |
985 | 769 |
986 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 770 WebTouchEvent transformedTouchEvent = |
987 EXPECT_FLOAT_EQ(10.6f, | 771 TransformWebTouchEvent(view, webTouchEvent); |
988 platformTouchBuilder.touchPoints()[0].screenPos().x()); | 772 WebTouchPoint transformedPoint = |
989 EXPECT_FLOAT_EQ(10.4f, | 773 transformedTouchEvent.touchPointInRootFrame(0); |
990 platformTouchBuilder.touchPoints()[0].screenPos().y()); | 774 EXPECT_FLOAT_EQ(10.6f, transformedPoint.screenPosition.x); |
991 EXPECT_FLOAT_EQ(5.3f + visualOffset.x(), | 775 EXPECT_FLOAT_EQ(10.4f, transformedPoint.screenPosition.y); |
992 platformTouchBuilder.touchPoints()[0].pos().x()); | 776 EXPECT_FLOAT_EQ(5.3f + visualOffset.x(), transformedPoint.position.x); |
993 EXPECT_FLOAT_EQ(5.2f + visualOffset.y(), | 777 EXPECT_FLOAT_EQ(5.2f + visualOffset.y(), transformedPoint.position.y); |
994 platformTouchBuilder.touchPoints()[0].pos().y()); | |
995 } | 778 } |
996 } | 779 } |
997 | 780 |
998 TEST(WebInputEventConversionTest, ElasticOverscroll) { | 781 TEST(WebInputEventConversionTest, ElasticOverscroll) { |
999 const std::string baseURL("http://www.test5.com/"); | 782 const std::string baseURL("http://www.test5.com/"); |
1000 const std::string fileName("fixed_layout.html"); | 783 const std::string fileName("fixed_layout.html"); |
1001 | 784 |
1002 URLTestHelpers::registerMockedURLFromBaseURL( | 785 URLTestHelpers::registerMockedURLFromBaseURL( |
1003 WebString::fromUTF8(baseURL.c_str()), | 786 WebString::fromUTF8(baseURL.c_str()), |
1004 WebString::fromUTF8("fixed_layout.html")); | 787 WebString::fromUTF8("fixed_layout.html")); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), | 888 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), |
1106 platformMouseBuilder.position().x()); | 889 platformMouseBuilder.position().x()); |
1107 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), | 890 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), |
1108 platformMouseBuilder.position().y()); | 891 platformMouseBuilder.position().y()); |
1109 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); | 892 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); |
1110 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); | 893 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); |
1111 } | 894 } |
1112 } | 895 } |
1113 | 896 |
1114 } // namespace blink | 897 } // namespace blink |
OLD | NEW |