| 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); | 722 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); |
| 723 | 723 |
| 724 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 724 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
| 725 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); | 725 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); |
| 726 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); | 726 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); |
| 727 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); | 727 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); |
| 728 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); | 728 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); |
| 729 } | 729 } |
| 730 } | 730 } |
| 731 | 731 |
| 732 TEST(WebInputEventConversionTest, ElasticOverscroll) |
| 733 { |
| 734 const std::string baseURL("http://www.test4.com/"); |
| 735 const std::string fileName("fixed_layout.html"); |
| 736 |
| 737 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
| 738 FrameTestHelpers::WebViewHelper webViewHelper; |
| 739 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, 0, setupVirtualViewportPinch); |
| 740 int pageWidth = 640; |
| 741 int pageHeight = 480; |
| 742 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 743 webViewImpl->layout(); |
| 744 |
| 745 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 746 |
| 747 FloatSize elasticOverscroll(10, -20); |
| 748 view->setElasticOverscroll(elasticOverscroll); |
| 749 |
| 750 // Just elastic overscroll. |
| 751 { |
| 752 WebMouseEvent webMouseEvent; |
| 753 webMouseEvent.type = WebInputEvent::MouseMove; |
| 754 webMouseEvent.x = 10; |
| 755 webMouseEvent.y = 50; |
| 756 webMouseEvent.windowX = 10; |
| 757 webMouseEvent.windowY = 50; |
| 758 webMouseEvent.globalX = 10; |
| 759 webMouseEvent.globalY = 50; |
| 760 |
| 761 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
| 762 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), platformMouseBuil
der.position().x()); |
| 763 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), platformMouseBui
lder.position().y()); |
| 764 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); |
| 765 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); |
| 766 } |
| 767 |
| 768 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, |
| 769 // but ensure that if it were to, the overscroll would be applied after the |
| 770 // pinch-zoom). |
| 771 float pageScale = 2; |
| 772 webViewImpl->setPageScaleFactor(pageScale); |
| 773 IntPoint pinchOffset(35, 60); |
| 774 webViewImpl->page()->frameHost().pinchViewport().setLocation(pinchOffset); |
| 775 { |
| 776 WebMouseEvent webMouseEvent; |
| 777 webMouseEvent.type = WebInputEvent::MouseMove; |
| 778 webMouseEvent.x = 10; |
| 779 webMouseEvent.y = 10; |
| 780 webMouseEvent.windowX = 10; |
| 781 webMouseEvent.windowY = 10; |
| 782 webMouseEvent.globalX = 10; |
| 783 webMouseEvent.globalY = 10; |
| 784 |
| 785 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
| 786 EXPECT_EQ(webMouseEvent.x / pageScale + pinchOffset.x() + elasticOverscr
oll.width(), platformMouseBuilder.position().x()); |
| 787 EXPECT_EQ(webMouseEvent.y / pageScale + pinchOffset.y() + elasticOverscr
oll.height(), platformMouseBuilder.position().y()); |
| 788 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); |
| 789 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); |
| 790 } |
| 791 } |
| 792 |
| 732 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) | 793 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) |
| 733 { | 794 { |
| 734 const std::string baseURL("http://www.test5.com/"); | 795 const std::string baseURL("http://www.test5.com/"); |
| 735 const std::string fileName("fixed_layout.html"); | 796 const std::string fileName("fixed_layout.html"); |
| 736 | 797 |
| 737 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 798 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
| 738 FrameTestHelpers::WebViewHelper webViewHelper; | 799 FrameTestHelpers::WebViewHelper webViewHelper; |
| 739 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 800 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
| 740 int pageWidth = 640; | 801 int pageWidth = 640; |
| 741 int pageHeight = 480; | 802 int pageHeight = 480; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; | 850 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent)
; |
| 790 EXPECT_EQ(0, platformWheelBuilder.position().x()); | 851 EXPECT_EQ(0, platformWheelBuilder.position().x()); |
| 791 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 852 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
| 792 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 853 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
| 793 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 854 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
| 794 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | 855 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
| 795 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 856 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
| 796 EXPECT_TRUE(platformWheelBuilder.canScroll()); | 857 EXPECT_TRUE(platformWheelBuilder.canScroll()); |
| 797 } | 858 } |
| 798 } | 859 } |
| 860 |
| 799 } // anonymous namespace | 861 } // anonymous namespace |
| OLD | NEW |