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

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

Issue 759073002: Add canScroll bit to WebMouseWheelEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase 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
« 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 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "web/WebInputEventConversion.h" 33 #include "web/WebInputEventConversion.h"
34 34
35 #include "core/dom/Touch.h" 35 #include "core/dom/Touch.h"
36 #include "core/dom/TouchList.h" 36 #include "core/dom/TouchList.h"
37 #include "core/events/GestureEvent.h" 37 #include "core/events/GestureEvent.h"
38 #include "core/events/KeyboardEvent.h" 38 #include "core/events/KeyboardEvent.h"
39 #include "core/events/MouseEvent.h" 39 #include "core/events/MouseEvent.h"
40 #include "core/events/TouchEvent.h" 40 #include "core/events/TouchEvent.h"
41 #include "core/events/WheelEvent.h"
41 #include "core/frame/FrameHost.h" 42 #include "core/frame/FrameHost.h"
42 #include "core/frame/FrameView.h" 43 #include "core/frame/FrameView.h"
43 #include "core/frame/LocalFrame.h" 44 #include "core/frame/LocalFrame.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
45 #include "core/rendering/RenderView.h" 46 #include "core/rendering/RenderView.h"
46 #include "core/testing/URLTestHelpers.h" 47 #include "core/testing/URLTestHelpers.h"
47 #include "public/web/WebFrame.h" 48 #include "public/web/WebFrame.h"
48 #include "public/web/WebSettings.h" 49 #include "public/web/WebSettings.h"
49 #include "web/WebViewImpl.h" 50 #include "web/WebViewImpl.h"
50 #include "web/tests/FrameTestHelpers.h" 51 #include "web/tests/FrameTestHelpers.h"
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); 722 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y);
722 723
723 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 724 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
724 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); 725 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x());
725 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); 726 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y());
726 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());
727 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());
728 } 729 }
729 } 730 }
730 731
732 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder)
733 {
734 const std::string baseURL("http://www.test5.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);
740 int pageWidth = 640;
741 int pageHeight = 480;
742 webViewImpl->resize(WebSize(pageWidth, pageHeight));
743 webViewImpl->layout();
744
745 RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->ma inFrame())->document();
746 RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 10),
747 WheelEvent::DOM_DELTA_PAGE, document.get()->domWindow(), IntPoint(2, 6) , IntPoint(10, 30),
748 true, false, false, false, 0, true);
749 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->ma inFrame())->view(), document.get()->renderView(), *event);
750 EXPECT_EQ(1, webMouseWheel.wheelTicksX);
751 EXPECT_EQ(3, webMouseWheel.wheelTicksY);
752 EXPECT_EQ(5, webMouseWheel.deltaX);
753 EXPECT_EQ(10, webMouseWheel.deltaY);
754 EXPECT_EQ(2, webMouseWheel.globalX);
755 EXPECT_EQ(6, webMouseWheel.globalY);
756 EXPECT_EQ(10, webMouseWheel.windowX);
757 EXPECT_EQ(30, webMouseWheel.windowY);
758 EXPECT_TRUE(webMouseWheel.scrollByPage);
759 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers);
760 EXPECT_TRUE(webMouseWheel.canScroll);
761 }
762
763 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder)
764 {
765 const std::string baseURL("http://www.test6.com/");
766 const std::string fileName("fixed_layout.html");
767
768 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html"));
769 FrameTestHelpers::WebViewHelper webViewHelper;
770 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true);
771 int pageWidth = 640;
772 int pageHeight = 480;
773 webViewImpl->resize(WebSize(pageWidth, pageHeight));
774 webViewImpl->layout();
775
776 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view();
777
778 {
779 WebMouseWheelEvent webMouseWheelEvent;
780 webMouseWheelEvent.type = WebInputEvent::MouseWheel;
781 webMouseWheelEvent.x = 0;
782 webMouseWheelEvent.y = 5;
783 webMouseWheelEvent.deltaX = 10;
784 webMouseWheelEvent.deltaY = 15;
785 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey;
786 webMouseWheelEvent.hasPreciseScrollingDeltas = true;
787 webMouseWheelEvent.canScroll = true;
788
789 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ;
790 EXPECT_EQ(0, platformWheelBuilder.position().x());
791 EXPECT_EQ(5, platformWheelBuilder.position().y());
792 EXPECT_EQ(10, platformWheelBuilder.deltaX());
793 EXPECT_EQ(15, platformWheelBuilder.deltaY());
794 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers());
795 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas());
796 EXPECT_TRUE(platformWheelBuilder.canScroll());
797 }
798 }
731 } // anonymous namespace 799 } // 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