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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 webGestureEvent.globalX = 20; | 352 webGestureEvent.globalX = 20; |
353 webGestureEvent.globalY = 22; | 353 webGestureEvent.globalY = 22; |
354 webGestureEvent.data.scrollUpdate.deltaX = 30; | 354 webGestureEvent.data.scrollUpdate.deltaX = 30; |
355 webGestureEvent.data.scrollUpdate.deltaY = 32; | 355 webGestureEvent.data.scrollUpdate.deltaY = 32; |
356 webGestureEvent.data.scrollUpdate.velocityX = 40; | 356 webGestureEvent.data.scrollUpdate.velocityX = 40; |
357 webGestureEvent.data.scrollUpdate.velocityY = 42; | 357 webGestureEvent.data.scrollUpdate.velocityY = 42; |
358 webGestureEvent.data.scrollUpdate.inertialPhase = | 358 webGestureEvent.data.scrollUpdate.inertialPhase = |
359 WebGestureEvent::MomentumPhase; | 359 WebGestureEvent::MomentumPhase; |
360 webGestureEvent.data.scrollUpdate.preventPropagation = true; | 360 webGestureEvent.data.scrollUpdate.preventPropagation = true; |
361 | 361 |
362 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 362 WebGestureEvent scaledGestureEvent = |
363 EXPECT_EQ(5, platformGestureBuilder.position().x()); | 363 TransformWebGestureEvent(view, webGestureEvent); |
364 EXPECT_EQ(6, platformGestureBuilder.position().y()); | 364 IntPoint position = |
365 EXPECT_EQ(20, platformGestureBuilder.globalPosition().x()); | 365 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
366 EXPECT_EQ(22, platformGestureBuilder.globalPosition().y()); | 366 EXPECT_EQ(5, position.x()); |
367 EXPECT_EQ(15, platformGestureBuilder.deltaX()); | 367 EXPECT_EQ(6, position.y()); |
368 EXPECT_EQ(16, platformGestureBuilder.deltaY()); | 368 EXPECT_EQ(20, scaledGestureEvent.globalX); |
| 369 EXPECT_EQ(22, scaledGestureEvent.globalY); |
| 370 EXPECT_EQ(15, scaledGestureEvent.deltaXInRootFrame()); |
| 371 EXPECT_EQ(16, scaledGestureEvent.deltaYInRootFrame()); |
369 // TODO: The velocity values may need to be scaled to page scale in | 372 // TODO: The velocity values may need to be scaled to page scale in |
370 // order to remain consist with delta values. | 373 // order to remain consist with delta values. |
371 EXPECT_EQ(40, platformGestureBuilder.velocityX()); | 374 EXPECT_EQ(40, scaledGestureEvent.velocityX()); |
372 EXPECT_EQ(42, platformGestureBuilder.velocityY()); | 375 EXPECT_EQ(42, scaledGestureEvent.velocityY()); |
373 EXPECT_EQ(ScrollInertialPhaseMomentum, | 376 EXPECT_EQ(WebGestureEvent::MomentumPhase, |
374 platformGestureBuilder.inertialPhase()); | 377 scaledGestureEvent.inertialPhase()); |
375 EXPECT_TRUE(platformGestureBuilder.preventPropagation()); | 378 EXPECT_TRUE(scaledGestureEvent.preventPropagation()); |
376 } | 379 } |
377 | 380 |
378 { | 381 { |
379 WebGestureEvent webGestureEvent; | 382 WebGestureEvent webGestureEvent; |
380 webGestureEvent.type = WebInputEvent::GestureScrollEnd; | 383 webGestureEvent.type = WebInputEvent::GestureScrollEnd; |
381 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 384 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
382 webGestureEvent.x = 10; | 385 webGestureEvent.x = 10; |
383 webGestureEvent.y = 12; | 386 webGestureEvent.y = 12; |
384 webGestureEvent.globalX = 20; | 387 webGestureEvent.globalX = 20; |
385 webGestureEvent.globalY = 22; | 388 webGestureEvent.globalY = 22; |
386 | 389 |
387 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 390 WebGestureEvent scaledGestureEvent = |
388 EXPECT_EQ(5, platformGestureBuilder.position().x()); | 391 TransformWebGestureEvent(view, webGestureEvent); |
389 EXPECT_EQ(6, platformGestureBuilder.position().y()); | 392 IntPoint position = |
390 EXPECT_EQ(20, platformGestureBuilder.globalPosition().x()); | 393 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
391 EXPECT_EQ(22, platformGestureBuilder.globalPosition().y()); | 394 EXPECT_EQ(5, position.x()); |
392 EXPECT_EQ(ScrollInertialPhaseUnknown, | 395 EXPECT_EQ(6, position.y()); |
393 platformGestureBuilder.inertialPhase()); | 396 EXPECT_EQ(20, scaledGestureEvent.globalX); |
| 397 EXPECT_EQ(22, scaledGestureEvent.globalY); |
| 398 EXPECT_EQ(WebGestureEvent::UnknownMomentumPhase, |
| 399 scaledGestureEvent.inertialPhase()); |
394 } | 400 } |
395 | 401 |
396 { | 402 { |
397 WebGestureEvent webGestureEvent; | 403 WebGestureEvent webGestureEvent; |
398 webGestureEvent.type = WebInputEvent::GestureTap; | 404 webGestureEvent.type = WebInputEvent::GestureTap; |
399 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 405 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
400 webGestureEvent.data.tap.width = 10; | 406 webGestureEvent.data.tap.width = 10; |
401 webGestureEvent.data.tap.height = 10; | 407 webGestureEvent.data.tap.height = 10; |
402 | 408 |
403 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 409 WebGestureEvent scaledGestureEvent = |
404 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 410 TransformWebGestureEvent(view, webGestureEvent); |
405 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 411 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 412 EXPECT_EQ(5, area.width()); |
| 413 EXPECT_EQ(5, area.height()); |
406 } | 414 } |
407 | 415 |
408 { | 416 { |
409 WebGestureEvent webGestureEvent; | 417 WebGestureEvent webGestureEvent; |
410 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 418 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; |
411 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 419 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
412 webGestureEvent.data.tap.width = 10; | 420 webGestureEvent.data.tap.width = 10; |
413 webGestureEvent.data.tap.height = 10; | 421 webGestureEvent.data.tap.height = 10; |
414 | 422 |
415 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 423 WebGestureEvent scaledGestureEvent = |
416 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 424 TransformWebGestureEvent(view, webGestureEvent); |
417 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 425 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 426 EXPECT_EQ(5, area.width()); |
| 427 EXPECT_EQ(5, area.height()); |
418 } | 428 } |
419 | 429 |
420 { | 430 { |
421 WebGestureEvent webGestureEvent; | 431 WebGestureEvent webGestureEvent; |
422 webGestureEvent.type = WebInputEvent::GestureTapDown; | 432 webGestureEvent.type = WebInputEvent::GestureTapDown; |
423 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 433 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
424 webGestureEvent.data.tapDown.width = 10; | 434 webGestureEvent.data.tapDown.width = 10; |
425 webGestureEvent.data.tapDown.height = 10; | 435 webGestureEvent.data.tapDown.height = 10; |
426 | 436 |
427 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 437 WebGestureEvent scaledGestureEvent = |
428 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 438 TransformWebGestureEvent(view, webGestureEvent); |
429 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 439 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 440 EXPECT_EQ(5, area.width()); |
| 441 EXPECT_EQ(5, area.height()); |
430 } | 442 } |
431 | 443 |
432 { | 444 { |
433 WebGestureEvent webGestureEvent; | 445 WebGestureEvent webGestureEvent; |
434 webGestureEvent.type = WebInputEvent::GestureShowPress; | 446 webGestureEvent.type = WebInputEvent::GestureShowPress; |
435 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 447 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
436 webGestureEvent.data.showPress.width = 10; | 448 webGestureEvent.data.showPress.width = 10; |
437 webGestureEvent.data.showPress.height = 10; | 449 webGestureEvent.data.showPress.height = 10; |
438 | 450 |
439 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 451 WebGestureEvent scaledGestureEvent = |
440 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 452 TransformWebGestureEvent(view, webGestureEvent); |
441 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 453 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 454 EXPECT_EQ(5, area.width()); |
| 455 EXPECT_EQ(5, area.height()); |
442 } | 456 } |
443 | 457 |
444 { | 458 { |
445 WebGestureEvent webGestureEvent; | 459 WebGestureEvent webGestureEvent; |
446 webGestureEvent.type = WebInputEvent::GestureLongPress; | 460 webGestureEvent.type = WebInputEvent::GestureLongPress; |
447 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 461 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
448 webGestureEvent.data.longPress.width = 10; | 462 webGestureEvent.data.longPress.width = 10; |
449 webGestureEvent.data.longPress.height = 10; | 463 webGestureEvent.data.longPress.height = 10; |
450 | 464 |
451 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 465 WebGestureEvent scaledGestureEvent = |
452 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 466 TransformWebGestureEvent(view, webGestureEvent); |
453 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 467 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 468 EXPECT_EQ(5, area.width()); |
| 469 EXPECT_EQ(5, area.height()); |
454 } | 470 } |
455 | 471 |
456 { | 472 { |
457 WebGestureEvent webGestureEvent; | 473 WebGestureEvent webGestureEvent; |
458 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 474 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; |
459 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 475 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
460 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; | 476 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; |
461 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; | 477 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; |
462 | 478 |
463 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 479 WebGestureEvent scaledGestureEvent = |
464 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 480 TransformWebGestureEvent(view, webGestureEvent); |
465 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 481 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 482 EXPECT_EQ(5, area.width()); |
| 483 EXPECT_EQ(5, area.height()); |
466 } | 484 } |
467 | 485 |
468 { | 486 { |
469 WebTouchEvent webTouchEvent; | 487 WebTouchEvent webTouchEvent; |
470 webTouchEvent.type = WebInputEvent::TouchMove; | 488 webTouchEvent.type = WebInputEvent::TouchMove; |
471 webTouchEvent.touchesLength = 1; | 489 webTouchEvent.touchesLength = 1; |
472 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 490 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
473 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 491 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
474 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 492 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
475 webTouchEvent.touches[0].position.x = 10.6f; | 493 webTouchEvent.touches[0].position.x = 10.6f; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, | 540 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, |
523 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 541 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
524 TimeTicks()); | 542 TimeTicks()); |
525 MouseEvent* mouseEvent = MouseEvent::create( | 543 MouseEvent* mouseEvent = MouseEvent::create( |
526 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); | 544 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); |
527 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); | 545 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); |
528 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); | 546 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); |
529 } | 547 } |
530 | 548 |
531 { | 549 { |
532 PlatformGestureEvent platformGestureEvent( | |
533 PlatformEvent::GestureScrollUpdate, IntPoint(10, 12), IntPoint(20, 22), | |
534 IntSize(25, 27), TimeTicks(), PlatformEvent::NoModifiers, | |
535 PlatformGestureSourceTouchscreen); | |
536 platformGestureEvent.setScrollGestureData(30, 32, ScrollByPrecisePixel, 40, | |
537 42, ScrollInertialPhaseMomentum, | |
538 true, -1 /* null plugin id */); | |
539 // FIXME: GestureEvent does not preserve velocityX, velocityY, | |
540 // or preventPropagation. It also fails to scale | |
541 // coordinates (x, y, deltaX, deltaY) to the page scale. This | |
542 // may lead to unexpected bugs if a PlatformGestureEvent is | |
543 // transformed into WebGestureEvent and back. | |
544 GestureEvent* gestureEvent = | |
545 GestureEvent::create(domWindow, platformGestureEvent); | |
546 WebGestureEventBuilder webGestureBuilder(documentLayoutView, *gestureEvent); | |
547 | |
548 EXPECT_EQ(10, webGestureBuilder.x); | |
549 EXPECT_EQ(12, webGestureBuilder.y); | |
550 EXPECT_EQ(20, webGestureBuilder.globalX); | |
551 EXPECT_EQ(22, webGestureBuilder.globalY); | |
552 EXPECT_EQ(30, webGestureBuilder.data.scrollUpdate.deltaX); | |
553 EXPECT_EQ(32, webGestureBuilder.data.scrollUpdate.deltaY); | |
554 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityX); | |
555 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityY); | |
556 EXPECT_EQ(WebGestureEvent::MomentumPhase, | |
557 webGestureBuilder.data.scrollUpdate.inertialPhase); | |
558 EXPECT_FALSE(webGestureBuilder.data.scrollUpdate.preventPropagation); | |
559 EXPECT_EQ(WebGestureDeviceTouchscreen, webGestureBuilder.sourceDevice); | |
560 } | |
561 | |
562 { | |
563 Touch* touch = | 550 Touch* touch = |
564 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, | 551 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, |
565 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), | 552 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), |
566 FloatSize(4, 4.5), 0, 0, String()); | 553 FloatSize(4, 4.5), 0, 0, String()); |
567 TouchList* touchList = TouchList::create(); | 554 TouchList* touchList = TouchList::create(); |
568 touchList->append(touch); | 555 touchList->append(touch); |
569 TouchEvent* touchEvent = TouchEvent::create( | 556 TouchEvent* touchEvent = TouchEvent::create( |
570 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, | 557 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, |
571 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), | 558 PlatformEvent::NoModifiers, false, false, true, TimeTicks(), |
572 TouchActionAuto, WebPointerProperties::PointerType::Touch); | 559 TouchActionAuto, WebPointerProperties::PointerType::Touch); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 WebGestureEvent webGestureEvent; | 658 WebGestureEvent webGestureEvent; |
672 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 659 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
673 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 660 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
674 webGestureEvent.x = 100; | 661 webGestureEvent.x = 100; |
675 webGestureEvent.y = 110; | 662 webGestureEvent.y = 110; |
676 webGestureEvent.globalX = 100; | 663 webGestureEvent.globalX = 100; |
677 webGestureEvent.globalY = 110; | 664 webGestureEvent.globalY = 110; |
678 webGestureEvent.data.scrollUpdate.deltaX = 60; | 665 webGestureEvent.data.scrollUpdate.deltaX = 60; |
679 webGestureEvent.data.scrollUpdate.deltaY = 60; | 666 webGestureEvent.data.scrollUpdate.deltaY = 60; |
680 | 667 |
681 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 668 WebGestureEvent scaledGestureEvent = |
682 EXPECT_EQ(30, platformGestureBuilder.position().x()); | 669 TransformWebGestureEvent(view, webGestureEvent); |
683 EXPECT_EQ(30, platformGestureBuilder.position().y()); | 670 FloatPoint position = scaledGestureEvent.positionInRootFrame(); |
684 EXPECT_EQ(100, platformGestureBuilder.globalPosition().x()); | 671 |
685 EXPECT_EQ(110, platformGestureBuilder.globalPosition().y()); | 672 EXPECT_FLOAT_EQ(30, position.x()); |
686 EXPECT_EQ(20, platformGestureBuilder.deltaX()); | 673 EXPECT_FLOAT_EQ(30, position.y()); |
687 EXPECT_EQ(20, platformGestureBuilder.deltaY()); | 674 EXPECT_EQ(100, scaledGestureEvent.globalX); |
| 675 EXPECT_EQ(110, scaledGestureEvent.globalY); |
| 676 EXPECT_EQ(20, scaledGestureEvent.deltaXInRootFrame()); |
| 677 EXPECT_EQ(20, scaledGestureEvent.deltaYInRootFrame()); |
688 } | 678 } |
689 | 679 |
690 { | 680 { |
691 WebGestureEvent webGestureEvent; | 681 WebGestureEvent webGestureEvent; |
692 webGestureEvent.type = WebInputEvent::GestureTap; | 682 webGestureEvent.type = WebInputEvent::GestureTap; |
693 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 683 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
694 webGestureEvent.data.tap.width = 30; | 684 webGestureEvent.data.tap.width = 30; |
695 webGestureEvent.data.tap.height = 30; | 685 webGestureEvent.data.tap.height = 30; |
696 | 686 |
697 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 687 WebGestureEvent scaledGestureEvent = |
698 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 688 TransformWebGestureEvent(view, webGestureEvent); |
699 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 689 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 690 EXPECT_EQ(10, area.width()); |
| 691 EXPECT_EQ(10, area.height()); |
700 } | 692 } |
701 | 693 |
702 { | 694 { |
703 WebGestureEvent webGestureEvent; | 695 WebGestureEvent webGestureEvent; |
704 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 696 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; |
705 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 697 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
706 webGestureEvent.data.tap.width = 30; | 698 webGestureEvent.data.tap.width = 30; |
707 webGestureEvent.data.tap.height = 30; | 699 webGestureEvent.data.tap.height = 30; |
708 | 700 |
709 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 701 WebGestureEvent scaledGestureEvent = |
710 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 702 TransformWebGestureEvent(view, webGestureEvent); |
711 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 703 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 704 EXPECT_EQ(10, area.width()); |
| 705 EXPECT_EQ(10, area.height()); |
712 } | 706 } |
713 | 707 |
714 { | 708 { |
715 WebGestureEvent webGestureEvent; | 709 WebGestureEvent webGestureEvent; |
716 webGestureEvent.type = WebInputEvent::GestureTapDown; | 710 webGestureEvent.type = WebInputEvent::GestureTapDown; |
717 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 711 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
718 webGestureEvent.data.tapDown.width = 30; | 712 webGestureEvent.data.tapDown.width = 30; |
719 webGestureEvent.data.tapDown.height = 30; | 713 webGestureEvent.data.tapDown.height = 30; |
720 | 714 |
721 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 715 WebGestureEvent scaledGestureEvent = |
722 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 716 TransformWebGestureEvent(view, webGestureEvent); |
723 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 717 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 718 EXPECT_EQ(10, area.width()); |
| 719 EXPECT_EQ(10, area.height()); |
724 } | 720 } |
725 | 721 |
726 { | 722 { |
727 WebGestureEvent webGestureEvent; | 723 WebGestureEvent webGestureEvent; |
728 webGestureEvent.type = WebInputEvent::GestureShowPress; | 724 webGestureEvent.type = WebInputEvent::GestureShowPress; |
729 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 725 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
730 webGestureEvent.data.showPress.width = 30; | 726 webGestureEvent.data.showPress.width = 30; |
731 webGestureEvent.data.showPress.height = 30; | 727 webGestureEvent.data.showPress.height = 30; |
732 | 728 |
733 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 729 WebGestureEvent scaledGestureEvent = |
734 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 730 TransformWebGestureEvent(view, webGestureEvent); |
735 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 731 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 732 EXPECT_EQ(10, area.width()); |
| 733 EXPECT_EQ(10, area.height()); |
736 } | 734 } |
737 | 735 |
738 { | 736 { |
739 WebGestureEvent webGestureEvent; | 737 WebGestureEvent webGestureEvent; |
740 webGestureEvent.type = WebInputEvent::GestureLongPress; | 738 webGestureEvent.type = WebInputEvent::GestureLongPress; |
741 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 739 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
742 webGestureEvent.data.longPress.width = 30; | 740 webGestureEvent.data.longPress.width = 30; |
743 webGestureEvent.data.longPress.height = 30; | 741 webGestureEvent.data.longPress.height = 30; |
744 | 742 |
745 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 743 WebGestureEvent scaledGestureEvent = |
746 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 744 TransformWebGestureEvent(view, webGestureEvent); |
747 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 745 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 746 EXPECT_EQ(10, area.width()); |
| 747 EXPECT_EQ(10, area.height()); |
748 } | 748 } |
749 | 749 |
750 { | 750 { |
751 WebGestureEvent webGestureEvent; | 751 WebGestureEvent webGestureEvent; |
752 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 752 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; |
753 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 753 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
754 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; | 754 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; |
755 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; | 755 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; |
756 | 756 |
757 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 757 WebGestureEvent scaledGestureEvent = |
758 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 758 TransformWebGestureEvent(view, webGestureEvent); |
759 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 759 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 760 EXPECT_EQ(10, area.width()); |
| 761 EXPECT_EQ(10, area.height()); |
760 } | 762 } |
761 | 763 |
762 { | 764 { |
763 WebTouchEvent webTouchEvent; | 765 WebTouchEvent webTouchEvent; |
764 webTouchEvent.type = WebInputEvent::TouchMove; | 766 webTouchEvent.type = WebInputEvent::TouchMove; |
765 webTouchEvent.touchesLength = 1; | 767 webTouchEvent.touchesLength = 1; |
766 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 768 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
767 webTouchEvent.touches[0].screenPosition.x = 100; | 769 webTouchEvent.touches[0].screenPosition.x = 100; |
768 webTouchEvent.touches[0].screenPosition.y = 110; | 770 webTouchEvent.touches[0].screenPosition.y = 110; |
769 webTouchEvent.touches[0].position.x = 100; | 771 webTouchEvent.touches[0].position.x = 100; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 WebString::fromUTF8("fixed_layout.html")); | 833 WebString::fromUTF8("fixed_layout.html")); |
832 FrameTestHelpers::WebViewHelper webViewHelper; | 834 FrameTestHelpers::WebViewHelper webViewHelper; |
833 WebViewImpl* webViewImpl = | 835 WebViewImpl* webViewImpl = |
834 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 836 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
835 int pageWidth = 640; | 837 int pageWidth = 640; |
836 int pageHeight = 480; | 838 int pageHeight = 480; |
837 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 839 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
838 webViewImpl->updateAllLifecyclePhases(); | 840 webViewImpl->updateAllLifecyclePhases(); |
839 | 841 |
840 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 842 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
841 Document* document = | |
842 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | |
843 LocalDOMWindow* domWindow = document->domWindow(); | |
844 LayoutViewItem documentLayoutView = document->layoutViewItem(); | |
845 | |
846 { | 843 { |
847 WebGestureEvent webGestureEvent; | 844 WebGestureEvent webGestureEvent; |
848 webGestureEvent.type = WebInputEvent::GestureTap; | 845 webGestureEvent.type = WebInputEvent::GestureTap; |
849 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 846 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
850 webGestureEvent.x = 10; | 847 webGestureEvent.x = 10; |
851 webGestureEvent.y = 10; | 848 webGestureEvent.y = 10; |
852 webGestureEvent.globalX = 10; | 849 webGestureEvent.globalX = 10; |
853 webGestureEvent.globalY = 10; | 850 webGestureEvent.globalY = 10; |
854 webGestureEvent.data.tap.tapCount = 1; | 851 webGestureEvent.data.tap.tapCount = 1; |
855 webGestureEvent.data.tap.width = 10; | 852 webGestureEvent.data.tap.width = 10; |
856 webGestureEvent.data.tap.height = 10; | 853 webGestureEvent.data.tap.height = 10; |
857 | 854 |
858 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 855 WebGestureEvent scaledGestureEvent = |
859 EXPECT_EQ(10.f, platformGestureBuilder.position().x()); | 856 TransformWebGestureEvent(view, webGestureEvent); |
860 EXPECT_EQ(10.f, platformGestureBuilder.position().y()); | 857 IntPoint position = |
861 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().x()); | 858 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
862 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().y()); | 859 EXPECT_EQ(10.f, position.x()); |
863 EXPECT_EQ(1, platformGestureBuilder.tapCount()); | 860 EXPECT_EQ(10.f, position.y()); |
864 | 861 EXPECT_EQ(10.f, scaledGestureEvent.globalX); |
865 GestureEvent* coreGestureEvent = | 862 EXPECT_EQ(10.f, scaledGestureEvent.globalY); |
866 GestureEvent::create(domWindow, platformGestureBuilder); | 863 EXPECT_EQ(1, scaledGestureEvent.tapCount()); |
867 WebGestureEventBuilder recreatedWebGestureEvent(documentLayoutView, | |
868 *coreGestureEvent); | |
869 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type); | |
870 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x); | |
871 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y); | |
872 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX); | |
873 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY); | |
874 EXPECT_EQ(webGestureEvent.data.tap.tapCount, | |
875 recreatedWebGestureEvent.data.tap.tapCount); | |
876 } | 864 } |
877 } | 865 } |
878 | 866 |
879 TEST(WebInputEventConversionTest, VisualViewportOffset) { | 867 TEST(WebInputEventConversionTest, VisualViewportOffset) { |
880 const std::string baseURL("http://www.test4.com/"); | 868 const std::string baseURL("http://www.test4.com/"); |
881 const std::string fileName("fixed_layout.html"); | 869 const std::string fileName("fixed_layout.html"); |
882 | 870 |
883 URLTestHelpers::registerMockedURLFromBaseURL( | 871 URLTestHelpers::registerMockedURLFromBaseURL( |
884 WebString::fromUTF8(baseURL.c_str()), | 872 WebString::fromUTF8(baseURL.c_str()), |
885 WebString::fromUTF8("fixed_layout.html")); | 873 WebString::fromUTF8("fixed_layout.html")); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 | 922 |
935 { | 923 { |
936 WebGestureEvent webGestureEvent; | 924 WebGestureEvent webGestureEvent; |
937 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 925 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
938 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 926 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
939 webGestureEvent.x = 10; | 927 webGestureEvent.x = 10; |
940 webGestureEvent.y = 10; | 928 webGestureEvent.y = 10; |
941 webGestureEvent.globalX = 10; | 929 webGestureEvent.globalX = 10; |
942 webGestureEvent.globalY = 10; | 930 webGestureEvent.globalY = 10; |
943 | 931 |
944 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 932 WebGestureEvent scaledGestureEvent = |
945 EXPECT_EQ(5 + visualOffset.x(), platformGestureBuilder.position().x()); | 933 TransformWebGestureEvent(view, webGestureEvent); |
946 EXPECT_EQ(5 + visualOffset.y(), platformGestureBuilder.position().y()); | 934 IntPoint position = |
947 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 935 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
948 EXPECT_EQ(10, platformGestureBuilder.globalPosition().y()); | 936 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
| 937 EXPECT_EQ(5 + visualOffset.y(), position.y()); |
| 938 EXPECT_EQ(10, scaledGestureEvent.globalX); |
| 939 EXPECT_EQ(10, scaledGestureEvent.globalY); |
949 } | 940 } |
950 | 941 |
951 { | 942 { |
952 WebTouchEvent webTouchEvent; | 943 WebTouchEvent webTouchEvent; |
953 webTouchEvent.type = WebInputEvent::TouchMove; | 944 webTouchEvent.type = WebInputEvent::TouchMove; |
954 webTouchEvent.touchesLength = 1; | 945 webTouchEvent.touchesLength = 1; |
955 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 946 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
956 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 947 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
957 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 948 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
958 webTouchEvent.touches[0].position.x = 10.6f; | 949 webTouchEvent.touches[0].position.x = 10.6f; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | 1246 EXPECT_EQ(platformWheelBuilder.getRailsMode(), |
1256 PlatformEvent::RailsModeVertical); | 1247 PlatformEvent::RailsModeVertical); |
1257 #if OS(MACOSX) | 1248 #if OS(MACOSX) |
1258 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | 1249 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
1259 EXPECT_EQ(PlatformWheelEventPhaseNone, | 1250 EXPECT_EQ(PlatformWheelEventPhaseNone, |
1260 platformWheelBuilder.momentumPhase()); | 1251 platformWheelBuilder.momentumPhase()); |
1261 #endif | 1252 #endif |
1262 } | 1253 } |
1263 } | 1254 } |
1264 | 1255 |
1265 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) { | |
1266 const std::string baseURL("http://www.test9.com/"); | |
1267 const std::string fileName("fixed_layout.html"); | |
1268 | |
1269 URLTestHelpers::registerMockedURLFromBaseURL( | |
1270 WebString::fromUTF8(baseURL.c_str()), | |
1271 WebString::fromUTF8("fixed_layout.html")); | |
1272 FrameTestHelpers::WebViewHelper webViewHelper; | |
1273 WebViewImpl* webViewImpl = | |
1274 webViewHelper.initializeAndLoad(baseURL + fileName, true); | |
1275 int pageWidth = 640; | |
1276 int pageHeight = 480; | |
1277 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
1278 webViewImpl->updateAllLifecyclePhases(); | |
1279 | |
1280 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | |
1281 | |
1282 { | |
1283 WebGestureEvent webGestureEvent; | |
1284 webGestureEvent.type = WebInputEvent::GestureScrollBegin; | |
1285 webGestureEvent.x = 0; | |
1286 webGestureEvent.y = 5; | |
1287 webGestureEvent.globalX = 10; | |
1288 webGestureEvent.globalY = 15; | |
1289 webGestureEvent.sourceDevice = WebGestureDeviceTouchpad; | |
1290 webGestureEvent.resendingPluginId = 2; | |
1291 webGestureEvent.data.scrollBegin.inertialPhase = | |
1292 WebGestureEvent::MomentumPhase; | |
1293 webGestureEvent.data.scrollBegin.synthetic = true; | |
1294 webGestureEvent.data.scrollBegin.deltaXHint = 100; | |
1295 webGestureEvent.data.scrollBegin.deltaYHint = 10; | |
1296 webGestureEvent.data.scrollBegin.deltaHintUnits = WebGestureEvent::Pixels; | |
1297 webGestureEvent.uniqueTouchEventId = 12345U; | |
1298 | |
1299 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | |
1300 EXPECT_EQ(PlatformGestureSourceTouchpad, platformGestureBuilder.source()); | |
1301 EXPECT_EQ(2, platformGestureBuilder.resendingPluginId()); | |
1302 EXPECT_EQ(0, platformGestureBuilder.position().x()); | |
1303 EXPECT_EQ(5, platformGestureBuilder.position().y()); | |
1304 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | |
1305 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | |
1306 EXPECT_EQ(ScrollInertialPhaseMomentum, | |
1307 platformGestureBuilder.inertialPhase()); | |
1308 EXPECT_TRUE(platformGestureBuilder.synthetic()); | |
1309 EXPECT_EQ(100, platformGestureBuilder.deltaX()); | |
1310 EXPECT_EQ(10, platformGestureBuilder.deltaY()); | |
1311 EXPECT_EQ(ScrollGranularity::ScrollByPixel, | |
1312 platformGestureBuilder.deltaUnits()); | |
1313 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | |
1314 } | |
1315 | |
1316 { | |
1317 WebGestureEvent webGestureEvent; | |
1318 webGestureEvent.type = WebInputEvent::GestureScrollEnd; | |
1319 webGestureEvent.x = 0; | |
1320 webGestureEvent.y = 5; | |
1321 webGestureEvent.globalX = 10; | |
1322 webGestureEvent.globalY = 15; | |
1323 webGestureEvent.sourceDevice = WebGestureDeviceTouchpad; | |
1324 webGestureEvent.resendingPluginId = 2; | |
1325 webGestureEvent.data.scrollEnd.inertialPhase = | |
1326 WebGestureEvent::NonMomentumPhase; | |
1327 webGestureEvent.data.scrollEnd.synthetic = true; | |
1328 webGestureEvent.data.scrollEnd.deltaUnits = WebGestureEvent::Page; | |
1329 webGestureEvent.uniqueTouchEventId = 12345U; | |
1330 | |
1331 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | |
1332 EXPECT_EQ(PlatformGestureSourceTouchpad, platformGestureBuilder.source()); | |
1333 EXPECT_EQ(2, platformGestureBuilder.resendingPluginId()); | |
1334 EXPECT_EQ(0, platformGestureBuilder.position().x()); | |
1335 EXPECT_EQ(5, platformGestureBuilder.position().y()); | |
1336 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | |
1337 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | |
1338 EXPECT_EQ(ScrollInertialPhaseNonMomentum, | |
1339 platformGestureBuilder.inertialPhase()); | |
1340 EXPECT_TRUE(platformGestureBuilder.synthetic()); | |
1341 EXPECT_EQ(ScrollGranularity::ScrollByPage, | |
1342 platformGestureBuilder.deltaUnits()); | |
1343 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | |
1344 } | |
1345 } | |
1346 | |
1347 } // namespace blink | 1256 } // namespace blink |
OLD | NEW |