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

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

Issue 2227803003: Plumb phase/momentum for WheelEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Non-Mac compile. Created 4 years, 4 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
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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 int pageWidth = 640; 902 int pageWidth = 640;
903 int pageHeight = 480; 903 int pageHeight = 480;
904 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 904 webViewImpl->resize(WebSize(pageWidth, pageHeight));
905 webViewImpl->updateAllLifecyclePhases(); 905 webViewImpl->updateAllLifecyclePhases();
906 906
907 Document* document = toLocalFrame(webViewImpl->page()->mainFrame())->documen t(); 907 Document* document = toLocalFrame(webViewImpl->page()->mainFrame())->documen t();
908 { 908 {
909 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1 0), 909 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1 0),
910 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In tPoint(10, 30), 910 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In tPoint(10, 30),
911 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, 911 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */,
912 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, tr ue /*cancelable*/); 912 true /* hasPreciseScrollingDeltas */, Event::RailsModeHorizontal, tr ue /*cancelable*/
913 #if OS(MACOSX)
914 , WheelEventPhaseBegan, WheelEventPhaseChanged
915 #endif
916 );
913 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page() ->mainFrame())->view(), document->layoutViewItem(), *event); 917 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page() ->mainFrame())->view(), document->layoutViewItem(), *event);
914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); 918 EXPECT_EQ(1, webMouseWheel.wheelTicksX);
915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); 919 EXPECT_EQ(3, webMouseWheel.wheelTicksY);
916 EXPECT_EQ(5, webMouseWheel.deltaX); 920 EXPECT_EQ(5, webMouseWheel.deltaX);
917 EXPECT_EQ(10, webMouseWheel.deltaY); 921 EXPECT_EQ(10, webMouseWheel.deltaY);
918 EXPECT_EQ(2, webMouseWheel.globalX); 922 EXPECT_EQ(2, webMouseWheel.globalX);
919 EXPECT_EQ(6, webMouseWheel.globalY); 923 EXPECT_EQ(6, webMouseWheel.globalY);
920 EXPECT_EQ(10, webMouseWheel.windowX); 924 EXPECT_EQ(10, webMouseWheel.windowX);
921 EXPECT_EQ(30, webMouseWheel.windowY); 925 EXPECT_EQ(30, webMouseWheel.windowY);
922 EXPECT_TRUE(webMouseWheel.scrollByPage); 926 EXPECT_TRUE(webMouseWheel.scrollByPage);
923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); 927 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers);
924 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); 928 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode);
925 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); 929 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas);
926 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); 930 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType);
931 #if OS(MACOSX)
932 EXPECT_EQ(WebMouseWheelEvent::PhaseBegan, webMouseWheel.phase);
933 EXPECT_EQ(WebMouseWheelEvent::PhaseChanged, webMouseWheel.momentumPhase) ;
934 #endif
927 } 935 }
928 936
929 { 937 {
930 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1 0), 938 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1 0),
931 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In tPoint(10, 30), 939 WheelEvent::kDomDeltaPage, document->domWindow(), IntPoint(2, 6), In tPoint(10, 30),
932 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr eciseScrollingDeltas */, Event::RailsModeHorizontal, false); 940 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr eciseScrollingDeltas */, Event::RailsModeHorizontal, false
941 #if OS(MACOSX)
942 , WheelEventPhaseNone, WheelEventPhaseNone
943 #endif
944 );
933 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page() ->mainFrame())->view(), document->layoutViewItem(), *event); 945 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page() ->mainFrame())->view(), document->layoutViewItem(), *event);
934 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); 946 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType);
935 } 947 }
936 } 948 }
937 949
938 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) 950 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder)
939 { 951 {
940 const std::string baseURL("http://www.test8.com/"); 952 const std::string baseURL("http://www.test8.com/");
941 const std::string fileName("fixed_layout.html"); 953 const std::string fileName("fixed_layout.html");
942 954
(...skipping 10 matching lines...) Expand all
953 { 965 {
954 WebMouseWheelEvent webMouseWheelEvent; 966 WebMouseWheelEvent webMouseWheelEvent;
955 webMouseWheelEvent.type = WebInputEvent::MouseWheel; 967 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
956 webMouseWheelEvent.x = 0; 968 webMouseWheelEvent.x = 0;
957 webMouseWheelEvent.y = 5; 969 webMouseWheelEvent.y = 5;
958 webMouseWheelEvent.deltaX = 10; 970 webMouseWheelEvent.deltaX = 10;
959 webMouseWheelEvent.deltaY = 15; 971 webMouseWheelEvent.deltaY = 15;
960 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; 972 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey;
961 webMouseWheelEvent.hasPreciseScrollingDeltas = true; 973 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
962 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal; 974 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeHorizontal;
975 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseBegan;
976 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseChanged;
963 977
964 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; 978 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
965 EXPECT_EQ(0, platformWheelBuilder.position().x()); 979 EXPECT_EQ(0, platformWheelBuilder.position().x());
966 EXPECT_EQ(5, platformWheelBuilder.position().y()); 980 EXPECT_EQ(5, platformWheelBuilder.position().y());
967 EXPECT_EQ(10, platformWheelBuilder.deltaX()); 981 EXPECT_EQ(10, platformWheelBuilder.deltaX());
968 EXPECT_EQ(15, platformWheelBuilder.deltaY()); 982 EXPECT_EQ(15, platformWheelBuilder.deltaY());
969 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers()); 983 EXPECT_EQ(PlatformEvent::CtrlKey, platformWheelBuilder.getModifiers());
970 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); 984 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
971 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH orizontal); 985 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeH orizontal);
986 #if OS(MACOSX)
987 EXPECT_EQ(PlatformWheelEventPhaseBegan, platformWheelBuilder.phase());
988 EXPECT_EQ(PlatformWheelEventPhaseChanged, platformWheelBuilder.momentumP hase());
989 #endif
972 } 990 }
973 991
974 { 992 {
975 WebMouseWheelEvent webMouseWheelEvent; 993 WebMouseWheelEvent webMouseWheelEvent;
976 webMouseWheelEvent.type = WebInputEvent::MouseWheel; 994 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
977 webMouseWheelEvent.x = 5; 995 webMouseWheelEvent.x = 5;
978 webMouseWheelEvent.y = 0; 996 webMouseWheelEvent.y = 0;
979 webMouseWheelEvent.deltaX = 15; 997 webMouseWheelEvent.deltaX = 15;
980 webMouseWheelEvent.deltaY = 10; 998 webMouseWheelEvent.deltaY = 10;
981 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey; 999 webMouseWheelEvent.modifiers = WebInputEvent::ShiftKey;
982 webMouseWheelEvent.hasPreciseScrollingDeltas = false; 1000 webMouseWheelEvent.hasPreciseScrollingDeltas = false;
983 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree; 1001 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeFree;
1002 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone;
1003 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone;
984 1004
985 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; 1005 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
986 EXPECT_EQ(5, platformWheelBuilder.position().x()); 1006 EXPECT_EQ(5, platformWheelBuilder.position().x());
987 EXPECT_EQ(0, platformWheelBuilder.position().y()); 1007 EXPECT_EQ(0, platformWheelBuilder.position().y());
988 EXPECT_EQ(15, platformWheelBuilder.deltaX()); 1008 EXPECT_EQ(15, platformWheelBuilder.deltaX());
989 EXPECT_EQ(10, platformWheelBuilder.deltaY()); 1009 EXPECT_EQ(10, platformWheelBuilder.deltaY());
990 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers()); 1010 EXPECT_EQ(PlatformEvent::ShiftKey, platformWheelBuilder.getModifiers());
991 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas()); 1011 EXPECT_FALSE(platformWheelBuilder.hasPreciseScrollingDeltas());
992 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF ree); 1012 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeF ree);
1013 #if OS(MACOSX)
1014 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase());
1015 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.momentumPhas e());
1016 #endif
993 } 1017 }
994 1018
995 { 1019 {
996 WebMouseWheelEvent webMouseWheelEvent; 1020 WebMouseWheelEvent webMouseWheelEvent;
997 webMouseWheelEvent.type = WebInputEvent::MouseWheel; 1021 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
998 webMouseWheelEvent.x = 5; 1022 webMouseWheelEvent.x = 5;
999 webMouseWheelEvent.y = 0; 1023 webMouseWheelEvent.y = 0;
1000 webMouseWheelEvent.deltaX = 15; 1024 webMouseWheelEvent.deltaX = 15;
1001 webMouseWheelEvent.deltaY = 10; 1025 webMouseWheelEvent.deltaY = 10;
1002 webMouseWheelEvent.modifiers = WebInputEvent::AltKey; 1026 webMouseWheelEvent.modifiers = WebInputEvent::AltKey;
1003 webMouseWheelEvent.hasPreciseScrollingDeltas = true; 1027 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
1004 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical; 1028 webMouseWheelEvent.railsMode = WebInputEvent::RailsModeVertical;
1029 webMouseWheelEvent.phase = WebMouseWheelEvent::PhaseNone;
1030 webMouseWheelEvent.momentumPhase = WebMouseWheelEvent::PhaseNone;
1005 1031
1006 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; 1032 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
1007 EXPECT_EQ(5, platformWheelBuilder.position().x()); 1033 EXPECT_EQ(5, platformWheelBuilder.position().x());
1008 EXPECT_EQ(0, platformWheelBuilder.position().y()); 1034 EXPECT_EQ(0, platformWheelBuilder.position().y());
1009 EXPECT_EQ(15, platformWheelBuilder.deltaX()); 1035 EXPECT_EQ(15, platformWheelBuilder.deltaX());
1010 EXPECT_EQ(10, platformWheelBuilder.deltaY()); 1036 EXPECT_EQ(10, platformWheelBuilder.deltaY());
1011 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers()); 1037 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.getModifiers());
1012 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); 1038 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
1013 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV ertical); 1039 EXPECT_EQ(platformWheelBuilder.getRailsMode(), PlatformEvent::RailsModeV ertical);
1040 #if OS(MACOSX)
1041 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase());
1042 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.momentumPhas e());
1043 #endif
1014 } 1044 }
1015 } 1045 }
1016 1046
1017 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) 1047 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder)
1018 { 1048 {
1019 const std::string baseURL("http://www.test8.com/"); 1049 const std::string baseURL("http://www.test8.com/");
1020 const std::string fileName("fixed_layout.html"); 1050 const std::string fileName("fixed_layout.html");
1021 1051
1022 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); 1052 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
1023 FrameTestHelpers::WebViewHelper webViewHelper; 1053 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); 1112 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x());
1083 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); 1113 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y());
1084 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia lPhase()); 1114 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia lPhase());
1085 EXPECT_TRUE(platformGestureBuilder.synthetic()); 1115 EXPECT_TRUE(platformGestureBuilder.synthetic());
1086 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU nits()); 1116 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU nits());
1087 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); 1117 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId());
1088 } 1118 }
1089 } 1119 }
1090 1120
1091 } // namespace blink 1121 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebInputEventConversion.cpp ('k') | third_party/WebKit/public/platform/WebInputEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698