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

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

Issue 1018183002: Add rails to input wheel events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More plumbing and tests Created 5 years, 9 months 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
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | public/web/WebInputEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 FrameTestHelpers::WebViewHelper webViewHelper; 821 FrameTestHelpers::WebViewHelper webViewHelper;
822 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); 822 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true);
823 int pageWidth = 640; 823 int pageWidth = 640;
824 int pageHeight = 480; 824 int pageHeight = 480;
825 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 825 webViewImpl->resize(WebSize(pageWidth, pageHeight));
826 webViewImpl->layout(); 826 webViewImpl->layout();
827 827
828 RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->ma inFrame())->document(); 828 RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->ma inFrame())->document();
829 RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 10), 829 RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 10),
830 WheelEvent::DOM_DELTA_PAGE, document.get()->domWindow(), IntPoint(2, 6) , IntPoint(10, 30), 830 WheelEvent::DOM_DELTA_PAGE, document.get()->domWindow(), IntPoint(2, 6) , IntPoint(10, 30),
831 true, false, false, false, 0, true, true); 831 true, false, false, false, 0, true, true, Event::RailsModeHorizontal);
832 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->ma inFrame())->view(), document.get()->layoutView(), *event); 832 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->ma inFrame())->view(), document.get()->layoutView(), *event);
833 EXPECT_EQ(1, webMouseWheel.wheelTicksX); 833 EXPECT_EQ(1, webMouseWheel.wheelTicksX);
834 EXPECT_EQ(3, webMouseWheel.wheelTicksY); 834 EXPECT_EQ(3, webMouseWheel.wheelTicksY);
835 EXPECT_EQ(5, webMouseWheel.deltaX); 835 EXPECT_EQ(5, webMouseWheel.deltaX);
836 EXPECT_EQ(10, webMouseWheel.deltaY); 836 EXPECT_EQ(10, webMouseWheel.deltaY);
837 EXPECT_EQ(2, webMouseWheel.globalX); 837 EXPECT_EQ(2, webMouseWheel.globalX);
838 EXPECT_EQ(6, webMouseWheel.globalY); 838 EXPECT_EQ(6, webMouseWheel.globalY);
839 EXPECT_EQ(10, webMouseWheel.windowX); 839 EXPECT_EQ(10, webMouseWheel.windowX);
840 EXPECT_EQ(30, webMouseWheel.windowY); 840 EXPECT_EQ(30, webMouseWheel.windowY);
841 EXPECT_TRUE(webMouseWheel.scrollByPage); 841 EXPECT_TRUE(webMouseWheel.scrollByPage);
842 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); 842 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers);
843 EXPECT_TRUE(webMouseWheel.canScroll); 843 EXPECT_TRUE(webMouseWheel.canScroll);
844 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode);
844 } 845 }
845 846
846 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) 847 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder)
847 { 848 {
848 const std::string baseURL("http://www.test6.com/"); 849 const std::string baseURL("http://www.test6.com/");
849 const std::string fileName("fixed_layout.html"); 850 const std::string fileName("fixed_layout.html");
850 851
851 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 852 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
852 FrameTestHelpers::WebViewHelper webViewHelper; 853 FrameTestHelpers::WebViewHelper webViewHelper;
853 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); 854 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true);
854 int pageWidth = 640; 855 int pageWidth = 640;
855 int pageHeight = 480; 856 int pageHeight = 480;
856 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 857 webViewImpl->resize(WebSize(pageWidth, pageHeight));
857 webViewImpl->layout(); 858 webViewImpl->layout();
858 859
859 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); 860 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view();
860 861
861 { 862 {
862 WebMouseWheelEvent webMouseWheelEvent; 863 WebMouseWheelEvent webMouseWheelEvent;
863 webMouseWheelEvent.type = WebInputEvent::MouseWheel; 864 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
864 webMouseWheelEvent.x = 0; 865 webMouseWheelEvent.x = 0;
865 webMouseWheelEvent.y = 5; 866 webMouseWheelEvent.y = 5;
866 webMouseWheelEvent.deltaX = 10; 867 webMouseWheelEvent.deltaX = 10;
867 webMouseWheelEvent.deltaY = 15; 868 webMouseWheelEvent.deltaY = 15;
868 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; 869 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey;
869 webMouseWheelEvent.hasPreciseScrollingDeltas = true; 870 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
870 webMouseWheelEvent.canScroll = true; 871 webMouseWheelEvent.canScroll = true;
872 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal;
871 873
872 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; 874 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
873 EXPECT_EQ(0, platformWheelBuilder.position().x()); 875 EXPECT_EQ(0, platformWheelBuilder.position().x());
874 EXPECT_EQ(5, platformWheelBuilder.position().y()); 876 EXPECT_EQ(5, platformWheelBuilder.position().y());
875 EXPECT_EQ(10, platformWheelBuilder.deltaX()); 877 EXPECT_EQ(10, platformWheelBuilder.deltaX());
876 EXPECT_EQ(15, platformWheelBuilder.deltaY()); 878 EXPECT_EQ(15, platformWheelBuilder.deltaY());
877 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); 879 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.modifiers());
878 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); 880 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
879 EXPECT_TRUE(platformWheelBuilder.canScroll()); 881 EXPECT_TRUE(platformWheelBuilder.canScroll());
882 EXPECT_EQ(platformWheelBuilder.railsMode(), PlatformEvent::RailsModeHori zontal);
883 }
884
885 {
886 WebMouseWheelEvent webMouseWheelEvent;
887 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
888 webMouseWheelEvent.x = 5;
889 webMouseWheelEvent.y = 0;
890 webMouseWheelEvent.deltaX = 15;
891 webMouseWheelEvent.deltaY = 10;
892 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey;
893 webMouseWheelEvent.hasPreciseScrollingDeltas = false;
894 webMouseWheelEvent.canScroll = false;
895 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree;
896
897 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
898 EXPECT_EQ(5, platformWheelBuilder.position().x());
899 EXPECT_EQ(0, platformWheelBuilder.position().y());
900 EXPECT_EQ(15, platformWheelBuilder.deltaX());
901 EXPECT_EQ(10, platformWheelBuilder.deltaY());
902 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.modifiers());
903 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas());
904 EXPECT_FALSE(platformWheelBuilder.canScroll());
905 EXPECT_EQ(platformWheelBuilder.railsMode(), PlatformEvent::RailsModeFree );
906 }
907
908 {
909 WebMouseWheelEvent webMouseWheelEvent;
910 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
911 webMouseWheelEvent.x = 5;
912 webMouseWheelEvent.y = 0;
913 webMouseWheelEvent.deltaX = 15;
914 webMouseWheelEvent.deltaY = 10;
915 webMouseWheelEvent.modifiers = WebInputEvent::AltKey;
916 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
917 webMouseWheelEvent.canScroll = false;
918 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical;
919
920 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
921 EXPECT_EQ(5, platformWheelBuilder.position().x());
922 EXPECT_EQ(0, platformWheelBuilder.position().y());
923 EXPECT_EQ(15, platformWheelBuilder.deltaX());
924 EXPECT_EQ(10, platformWheelBuilder.deltaY());
925 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.modifiers());
926 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
927 EXPECT_FALSE(platformWheelBuilder.canScroll());
928 EXPECT_EQ(platformWheelBuilder.railsMode(), PlatformEvent::RailsModeVert ical);
880 } 929 }
881 } 930 }
882 931
883 } // anonymous namespace 932 } // anonymous namespace
OLDNEW
« no previous file with comments | « Source/web/WebInputEventConversion.cpp ('k') | public/web/WebInputEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698