Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: Source/web/tests/WebInputEventConversionTest.cpp

Issue 819953002: Mac: Update scrollbar size and input position during impl-overscroll (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 view->setElasticOverscroll(FloatSize(10, -20));
Ken Russell (switch to Gerrit) 2014/12/22 23:46:08 Please factor the FloatSize into a separate variab
ccameron 2014/12/22 23:57:23 Done.
ccameron 2014/12/22 23:57:23 Done.
747
748 // Just elastic overscroll.
749 {
750 WebMouseEvent webMouseEvent;
751 webMouseEvent.type = WebInputEvent::MouseMove;
752 webMouseEvent.x = 10;
753 webMouseEvent.y = 50;
754 webMouseEvent.windowX = 10;
755 webMouseEvent.windowY = 50;
756 webMouseEvent.globalX = 10;
757 webMouseEvent.globalY = 50;
758
759 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
760 EXPECT_EQ(20, platformMouseBuilder.position().x());
761 EXPECT_EQ(30, platformMouseBuilder.position().y());
Ken Russell (switch to Gerrit) 2014/12/22 23:46:08 Would be better if these constants referred to the
ccameron 2014/12/22 23:57:23 Done.
762 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x());
763 EXPECT_EQ(50, platformMouseBuilder.globalPosition().y());
764 }
765
766 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen,
767 // but ensure that if it were to, the overscroll would be applied after the
768 // pinch-zoom).
769 webViewImpl->setPageScaleFactor(2);
770 IntPoint pinchOffset(35, 60);
771 webViewImpl->page()->frameHost().pinchViewport().setLocation(pinchOffset);
772 {
773 WebMouseEvent webMouseEvent;
774 webMouseEvent.type = WebInputEvent::MouseMove;
775 webMouseEvent.x = 10;
776 webMouseEvent.y = 10;
777 webMouseEvent.windowX = 10;
778 webMouseEvent.windowY = 10;
779 webMouseEvent.globalX = 10;
780 webMouseEvent.globalY = 10;
781
782 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
783 EXPECT_EQ(5 + pinchOffset.x() + 10, platformMouseBuilder.position().x()) ;
784 EXPECT_EQ(5 + pinchOffset.y() - 20, platformMouseBuilder.position().y()) ;
Ken Russell (switch to Gerrit) 2014/12/22 23:46:08 In particular, it would be better if the "+10" and
785 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x());
786 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y());
787 }
788 }
789
732 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) 790 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder)
733 { 791 {
734 const std::string baseURL("http://www.test5.com/"); 792 const std::string baseURL("http://www.test5.com/");
735 const std::string fileName("fixed_layout.html"); 793 const std::string fileName("fixed_layout.html");
736 794
737 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 795 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
738 FrameTestHelpers::WebViewHelper webViewHelper; 796 FrameTestHelpers::WebViewHelper webViewHelper;
739 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); 797 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true);
740 int pageWidth = 640; 798 int pageWidth = 640;
741 int pageHeight = 480; 799 int pageHeight = 480;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; 847 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
790 EXPECT_EQ(0, platformWheelBuilder.position().x()); 848 EXPECT_EQ(0, platformWheelBuilder.position().x());
791 EXPECT_EQ(5, platformWheelBuilder.position().y()); 849 EXPECT_EQ(5, platformWheelBuilder.position().y());
792 EXPECT_EQ(10, platformWheelBuilder.deltaX()); 850 EXPECT_EQ(10, platformWheelBuilder.deltaX());
793 EXPECT_EQ(15, platformWheelBuilder.deltaY()); 851 EXPECT_EQ(15, platformWheelBuilder.deltaY());
794 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); 852 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers());
795 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); 853 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
796 EXPECT_TRUE(platformWheelBuilder.canScroll()); 854 EXPECT_TRUE(platformWheelBuilder.canScroll());
797 } 855 }
798 } 856 }
857
799 } // anonymous namespace 858 } // anonymous namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698