| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); | 252 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); |
| 253 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); | 253 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); |
| 254 EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); | 254 EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); |
| 255 EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); | 255 EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 { | 258 { |
| 259 WebGestureEvent webGestureEvent; | 259 WebGestureEvent webGestureEvent; |
| 260 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 260 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
| 261 webGestureEvent.x = 10; | 261 webGestureEvent.x = 10; |
| 262 webGestureEvent.y = 10; | 262 webGestureEvent.y = 12; |
| 263 webGestureEvent.globalX = 10; | 263 webGestureEvent.globalX = 20; |
| 264 webGestureEvent.globalY = 10; | 264 webGestureEvent.globalY = 22; |
| 265 webGestureEvent.data.scrollUpdate.deltaX = 10; | 265 webGestureEvent.data.scrollUpdate.deltaX = 30; |
| 266 webGestureEvent.data.scrollUpdate.deltaY = 10; | 266 webGestureEvent.data.scrollUpdate.deltaY = 32; |
| 267 webGestureEvent.data.scrollUpdate.velocityX = 40; |
| 268 webGestureEvent.data.scrollUpdate.velocityY = 42; |
| 269 webGestureEvent.data.scrollUpdate.preventPropagation = true; |
| 267 | 270 |
| 268 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent
); | 271 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent
); |
| 269 EXPECT_EQ(5, platformGestureBuilder.position().x()); | 272 EXPECT_EQ(5, platformGestureBuilder.position().x()); |
| 270 EXPECT_EQ(5, platformGestureBuilder.position().y()); | 273 EXPECT_EQ(6, platformGestureBuilder.position().y()); |
| 271 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 274 EXPECT_EQ(20, platformGestureBuilder.globalPosition().x()); |
| 272 EXPECT_EQ(10, platformGestureBuilder.globalPosition().y()); | 275 EXPECT_EQ(22, platformGestureBuilder.globalPosition().y()); |
| 273 EXPECT_EQ(5, platformGestureBuilder.deltaX()); | 276 EXPECT_EQ(15, platformGestureBuilder.deltaX()); |
| 274 EXPECT_EQ(5, platformGestureBuilder.deltaY()); | 277 EXPECT_EQ(16, platformGestureBuilder.deltaY()); |
| 278 // TODO: The velocity values may need to be scaled to page scale in |
| 279 // order to remain consist with delta values. |
| 280 EXPECT_EQ(40, platformGestureBuilder.velocityX()); |
| 281 EXPECT_EQ(42, platformGestureBuilder.velocityY()); |
| 282 EXPECT_TRUE(platformGestureBuilder.preventPropagation()); |
| 275 } | 283 } |
| 276 | 284 |
| 277 { | 285 { |
| 278 WebGestureEvent webGestureEvent; | 286 WebGestureEvent webGestureEvent; |
| 279 webGestureEvent.type = WebInputEvent::GestureTap; | 287 webGestureEvent.type = WebInputEvent::GestureTap; |
| 280 webGestureEvent.data.tap.width = 10; | 288 webGestureEvent.data.tap.width = 10; |
| 281 webGestureEvent.data.tap.height = 10; | 289 webGestureEvent.data.tap.height = 10; |
| 282 | 290 |
| 283 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent
); | 291 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent
); |
| 284 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 292 EXPECT_EQ(5, platformGestureBuilder.area().width()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 392 } |
| 385 | 393 |
| 386 { | 394 { |
| 387 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10)
, NoButton, PlatformEvent::MouseMoved, 1, false, false, false, false, PlatformMo
useEvent::RealOrIndistinguishable, 0); | 395 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10)
, NoButton, PlatformEvent::MouseMoved, 1, false, false, false, false, PlatformMo
useEvent::RealOrIndistinguishable, 0); |
| 388 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(EventType
Names::mousemove, domWindow, platformMouseEvent, 0, document); | 396 RefPtrWillBeRawPtr<MouseEvent> mouseEvent = MouseEvent::create(EventType
Names::mousemove, domWindow, platformMouseEvent, 0, document); |
| 389 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve
nt); | 397 WebMouseEventBuilder webMouseBuilder(view, documentRenderView, *mouseEve
nt); |
| 390 EXPECT_EQ(WebMouseEvent::ButtonNone, webMouseBuilder.button); | 398 EXPECT_EQ(WebMouseEvent::ButtonNone, webMouseBuilder.button); |
| 391 } | 399 } |
| 392 | 400 |
| 393 { | 401 { |
| 394 PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUp
date, IntPoint(10, 10), IntPoint(10, 10), IntSize(10, 10), 0, false, false, fals
e, false, 10, 10, 10, 10); | 402 PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUp
date, IntPoint(10, 12), IntPoint(20, 22), IntSize(25, 27), 0, false, false, fals
e, false, 30, 32, 40, 42, true); |
| 403 // TODO: GestureEvent does not preserve velocityX, velocityY, and |
| 404 // preventPropagation. It also fails to scale coordinates (x,y, deltaX, |
| 405 // deltaY) to the page scale. This may lead to unexpected bugs if a |
| 406 // PlatformGestureEvent is transformed into WebGestureEvent and back. |
| 395 RefPtrWillBeRawPtr<GestureEvent> gestureEvent = GestureEvent::create(dom
Window, platformGestureEvent); | 407 RefPtrWillBeRawPtr<GestureEvent> gestureEvent = GestureEvent::create(dom
Window, platformGestureEvent); |
| 396 WebGestureEventBuilder webGestureBuilder(view, documentRenderView, *gest
ureEvent); | 408 WebGestureEventBuilder webGestureBuilder(view, documentRenderView, *gest
ureEvent); |
| 397 | 409 |
| 398 EXPECT_EQ(10, webGestureBuilder.x); | 410 EXPECT_EQ(10, webGestureBuilder.x); |
| 399 EXPECT_EQ(10, webGestureBuilder.y); | 411 EXPECT_EQ(12, webGestureBuilder.y); |
| 400 EXPECT_EQ(10, webGestureBuilder.globalX); | 412 EXPECT_EQ(20, webGestureBuilder.globalX); |
| 401 EXPECT_EQ(10, webGestureBuilder.globalY); | 413 EXPECT_EQ(22, webGestureBuilder.globalY); |
| 402 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaX); | 414 EXPECT_EQ(30, webGestureBuilder.data.scrollUpdate.deltaX); |
| 403 EXPECT_EQ(10, webGestureBuilder.data.scrollUpdate.deltaY); | 415 EXPECT_EQ(32, webGestureBuilder.data.scrollUpdate.deltaY); |
| 416 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityX); |
| 417 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityY); |
| 418 EXPECT_FALSE(webGestureBuilder.data.scrollUpdate.preventPropagation); |
| 404 } | 419 } |
| 405 | 420 |
| 406 { | 421 { |
| 407 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webViewImpl
->page()->mainFrame()), document.get(), 0, FloatPoint(10, 9.5), FloatPoint(3.5,
2), FloatSize(4, 4.5), 0, 0); | 422 RefPtrWillBeRawPtr<Touch> touch = Touch::create(toLocalFrame(webViewImpl
->page()->mainFrame()), document.get(), 0, FloatPoint(10, 9.5), FloatPoint(3.5,
2), FloatSize(4, 4.5), 0, 0); |
| 408 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); | 423 RefPtrWillBeRawPtr<TouchList> touchList = TouchList::create(); |
| 409 touchList->append(touch); | 424 touchList->append(touch); |
| 410 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchmove, domWindow,
false, false, false, false, false); | 425 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(touchList
.get(), touchList.get(), touchList.get(), EventTypeNames::touchmove, domWindow,
false, false, false, false, false); |
| 411 | 426 |
| 412 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); | 427 WebTouchEventBuilder webTouchBuilder(view, documentRenderView, *touchEve
nt); |
| 413 ASSERT_EQ(1u, webTouchBuilder.touchesLength); | 428 ASSERT_EQ(1u, webTouchBuilder.touchesLength); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 | 722 |
| 708 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 723 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
| 709 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); | 724 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); |
| 710 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); | 725 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); |
| 711 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); | 726 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); |
| 712 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); | 727 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); |
| 713 } | 728 } |
| 714 } | 729 } |
| 715 | 730 |
| 716 } // anonymous namespace | 731 } // anonymous namespace |
| OLD | NEW |