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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 316 |
317 webViewImpl->setPageScaleFactor(2); | 317 webViewImpl->setPageScaleFactor(2); |
318 | 318 |
319 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 319 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
320 Document* document = | 320 Document* document = |
321 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | 321 toLocalFrame(webViewImpl->page()->mainFrame())->document(); |
322 LocalDOMWindow* domWindow = document->domWindow(); | 322 LocalDOMWindow* domWindow = document->domWindow(); |
323 LayoutViewItem documentLayoutView = document->layoutViewItem(); | 323 LayoutViewItem documentLayoutView = document->layoutViewItem(); |
324 | 324 |
325 { | 325 { |
326 WebMouseEvent webMouseEvent; | 326 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
327 webMouseEvent.type = WebInputEvent::MouseMove; | 327 WebInputEvent::NoModifiers, |
| 328 WebInputEvent::TimeStampForTesting); |
328 webMouseEvent.x = 10; | 329 webMouseEvent.x = 10; |
329 webMouseEvent.y = 10; | 330 webMouseEvent.y = 10; |
330 webMouseEvent.windowX = 10; | 331 webMouseEvent.windowX = 10; |
331 webMouseEvent.windowY = 10; | 332 webMouseEvent.windowY = 10; |
332 webMouseEvent.globalX = 10; | 333 webMouseEvent.globalX = 10; |
333 webMouseEvent.globalY = 10; | 334 webMouseEvent.globalY = 10; |
334 webMouseEvent.movementX = 10; | 335 webMouseEvent.movementX = 10; |
335 webMouseEvent.movementY = 10; | 336 webMouseEvent.movementY = 10; |
336 | 337 |
337 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 338 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
338 EXPECT_EQ(5, platformMouseBuilder.position().x()); | 339 EXPECT_EQ(5, platformMouseBuilder.position().x()); |
339 EXPECT_EQ(5, platformMouseBuilder.position().y()); | 340 EXPECT_EQ(5, platformMouseBuilder.position().y()); |
340 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); | 341 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); |
341 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); | 342 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); |
342 EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); | 343 EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); |
343 EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); | 344 EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); |
344 } | 345 } |
345 | 346 |
346 { | 347 { |
347 WebGestureEvent webGestureEvent; | 348 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
348 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 349 WebInputEvent::NoModifiers, |
| 350 WebInputEvent::TimeStampForTesting); |
349 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 351 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
350 webGestureEvent.x = 10; | 352 webGestureEvent.x = 10; |
351 webGestureEvent.y = 12; | 353 webGestureEvent.y = 12; |
352 webGestureEvent.globalX = 20; | 354 webGestureEvent.globalX = 20; |
353 webGestureEvent.globalY = 22; | 355 webGestureEvent.globalY = 22; |
354 webGestureEvent.data.scrollUpdate.deltaX = 30; | 356 webGestureEvent.data.scrollUpdate.deltaX = 30; |
355 webGestureEvent.data.scrollUpdate.deltaY = 32; | 357 webGestureEvent.data.scrollUpdate.deltaY = 32; |
356 webGestureEvent.data.scrollUpdate.velocityX = 40; | 358 webGestureEvent.data.scrollUpdate.velocityX = 40; |
357 webGestureEvent.data.scrollUpdate.velocityY = 42; | 359 webGestureEvent.data.scrollUpdate.velocityY = 42; |
358 webGestureEvent.data.scrollUpdate.inertialPhase = | 360 webGestureEvent.data.scrollUpdate.inertialPhase = |
(...skipping 13 matching lines...) Expand all Loading... |
372 // TODO: The velocity values may need to be scaled to page scale in | 374 // TODO: The velocity values may need to be scaled to page scale in |
373 // order to remain consist with delta values. | 375 // order to remain consist with delta values. |
374 EXPECT_EQ(40, scaledGestureEvent.velocityX()); | 376 EXPECT_EQ(40, scaledGestureEvent.velocityX()); |
375 EXPECT_EQ(42, scaledGestureEvent.velocityY()); | 377 EXPECT_EQ(42, scaledGestureEvent.velocityY()); |
376 EXPECT_EQ(WebGestureEvent::MomentumPhase, | 378 EXPECT_EQ(WebGestureEvent::MomentumPhase, |
377 scaledGestureEvent.inertialPhase()); | 379 scaledGestureEvent.inertialPhase()); |
378 EXPECT_TRUE(scaledGestureEvent.preventPropagation()); | 380 EXPECT_TRUE(scaledGestureEvent.preventPropagation()); |
379 } | 381 } |
380 | 382 |
381 { | 383 { |
382 WebGestureEvent webGestureEvent; | 384 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollEnd, |
383 webGestureEvent.type = WebInputEvent::GestureScrollEnd; | 385 WebInputEvent::NoModifiers, |
| 386 WebInputEvent::TimeStampForTesting); |
384 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 387 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
385 webGestureEvent.x = 10; | 388 webGestureEvent.x = 10; |
386 webGestureEvent.y = 12; | 389 webGestureEvent.y = 12; |
387 webGestureEvent.globalX = 20; | 390 webGestureEvent.globalX = 20; |
388 webGestureEvent.globalY = 22; | 391 webGestureEvent.globalY = 22; |
389 | 392 |
390 WebGestureEvent scaledGestureEvent = | 393 WebGestureEvent scaledGestureEvent = |
391 TransformWebGestureEvent(view, webGestureEvent); | 394 TransformWebGestureEvent(view, webGestureEvent); |
392 IntPoint position = | 395 IntPoint position = |
393 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); | 396 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
394 EXPECT_EQ(5, position.x()); | 397 EXPECT_EQ(5, position.x()); |
395 EXPECT_EQ(6, position.y()); | 398 EXPECT_EQ(6, position.y()); |
396 EXPECT_EQ(20, scaledGestureEvent.globalX); | 399 EXPECT_EQ(20, scaledGestureEvent.globalX); |
397 EXPECT_EQ(22, scaledGestureEvent.globalY); | 400 EXPECT_EQ(22, scaledGestureEvent.globalY); |
398 EXPECT_EQ(WebGestureEvent::UnknownMomentumPhase, | 401 EXPECT_EQ(WebGestureEvent::UnknownMomentumPhase, |
399 scaledGestureEvent.inertialPhase()); | 402 scaledGestureEvent.inertialPhase()); |
400 } | 403 } |
401 | 404 |
402 { | 405 { |
403 WebGestureEvent webGestureEvent; | 406 WebGestureEvent webGestureEvent(WebInputEvent::GestureTap, |
404 webGestureEvent.type = WebInputEvent::GestureTap; | 407 WebInputEvent::NoModifiers, |
| 408 WebInputEvent::TimeStampForTesting); |
405 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 409 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
406 webGestureEvent.data.tap.width = 10; | 410 webGestureEvent.data.tap.width = 10; |
407 webGestureEvent.data.tap.height = 10; | 411 webGestureEvent.data.tap.height = 10; |
408 | 412 |
409 WebGestureEvent scaledGestureEvent = | 413 WebGestureEvent scaledGestureEvent = |
410 TransformWebGestureEvent(view, webGestureEvent); | 414 TransformWebGestureEvent(view, webGestureEvent); |
411 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 415 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
412 EXPECT_EQ(5, area.width()); | 416 EXPECT_EQ(5, area.width()); |
413 EXPECT_EQ(5, area.height()); | 417 EXPECT_EQ(5, area.height()); |
414 } | 418 } |
415 | 419 |
416 { | 420 { |
417 WebGestureEvent webGestureEvent; | 421 WebGestureEvent webGestureEvent(WebInputEvent::GestureTapUnconfirmed, |
418 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 422 WebInputEvent::NoModifiers, |
| 423 WebInputEvent::TimeStampForTesting); |
419 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 424 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
420 webGestureEvent.data.tap.width = 10; | 425 webGestureEvent.data.tap.width = 10; |
421 webGestureEvent.data.tap.height = 10; | 426 webGestureEvent.data.tap.height = 10; |
422 | 427 |
423 WebGestureEvent scaledGestureEvent = | 428 WebGestureEvent scaledGestureEvent = |
424 TransformWebGestureEvent(view, webGestureEvent); | 429 TransformWebGestureEvent(view, webGestureEvent); |
425 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 430 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
426 EXPECT_EQ(5, area.width()); | 431 EXPECT_EQ(5, area.width()); |
427 EXPECT_EQ(5, area.height()); | 432 EXPECT_EQ(5, area.height()); |
428 } | 433 } |
429 | 434 |
430 { | 435 { |
431 WebGestureEvent webGestureEvent; | 436 WebGestureEvent webGestureEvent(WebInputEvent::GestureTapDown, |
432 webGestureEvent.type = WebInputEvent::GestureTapDown; | 437 WebInputEvent::NoModifiers, |
| 438 WebInputEvent::TimeStampForTesting); |
433 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 439 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
434 webGestureEvent.data.tapDown.width = 10; | 440 webGestureEvent.data.tapDown.width = 10; |
435 webGestureEvent.data.tapDown.height = 10; | 441 webGestureEvent.data.tapDown.height = 10; |
436 | 442 |
437 WebGestureEvent scaledGestureEvent = | 443 WebGestureEvent scaledGestureEvent = |
438 TransformWebGestureEvent(view, webGestureEvent); | 444 TransformWebGestureEvent(view, webGestureEvent); |
439 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 445 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
440 EXPECT_EQ(5, area.width()); | 446 EXPECT_EQ(5, area.width()); |
441 EXPECT_EQ(5, area.height()); | 447 EXPECT_EQ(5, area.height()); |
442 } | 448 } |
443 | 449 |
444 { | 450 { |
445 WebGestureEvent webGestureEvent; | 451 WebGestureEvent webGestureEvent(WebInputEvent::GestureShowPress, |
446 webGestureEvent.type = WebInputEvent::GestureShowPress; | 452 WebInputEvent::NoModifiers, |
| 453 WebInputEvent::TimeStampForTesting); |
447 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 454 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
448 webGestureEvent.data.showPress.width = 10; | 455 webGestureEvent.data.showPress.width = 10; |
449 webGestureEvent.data.showPress.height = 10; | 456 webGestureEvent.data.showPress.height = 10; |
450 | 457 |
451 WebGestureEvent scaledGestureEvent = | 458 WebGestureEvent scaledGestureEvent = |
452 TransformWebGestureEvent(view, webGestureEvent); | 459 TransformWebGestureEvent(view, webGestureEvent); |
453 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 460 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
454 EXPECT_EQ(5, area.width()); | 461 EXPECT_EQ(5, area.width()); |
455 EXPECT_EQ(5, area.height()); | 462 EXPECT_EQ(5, area.height()); |
456 } | 463 } |
457 | 464 |
458 { | 465 { |
459 WebGestureEvent webGestureEvent; | 466 WebGestureEvent webGestureEvent(WebInputEvent::GestureLongPress, |
460 webGestureEvent.type = WebInputEvent::GestureLongPress; | 467 WebInputEvent::NoModifiers, |
| 468 WebInputEvent::TimeStampForTesting); |
461 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 469 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
462 webGestureEvent.data.longPress.width = 10; | 470 webGestureEvent.data.longPress.width = 10; |
463 webGestureEvent.data.longPress.height = 10; | 471 webGestureEvent.data.longPress.height = 10; |
464 | 472 |
465 WebGestureEvent scaledGestureEvent = | 473 WebGestureEvent scaledGestureEvent = |
466 TransformWebGestureEvent(view, webGestureEvent); | 474 TransformWebGestureEvent(view, webGestureEvent); |
467 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 475 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
468 EXPECT_EQ(5, area.width()); | 476 EXPECT_EQ(5, area.width()); |
469 EXPECT_EQ(5, area.height()); | 477 EXPECT_EQ(5, area.height()); |
470 } | 478 } |
471 | 479 |
472 { | 480 { |
473 WebGestureEvent webGestureEvent; | 481 WebGestureEvent webGestureEvent(WebInputEvent::GestureTwoFingerTap, |
474 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 482 WebInputEvent::NoModifiers, |
| 483 WebInputEvent::TimeStampForTesting); |
475 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 484 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
476 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; | 485 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; |
477 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; | 486 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; |
478 | 487 |
479 WebGestureEvent scaledGestureEvent = | 488 WebGestureEvent scaledGestureEvent = |
480 TransformWebGestureEvent(view, webGestureEvent); | 489 TransformWebGestureEvent(view, webGestureEvent); |
481 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 490 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
482 EXPECT_EQ(5, area.width()); | 491 EXPECT_EQ(5, area.width()); |
483 EXPECT_EQ(5, area.height()); | 492 EXPECT_EQ(5, area.height()); |
484 } | 493 } |
485 | 494 |
486 { | 495 { |
487 WebTouchEvent webTouchEvent; | 496 WebTouchEvent webTouchEvent(WebInputEvent::TouchMove, |
488 webTouchEvent.type = WebInputEvent::TouchMove; | 497 WebInputEvent::NoModifiers, |
| 498 WebInputEvent::TimeStampForTesting); |
489 webTouchEvent.touchesLength = 1; | 499 webTouchEvent.touchesLength = 1; |
490 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 500 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
491 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 501 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
492 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 502 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
493 webTouchEvent.touches[0].position.x = 10.6f; | 503 webTouchEvent.touches[0].position.x = 10.6f; |
494 webTouchEvent.touches[0].position.y = 10.4f; | 504 webTouchEvent.touches[0].position.y = 10.4f; |
495 webTouchEvent.touches[0].radiusX = 10.6f; | 505 webTouchEvent.touches[0].radiusX = 10.6f; |
496 webTouchEvent.touches[0].radiusY = 10.4f; | 506 webTouchEvent.touches[0].radiusY = 10.4f; |
497 | 507 |
498 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); | 508 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 596 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
587 webViewImpl->updateAllLifecyclePhases(); | 597 webViewImpl->updateAllLifecyclePhases(); |
588 | 598 |
589 webViewImpl->setPageScaleFactor(2); | 599 webViewImpl->setPageScaleFactor(2); |
590 webViewImpl->mainFrameImpl()->setInputEventsTransformForEmulation( | 600 webViewImpl->mainFrameImpl()->setInputEventsTransformForEmulation( |
591 IntSize(10, 20), 1.5); | 601 IntSize(10, 20), 1.5); |
592 | 602 |
593 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 603 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
594 | 604 |
595 { | 605 { |
596 WebMouseEvent webMouseEvent; | 606 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
597 webMouseEvent.type = WebInputEvent::MouseMove; | 607 WebInputEvent::NoModifiers, |
| 608 WebInputEvent::TimeStampForTesting); |
598 webMouseEvent.x = 100; | 609 webMouseEvent.x = 100; |
599 webMouseEvent.y = 110; | 610 webMouseEvent.y = 110; |
600 webMouseEvent.windowX = 100; | 611 webMouseEvent.windowX = 100; |
601 webMouseEvent.windowY = 110; | 612 webMouseEvent.windowY = 110; |
602 webMouseEvent.globalX = 100; | 613 webMouseEvent.globalX = 100; |
603 webMouseEvent.globalY = 110; | 614 webMouseEvent.globalY = 110; |
604 webMouseEvent.movementX = 60; | 615 webMouseEvent.movementX = 60; |
605 webMouseEvent.movementY = 60; | 616 webMouseEvent.movementY = 60; |
606 | 617 |
607 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 618 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
608 EXPECT_EQ(30, platformMouseBuilder.position().x()); | 619 EXPECT_EQ(30, platformMouseBuilder.position().x()); |
609 EXPECT_EQ(30, platformMouseBuilder.position().y()); | 620 EXPECT_EQ(30, platformMouseBuilder.position().y()); |
610 EXPECT_EQ(100, platformMouseBuilder.globalPosition().x()); | 621 EXPECT_EQ(100, platformMouseBuilder.globalPosition().x()); |
611 EXPECT_EQ(110, platformMouseBuilder.globalPosition().y()); | 622 EXPECT_EQ(110, platformMouseBuilder.globalPosition().y()); |
612 EXPECT_EQ(20, platformMouseBuilder.movementDelta().x()); | 623 EXPECT_EQ(20, platformMouseBuilder.movementDelta().x()); |
613 EXPECT_EQ(20, platformMouseBuilder.movementDelta().y()); | 624 EXPECT_EQ(20, platformMouseBuilder.movementDelta().y()); |
614 } | 625 } |
615 | 626 |
616 { | 627 { |
617 WebMouseEvent webMouseEvent1; | 628 WebMouseEvent webMouseEvent1(WebInputEvent::MouseMove, |
618 webMouseEvent1.type = WebInputEvent::MouseMove; | 629 WebInputEvent::NoModifiers, |
| 630 WebInputEvent::TimeStampForTesting); |
619 webMouseEvent1.x = 100; | 631 webMouseEvent1.x = 100; |
620 webMouseEvent1.y = 110; | 632 webMouseEvent1.y = 110; |
621 webMouseEvent1.windowX = 100; | 633 webMouseEvent1.windowX = 100; |
622 webMouseEvent1.windowY = 110; | 634 webMouseEvent1.windowY = 110; |
623 webMouseEvent1.globalX = 100; | 635 webMouseEvent1.globalX = 100; |
624 webMouseEvent1.globalY = 110; | 636 webMouseEvent1.globalY = 110; |
625 webMouseEvent1.movementX = 60; | 637 webMouseEvent1.movementX = 60; |
626 webMouseEvent1.movementY = 60; | 638 webMouseEvent1.movementY = 60; |
627 | 639 |
628 WebMouseEvent webMouseEvent2 = webMouseEvent1; | 640 WebMouseEvent webMouseEvent2 = webMouseEvent1; |
(...skipping 19 matching lines...) Expand all Loading... |
648 | 660 |
649 EXPECT_EQ(30, coalescedevents[1].position().x()); | 661 EXPECT_EQ(30, coalescedevents[1].position().x()); |
650 EXPECT_EQ(40, coalescedevents[1].position().y()); | 662 EXPECT_EQ(40, coalescedevents[1].position().y()); |
651 EXPECT_EQ(100, coalescedevents[1].globalPosition().x()); | 663 EXPECT_EQ(100, coalescedevents[1].globalPosition().x()); |
652 EXPECT_EQ(140, coalescedevents[1].globalPosition().y()); | 664 EXPECT_EQ(140, coalescedevents[1].globalPosition().y()); |
653 EXPECT_EQ(20, coalescedevents[1].movementDelta().x()); | 665 EXPECT_EQ(20, coalescedevents[1].movementDelta().x()); |
654 EXPECT_EQ(10, coalescedevents[1].movementDelta().y()); | 666 EXPECT_EQ(10, coalescedevents[1].movementDelta().y()); |
655 } | 667 } |
656 | 668 |
657 { | 669 { |
658 WebGestureEvent webGestureEvent; | 670 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
659 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 671 WebInputEvent::NoModifiers, |
| 672 WebInputEvent::TimeStampForTesting); |
660 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 673 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
661 webGestureEvent.x = 100; | 674 webGestureEvent.x = 100; |
662 webGestureEvent.y = 110; | 675 webGestureEvent.y = 110; |
663 webGestureEvent.globalX = 100; | 676 webGestureEvent.globalX = 100; |
664 webGestureEvent.globalY = 110; | 677 webGestureEvent.globalY = 110; |
665 webGestureEvent.data.scrollUpdate.deltaX = 60; | 678 webGestureEvent.data.scrollUpdate.deltaX = 60; |
666 webGestureEvent.data.scrollUpdate.deltaY = 60; | 679 webGestureEvent.data.scrollUpdate.deltaY = 60; |
667 | 680 |
668 WebGestureEvent scaledGestureEvent = | 681 WebGestureEvent scaledGestureEvent = |
669 TransformWebGestureEvent(view, webGestureEvent); | 682 TransformWebGestureEvent(view, webGestureEvent); |
670 FloatPoint position = scaledGestureEvent.positionInRootFrame(); | 683 FloatPoint position = scaledGestureEvent.positionInRootFrame(); |
671 | 684 |
672 EXPECT_FLOAT_EQ(30, position.x()); | 685 EXPECT_FLOAT_EQ(30, position.x()); |
673 EXPECT_FLOAT_EQ(30, position.y()); | 686 EXPECT_FLOAT_EQ(30, position.y()); |
674 EXPECT_EQ(100, scaledGestureEvent.globalX); | 687 EXPECT_EQ(100, scaledGestureEvent.globalX); |
675 EXPECT_EQ(110, scaledGestureEvent.globalY); | 688 EXPECT_EQ(110, scaledGestureEvent.globalY); |
676 EXPECT_EQ(20, scaledGestureEvent.deltaXInRootFrame()); | 689 EXPECT_EQ(20, scaledGestureEvent.deltaXInRootFrame()); |
677 EXPECT_EQ(20, scaledGestureEvent.deltaYInRootFrame()); | 690 EXPECT_EQ(20, scaledGestureEvent.deltaYInRootFrame()); |
678 } | 691 } |
679 | 692 |
680 { | 693 { |
681 WebGestureEvent webGestureEvent; | 694 WebGestureEvent webGestureEvent(WebInputEvent::GestureTap, |
682 webGestureEvent.type = WebInputEvent::GestureTap; | 695 WebInputEvent::NoModifiers, |
| 696 WebInputEvent::TimeStampForTesting); |
683 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 697 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
684 webGestureEvent.data.tap.width = 30; | 698 webGestureEvent.data.tap.width = 30; |
685 webGestureEvent.data.tap.height = 30; | 699 webGestureEvent.data.tap.height = 30; |
686 | 700 |
687 WebGestureEvent scaledGestureEvent = | 701 WebGestureEvent scaledGestureEvent = |
688 TransformWebGestureEvent(view, webGestureEvent); | 702 TransformWebGestureEvent(view, webGestureEvent); |
689 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 703 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
690 EXPECT_EQ(10, area.width()); | 704 EXPECT_EQ(10, area.width()); |
691 EXPECT_EQ(10, area.height()); | 705 EXPECT_EQ(10, area.height()); |
692 } | 706 } |
693 | 707 |
694 { | 708 { |
695 WebGestureEvent webGestureEvent; | 709 WebGestureEvent webGestureEvent(WebInputEvent::GestureTapUnconfirmed, |
696 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 710 WebInputEvent::NoModifiers, |
| 711 WebInputEvent::TimeStampForTesting); |
697 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 712 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
698 webGestureEvent.data.tap.width = 30; | 713 webGestureEvent.data.tap.width = 30; |
699 webGestureEvent.data.tap.height = 30; | 714 webGestureEvent.data.tap.height = 30; |
700 | 715 |
701 WebGestureEvent scaledGestureEvent = | 716 WebGestureEvent scaledGestureEvent = |
702 TransformWebGestureEvent(view, webGestureEvent); | 717 TransformWebGestureEvent(view, webGestureEvent); |
703 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 718 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
704 EXPECT_EQ(10, area.width()); | 719 EXPECT_EQ(10, area.width()); |
705 EXPECT_EQ(10, area.height()); | 720 EXPECT_EQ(10, area.height()); |
706 } | 721 } |
707 | 722 |
708 { | 723 { |
709 WebGestureEvent webGestureEvent; | 724 WebGestureEvent webGestureEvent(WebInputEvent::GestureTapDown, |
710 webGestureEvent.type = WebInputEvent::GestureTapDown; | 725 WebInputEvent::NoModifiers, |
| 726 WebInputEvent::TimeStampForTesting); |
711 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 727 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
712 webGestureEvent.data.tapDown.width = 30; | 728 webGestureEvent.data.tapDown.width = 30; |
713 webGestureEvent.data.tapDown.height = 30; | 729 webGestureEvent.data.tapDown.height = 30; |
714 | 730 |
715 WebGestureEvent scaledGestureEvent = | 731 WebGestureEvent scaledGestureEvent = |
716 TransformWebGestureEvent(view, webGestureEvent); | 732 TransformWebGestureEvent(view, webGestureEvent); |
717 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 733 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
718 EXPECT_EQ(10, area.width()); | 734 EXPECT_EQ(10, area.width()); |
719 EXPECT_EQ(10, area.height()); | 735 EXPECT_EQ(10, area.height()); |
720 } | 736 } |
721 | 737 |
722 { | 738 { |
723 WebGestureEvent webGestureEvent; | 739 WebGestureEvent webGestureEvent(WebInputEvent::GestureShowPress, |
724 webGestureEvent.type = WebInputEvent::GestureShowPress; | 740 WebInputEvent::NoModifiers, |
| 741 WebInputEvent::TimeStampForTesting); |
725 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 742 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
726 webGestureEvent.data.showPress.width = 30; | 743 webGestureEvent.data.showPress.width = 30; |
727 webGestureEvent.data.showPress.height = 30; | 744 webGestureEvent.data.showPress.height = 30; |
728 | 745 |
729 WebGestureEvent scaledGestureEvent = | 746 WebGestureEvent scaledGestureEvent = |
730 TransformWebGestureEvent(view, webGestureEvent); | 747 TransformWebGestureEvent(view, webGestureEvent); |
731 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 748 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
732 EXPECT_EQ(10, area.width()); | 749 EXPECT_EQ(10, area.width()); |
733 EXPECT_EQ(10, area.height()); | 750 EXPECT_EQ(10, area.height()); |
734 } | 751 } |
735 | 752 |
736 { | 753 { |
737 WebGestureEvent webGestureEvent; | 754 WebGestureEvent webGestureEvent(WebInputEvent::GestureLongPress, |
738 webGestureEvent.type = WebInputEvent::GestureLongPress; | 755 WebInputEvent::NoModifiers, |
| 756 WebInputEvent::TimeStampForTesting); |
739 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 757 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
740 webGestureEvent.data.longPress.width = 30; | 758 webGestureEvent.data.longPress.width = 30; |
741 webGestureEvent.data.longPress.height = 30; | 759 webGestureEvent.data.longPress.height = 30; |
742 | 760 |
743 WebGestureEvent scaledGestureEvent = | 761 WebGestureEvent scaledGestureEvent = |
744 TransformWebGestureEvent(view, webGestureEvent); | 762 TransformWebGestureEvent(view, webGestureEvent); |
745 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 763 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
746 EXPECT_EQ(10, area.width()); | 764 EXPECT_EQ(10, area.width()); |
747 EXPECT_EQ(10, area.height()); | 765 EXPECT_EQ(10, area.height()); |
748 } | 766 } |
749 | 767 |
750 { | 768 { |
751 WebGestureEvent webGestureEvent; | 769 WebGestureEvent webGestureEvent(WebInputEvent::GestureTwoFingerTap, |
752 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 770 WebInputEvent::NoModifiers, |
| 771 WebInputEvent::TimeStampForTesting); |
753 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 772 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
754 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; | 773 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; |
755 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; | 774 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; |
756 | 775 |
757 WebGestureEvent scaledGestureEvent = | 776 WebGestureEvent scaledGestureEvent = |
758 TransformWebGestureEvent(view, webGestureEvent); | 777 TransformWebGestureEvent(view, webGestureEvent); |
759 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); | 778 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
760 EXPECT_EQ(10, area.width()); | 779 EXPECT_EQ(10, area.width()); |
761 EXPECT_EQ(10, area.height()); | 780 EXPECT_EQ(10, area.height()); |
762 } | 781 } |
763 | 782 |
764 { | 783 { |
765 WebTouchEvent webTouchEvent; | 784 WebTouchEvent webTouchEvent(WebInputEvent::TouchMove, |
766 webTouchEvent.type = WebInputEvent::TouchMove; | 785 WebInputEvent::NoModifiers, |
| 786 WebInputEvent::TimeStampForTesting); |
767 webTouchEvent.touchesLength = 1; | 787 webTouchEvent.touchesLength = 1; |
768 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 788 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
769 webTouchEvent.touches[0].screenPosition.x = 100; | 789 webTouchEvent.touches[0].screenPosition.x = 100; |
770 webTouchEvent.touches[0].screenPosition.y = 110; | 790 webTouchEvent.touches[0].screenPosition.y = 110; |
771 webTouchEvent.touches[0].position.x = 100; | 791 webTouchEvent.touches[0].position.x = 100; |
772 webTouchEvent.touches[0].position.y = 110; | 792 webTouchEvent.touches[0].position.y = 110; |
773 webTouchEvent.touches[0].radiusX = 30; | 793 webTouchEvent.touches[0].radiusX = 30; |
774 webTouchEvent.touches[0].radiusY = 30; | 794 webTouchEvent.touches[0].radiusY = 30; |
775 | 795 |
776 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 796 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
777 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); | 797 EXPECT_FLOAT_EQ(100, platformTouchBuilder.touchPoints()[0].screenPos().x()); |
778 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); | 798 EXPECT_FLOAT_EQ(110, platformTouchBuilder.touchPoints()[0].screenPos().y()); |
779 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); | 799 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().x()); |
780 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); | 800 EXPECT_FLOAT_EQ(30, platformTouchBuilder.touchPoints()[0].pos().y()); |
781 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width()); | 801 EXPECT_FLOAT_EQ(10, platformTouchBuilder.touchPoints()[0].radius().width()); |
782 EXPECT_FLOAT_EQ(10, | 802 EXPECT_FLOAT_EQ(10, |
783 platformTouchBuilder.touchPoints()[0].radius().height()); | 803 platformTouchBuilder.touchPoints()[0].radius().height()); |
784 } | 804 } |
785 | 805 |
786 { | 806 { |
787 WebTouchEvent webTouchEvent1; | 807 WebTouchEvent webTouchEvent1(WebInputEvent::TouchMove, |
788 webTouchEvent1.type = WebInputEvent::TouchMove; | 808 WebInputEvent::NoModifiers, |
| 809 WebInputEvent::TimeStampForTesting); |
789 webTouchEvent1.touchesLength = 1; | 810 webTouchEvent1.touchesLength = 1; |
790 webTouchEvent1.touches[0].state = WebTouchPoint::StateMoved; | 811 webTouchEvent1.touches[0].state = WebTouchPoint::StateMoved; |
791 webTouchEvent1.touches[0].screenPosition.x = 100; | 812 webTouchEvent1.touches[0].screenPosition.x = 100; |
792 webTouchEvent1.touches[0].screenPosition.y = 110; | 813 webTouchEvent1.touches[0].screenPosition.y = 110; |
793 webTouchEvent1.touches[0].position.x = 100; | 814 webTouchEvent1.touches[0].position.x = 100; |
794 webTouchEvent1.touches[0].position.y = 110; | 815 webTouchEvent1.touches[0].position.y = 110; |
795 webTouchEvent1.touches[0].radiusX = 30; | 816 webTouchEvent1.touches[0].radiusX = 30; |
796 webTouchEvent1.touches[0].radiusY = 30; | 817 webTouchEvent1.touches[0].radiusY = 30; |
797 | 818 |
798 WebTouchEvent webTouchEvent2 = webTouchEvent1; | 819 WebTouchEvent webTouchEvent2 = webTouchEvent1; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 FrameTestHelpers::WebViewHelper webViewHelper; | 855 FrameTestHelpers::WebViewHelper webViewHelper; |
835 WebViewImpl* webViewImpl = | 856 WebViewImpl* webViewImpl = |
836 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 857 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
837 int pageWidth = 640; | 858 int pageWidth = 640; |
838 int pageHeight = 480; | 859 int pageHeight = 480; |
839 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 860 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
840 webViewImpl->updateAllLifecyclePhases(); | 861 webViewImpl->updateAllLifecyclePhases(); |
841 | 862 |
842 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 863 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
843 { | 864 { |
844 WebGestureEvent webGestureEvent; | 865 WebGestureEvent webGestureEvent(WebInputEvent::GestureTap, |
845 webGestureEvent.type = WebInputEvent::GestureTap; | 866 WebInputEvent::NoModifiers, |
| 867 WebInputEvent::TimeStampForTesting); |
846 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 868 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
847 webGestureEvent.x = 10; | 869 webGestureEvent.x = 10; |
848 webGestureEvent.y = 10; | 870 webGestureEvent.y = 10; |
849 webGestureEvent.globalX = 10; | 871 webGestureEvent.globalX = 10; |
850 webGestureEvent.globalY = 10; | 872 webGestureEvent.globalY = 10; |
851 webGestureEvent.data.tap.tapCount = 1; | 873 webGestureEvent.data.tap.tapCount = 1; |
852 webGestureEvent.data.tap.width = 10; | 874 webGestureEvent.data.tap.width = 10; |
853 webGestureEvent.data.tap.height = 10; | 875 webGestureEvent.data.tap.height = 10; |
854 | 876 |
855 WebGestureEvent scaledGestureEvent = | 877 WebGestureEvent scaledGestureEvent = |
(...skipping 24 matching lines...) Expand all Loading... |
880 webViewImpl->updateAllLifecyclePhases(); | 902 webViewImpl->updateAllLifecyclePhases(); |
881 | 903 |
882 webViewImpl->setPageScaleFactor(2); | 904 webViewImpl->setPageScaleFactor(2); |
883 | 905 |
884 IntPoint visualOffset(35, 60); | 906 IntPoint visualOffset(35, 60); |
885 webViewImpl->page()->frameHost().visualViewport().setLocation(visualOffset); | 907 webViewImpl->page()->frameHost().visualViewport().setLocation(visualOffset); |
886 | 908 |
887 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 909 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
888 | 910 |
889 { | 911 { |
890 WebMouseEvent webMouseEvent; | 912 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
891 webMouseEvent.type = WebInputEvent::MouseMove; | 913 WebInputEvent::NoModifiers, |
| 914 WebInputEvent::TimeStampForTesting); |
892 webMouseEvent.x = 10; | 915 webMouseEvent.x = 10; |
893 webMouseEvent.y = 10; | 916 webMouseEvent.y = 10; |
894 webMouseEvent.windowX = 10; | 917 webMouseEvent.windowX = 10; |
895 webMouseEvent.windowY = 10; | 918 webMouseEvent.windowY = 10; |
896 webMouseEvent.globalX = 10; | 919 webMouseEvent.globalX = 10; |
897 webMouseEvent.globalY = 10; | 920 webMouseEvent.globalY = 10; |
898 | 921 |
899 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 922 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
900 EXPECT_EQ(5 + visualOffset.x(), platformMouseBuilder.position().x()); | 923 EXPECT_EQ(5 + visualOffset.x(), platformMouseBuilder.position().x()); |
901 EXPECT_EQ(5 + visualOffset.y(), platformMouseBuilder.position().y()); | 924 EXPECT_EQ(5 + visualOffset.y(), platformMouseBuilder.position().y()); |
902 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); | 925 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); |
903 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); | 926 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); |
904 } | 927 } |
905 | 928 |
906 { | 929 { |
907 WebMouseWheelEvent webMouseWheelEvent; | 930 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, |
908 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 931 WebInputEvent::NoModifiers, |
| 932 WebInputEvent::TimeStampForTesting); |
909 webMouseWheelEvent.x = 10; | 933 webMouseWheelEvent.x = 10; |
910 webMouseWheelEvent.y = 10; | 934 webMouseWheelEvent.y = 10; |
911 webMouseWheelEvent.windowX = 10; | 935 webMouseWheelEvent.windowX = 10; |
912 webMouseWheelEvent.windowY = 10; | 936 webMouseWheelEvent.windowY = 10; |
913 webMouseWheelEvent.globalX = 10; | 937 webMouseWheelEvent.globalX = 10; |
914 webMouseWheelEvent.globalY = 10; | 938 webMouseWheelEvent.globalY = 10; |
915 | 939 |
916 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | 940 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); |
917 EXPECT_EQ(5 + visualOffset.x(), platformWheelBuilder.position().x()); | 941 EXPECT_EQ(5 + visualOffset.x(), platformWheelBuilder.position().x()); |
918 EXPECT_EQ(5 + visualOffset.y(), platformWheelBuilder.position().y()); | 942 EXPECT_EQ(5 + visualOffset.y(), platformWheelBuilder.position().y()); |
919 EXPECT_EQ(10, platformWheelBuilder.globalPosition().x()); | 943 EXPECT_EQ(10, platformWheelBuilder.globalPosition().x()); |
920 EXPECT_EQ(10, platformWheelBuilder.globalPosition().y()); | 944 EXPECT_EQ(10, platformWheelBuilder.globalPosition().y()); |
921 } | 945 } |
922 | 946 |
923 { | 947 { |
924 WebGestureEvent webGestureEvent; | 948 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
925 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 949 WebInputEvent::NoModifiers, |
| 950 WebInputEvent::TimeStampForTesting); |
926 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 951 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
927 webGestureEvent.x = 10; | 952 webGestureEvent.x = 10; |
928 webGestureEvent.y = 10; | 953 webGestureEvent.y = 10; |
929 webGestureEvent.globalX = 10; | 954 webGestureEvent.globalX = 10; |
930 webGestureEvent.globalY = 10; | 955 webGestureEvent.globalY = 10; |
931 | 956 |
932 WebGestureEvent scaledGestureEvent = | 957 WebGestureEvent scaledGestureEvent = |
933 TransformWebGestureEvent(view, webGestureEvent); | 958 TransformWebGestureEvent(view, webGestureEvent); |
934 IntPoint position = | 959 IntPoint position = |
935 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); | 960 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
936 EXPECT_EQ(5 + visualOffset.x(), position.x()); | 961 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
937 EXPECT_EQ(5 + visualOffset.y(), position.y()); | 962 EXPECT_EQ(5 + visualOffset.y(), position.y()); |
938 EXPECT_EQ(10, scaledGestureEvent.globalX); | 963 EXPECT_EQ(10, scaledGestureEvent.globalX); |
939 EXPECT_EQ(10, scaledGestureEvent.globalY); | 964 EXPECT_EQ(10, scaledGestureEvent.globalY); |
940 } | 965 } |
941 | 966 |
942 { | 967 { |
943 WebTouchEvent webTouchEvent; | 968 WebTouchEvent webTouchEvent(WebInputEvent::TouchMove, |
944 webTouchEvent.type = WebInputEvent::TouchMove; | 969 WebInputEvent::NoModifiers, |
| 970 WebInputEvent::TimeStampForTesting); |
945 webTouchEvent.touchesLength = 1; | 971 webTouchEvent.touchesLength = 1; |
946 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 972 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
947 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 973 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
948 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 974 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
949 webTouchEvent.touches[0].position.x = 10.6f; | 975 webTouchEvent.touches[0].position.x = 10.6f; |
950 webTouchEvent.touches[0].position.y = 10.4f; | 976 webTouchEvent.touches[0].position.y = 10.4f; |
951 | 977 |
952 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); | 978 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].screenPosition.x); |
953 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); | 979 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].screenPosition.y); |
954 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); | 980 EXPECT_FLOAT_EQ(10.6f, webTouchEvent.touches[0].position.x); |
(...skipping 27 matching lines...) Expand all Loading... |
982 webViewImpl->updateAllLifecyclePhases(); | 1008 webViewImpl->updateAllLifecyclePhases(); |
983 | 1009 |
984 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 1010 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
985 | 1011 |
986 FloatSize elasticOverscroll(10, -20); | 1012 FloatSize elasticOverscroll(10, -20); |
987 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1013 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
988 elasticOverscroll, 1.0f, 0.0f); | 1014 elasticOverscroll, 1.0f, 0.0f); |
989 | 1015 |
990 // Just elastic overscroll. | 1016 // Just elastic overscroll. |
991 { | 1017 { |
992 WebMouseEvent webMouseEvent; | 1018 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
993 webMouseEvent.type = WebInputEvent::MouseMove; | 1019 WebInputEvent::NoModifiers, |
| 1020 WebInputEvent::TimeStampForTesting); |
994 webMouseEvent.x = 10; | 1021 webMouseEvent.x = 10; |
995 webMouseEvent.y = 50; | 1022 webMouseEvent.y = 50; |
996 webMouseEvent.windowX = 10; | 1023 webMouseEvent.windowX = 10; |
997 webMouseEvent.windowY = 50; | 1024 webMouseEvent.windowY = 50; |
998 webMouseEvent.globalX = 10; | 1025 webMouseEvent.globalX = 10; |
999 webMouseEvent.globalY = 50; | 1026 webMouseEvent.globalY = 50; |
1000 | 1027 |
1001 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 1028 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
1002 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), | 1029 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), |
1003 platformMouseBuilder.position().x()); | 1030 platformMouseBuilder.position().x()); |
1004 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), | 1031 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), |
1005 platformMouseBuilder.position().y()); | 1032 platformMouseBuilder.position().y()); |
1006 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); | 1033 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x()); |
1007 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); | 1034 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y()); |
1008 } | 1035 } |
1009 | 1036 |
1010 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, | 1037 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, |
1011 // but ensure that if it were to, the overscroll would be applied after the | 1038 // but ensure that if it were to, the overscroll would be applied after the |
1012 // pinch-zoom). | 1039 // pinch-zoom). |
1013 float pageScale = 2; | 1040 float pageScale = 2; |
1014 webViewImpl->setPageScaleFactor(pageScale); | 1041 webViewImpl->setPageScaleFactor(pageScale); |
1015 IntPoint visualOffset(35, 60); | 1042 IntPoint visualOffset(35, 60); |
1016 webViewImpl->page()->frameHost().visualViewport().setLocation(visualOffset); | 1043 webViewImpl->page()->frameHost().visualViewport().setLocation(visualOffset); |
1017 { | 1044 { |
1018 WebMouseEvent webMouseEvent; | 1045 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
1019 webMouseEvent.type = WebInputEvent::MouseMove; | 1046 WebInputEvent::NoModifiers, |
| 1047 WebInputEvent::TimeStampForTesting); |
1020 webMouseEvent.x = 10; | 1048 webMouseEvent.x = 10; |
1021 webMouseEvent.y = 10; | 1049 webMouseEvent.y = 10; |
1022 webMouseEvent.windowX = 10; | 1050 webMouseEvent.windowX = 10; |
1023 webMouseEvent.windowY = 10; | 1051 webMouseEvent.windowY = 10; |
1024 webMouseEvent.globalX = 10; | 1052 webMouseEvent.globalX = 10; |
1025 webMouseEvent.globalY = 10; | 1053 webMouseEvent.globalY = 10; |
1026 | 1054 |
1027 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 1055 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
1028 EXPECT_EQ(webMouseEvent.x / pageScale + visualOffset.x() + | 1056 EXPECT_EQ(webMouseEvent.x / pageScale + visualOffset.x() + |
1029 elasticOverscroll.width(), | 1057 elasticOverscroll.width(), |
(...skipping 23 matching lines...) Expand all Loading... |
1053 webViewImpl->updateAllLifecyclePhases(); | 1081 webViewImpl->updateAllLifecyclePhases(); |
1054 | 1082 |
1055 FloatSize elasticOverscroll(10, -20); | 1083 FloatSize elasticOverscroll(10, -20); |
1056 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1084 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
1057 elasticOverscroll, 1.0f, 0.0f); | 1085 elasticOverscroll, 1.0f, 0.0f); |
1058 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); | 1086 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
1059 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 1087 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
1060 | 1088 |
1061 // Just elastic overscroll. | 1089 // Just elastic overscroll. |
1062 { | 1090 { |
1063 WebMouseEvent webMouseEvent; | 1091 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
1064 webMouseEvent.type = WebInputEvent::MouseMove; | 1092 WebInputEvent::NoModifiers, |
| 1093 WebInputEvent::TimeStampForTesting); |
1065 webMouseEvent.x = 10; | 1094 webMouseEvent.x = 10; |
1066 webMouseEvent.y = 50; | 1095 webMouseEvent.y = 50; |
1067 webMouseEvent.windowX = 10; | 1096 webMouseEvent.windowX = 10; |
1068 webMouseEvent.windowY = 50; | 1097 webMouseEvent.windowY = 50; |
1069 webMouseEvent.globalX = 10; | 1098 webMouseEvent.globalX = 10; |
1070 webMouseEvent.globalY = 50; | 1099 webMouseEvent.globalY = 50; |
1071 | 1100 |
1072 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 1101 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
1073 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), | 1102 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), |
1074 platformMouseBuilder.position().x()); | 1103 platformMouseBuilder.position().x()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 WebViewImpl* webViewImpl = | 1188 WebViewImpl* webViewImpl = |
1160 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 1189 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
1161 int pageWidth = 640; | 1190 int pageWidth = 640; |
1162 int pageHeight = 480; | 1191 int pageHeight = 480; |
1163 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 1192 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
1164 webViewImpl->updateAllLifecyclePhases(); | 1193 webViewImpl->updateAllLifecyclePhases(); |
1165 | 1194 |
1166 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 1195 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
1167 | 1196 |
1168 { | 1197 { |
1169 WebMouseWheelEvent webMouseWheelEvent; | 1198 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, |
1170 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 1199 WebInputEvent::ControlKey, |
| 1200 WebInputEvent::TimeStampForTesting); |
1171 webMouseWheelEvent.x = 0; | 1201 webMouseWheelEvent.x = 0; |
1172 webMouseWheelEvent.y = 5; | 1202 webMouseWheelEvent.y = 5; |
1173 webMouseWheelEvent.deltaX = 10; | 1203 webMouseWheelEvent.deltaX = 10; |
1174 webMouseWheelEvent.deltaY = 15; | 1204 webMouseWheelEvent.deltaY = 15; |
1175 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | |
1176 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 1205 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
1177 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; | 1206 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; |
1178 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan; | 1207 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan; |
1179 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged; | 1208 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged; |
1180 | 1209 |
1181 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | 1210 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); |
1182 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 1211 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
1183 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 1212 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
1184 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 1213 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
1185 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 1214 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
1186 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); | 1215 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); |
1187 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1216 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
1188 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | 1217 EXPECT_EQ(platformWheelBuilder.getRailsMode(), |
1189 PlatformEvent::RailsModeHorizontal); | 1218 PlatformEvent::RailsModeHorizontal); |
1190 #if OS(MACOSX) | 1219 #if OS(MACOSX) |
1191 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase()); | 1220 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase()); |
1192 EXPECT_EQ(PlatformWheelEventPhaseChanged, | 1221 EXPECT_EQ(PlatformWheelEventPhaseChanged, |
1193 platformWheelBuilder.momentumPhase()); | 1222 platformWheelBuilder.momentumPhase()); |
1194 #endif | 1223 #endif |
1195 } | 1224 } |
1196 | 1225 |
1197 { | 1226 { |
1198 WebMouseWheelEvent webMouseWheelEvent; | 1227 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, |
1199 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 1228 WebInputEvent::ShiftKey, |
| 1229 WebInputEvent::TimeStampForTesting); |
1200 webMouseWheelEvent.x = 5; | 1230 webMouseWheelEvent.x = 5; |
1201 webMouseWheelEvent.y = 0; | 1231 webMouseWheelEvent.y = 0; |
1202 webMouseWheelEvent.deltaX = 15; | 1232 webMouseWheelEvent.deltaX = 15; |
1203 webMouseWheelEvent.deltaY = 10; | 1233 webMouseWheelEvent.deltaY = 10; |
1204 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; | |
1205 webMouseWheelEvent.hasPreciseScrollingDeltas = false; | 1234 webMouseWheelEvent.hasPreciseScrollingDeltas = false; |
1206 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; | 1235 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; |
1207 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; | 1236 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; |
1208 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; | 1237 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; |
1209 | 1238 |
1210 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | 1239 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); |
1211 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 1240 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
1212 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 1241 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
1213 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 1242 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
1214 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 1243 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
1215 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); | 1244 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); |
1216 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1245 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
1217 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | 1246 EXPECT_EQ(platformWheelBuilder.getRailsMode(), |
1218 PlatformEvent::RailsModeFree); | 1247 PlatformEvent::RailsModeFree); |
1219 #if OS(MACOSX) | 1248 #if OS(MACOSX) |
1220 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | 1249 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
1221 EXPECT_EQ(PlatformWheelEventPhaseNone, | 1250 EXPECT_EQ(PlatformWheelEventPhaseNone, |
1222 platformWheelBuilder.momentumPhase()); | 1251 platformWheelBuilder.momentumPhase()); |
1223 #endif | 1252 #endif |
1224 } | 1253 } |
1225 | 1254 |
1226 { | 1255 { |
1227 WebMouseWheelEvent webMouseWheelEvent; | 1256 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, |
1228 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | 1257 WebInputEvent::AltKey, |
| 1258 WebInputEvent::TimeStampForTesting); |
1229 webMouseWheelEvent.x = 5; | 1259 webMouseWheelEvent.x = 5; |
1230 webMouseWheelEvent.y = 0; | 1260 webMouseWheelEvent.y = 0; |
1231 webMouseWheelEvent.deltaX = 15; | 1261 webMouseWheelEvent.deltaX = 15; |
1232 webMouseWheelEvent.deltaY = 10; | 1262 webMouseWheelEvent.deltaY = 10; |
1233 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; | |
1234 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | 1263 webMouseWheelEvent.hasPreciseScrollingDeltas = true; |
1235 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; | 1264 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; |
1236 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; | 1265 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone; |
1237 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; | 1266 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone; |
1238 | 1267 |
1239 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); | 1268 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent); |
1240 EXPECT_EQ(5, platformWheelBuilder.position().x()); | 1269 EXPECT_EQ(5, platformWheelBuilder.position().x()); |
1241 EXPECT_EQ(0, platformWheelBuilder.position().y()); | 1270 EXPECT_EQ(0, platformWheelBuilder.position().y()); |
1242 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 1271 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
1243 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 1272 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
1244 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); | 1273 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); |
1245 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 1274 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
1246 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | 1275 EXPECT_EQ(platformWheelBuilder.getRailsMode(), |
1247 PlatformEvent::RailsModeVertical); | 1276 PlatformEvent::RailsModeVertical); |
1248 #if OS(MACOSX) | 1277 #if OS(MACOSX) |
1249 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | 1278 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
1250 EXPECT_EQ(PlatformWheelEventPhaseNone, | 1279 EXPECT_EQ(PlatformWheelEventPhaseNone, |
1251 platformWheelBuilder.momentumPhase()); | 1280 platformWheelBuilder.momentumPhase()); |
1252 #endif | 1281 #endif |
1253 } | 1282 } |
1254 } | 1283 } |
1255 | 1284 |
1256 } // namespace blink | 1285 } // namespace blink |
OLD | NEW |