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 20 matching lines...) Expand all Loading... | |
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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); | 707 EXPECT_FLOAT_EQ(10.4f, webTouchEvent.touches[0].position.y); |
707 | 708 |
708 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 709 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
709 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); | 710 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos() .x()); |
710 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); | 711 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos() .y()); |
711 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); | 712 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints ()[0].pos().x()); |
712 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); | 713 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints ()[0].pos().y()); |
713 } | 714 } |
714 } | 715 } |
715 | 716 |
717 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) | |
718 { | |
719 const std::string baseURL("http://www.test5.com/"); | |
720 const std::string fileName("fixed_layout.html"); | |
721 | |
722 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); | |
723 FrameTestHelpers::WebViewHelper webViewHelper; | |
724 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
725 int pageWidth = 640; | |
726 int pageHeight = 480; | |
727 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
728 webViewImpl->layout(); | |
729 | |
730 RefPtrWillBeRawPtr<Document> document = toLocalFrame(webViewImpl->page()->ma inFrame())->document(); | |
731 RefPtrWillBeRawPtr<WheelEvent> event = WheelEvent::create(FloatPoint(1, 1), FloatPoint(10, 10), | |
732 0, document.get()->domWindow(), IntPoint(1, 1), IntPoint(1, 1), true, f alse, false, false, true); | |
733 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()->ma inFrame())->view(), document.get()->renderView(), *event); | |
734 EXPECT_TRUE(webMouseWheel.canScroll); | |
Rick Byers
2014/12/02 15:48:21
You should verify the other fields too while you'r
lanwei
2014/12/02 22:27:54
Done.
| |
735 } | |
736 | |
737 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | |
738 { | |
739 const std::string baseURL("http://www.test6.com/"); | |
740 const std::string fileName("fixed_layout.html"); | |
741 | |
742 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s tr()), WebString::fromUTF8("fixed_layout.html")); | |
743 FrameTestHelpers::WebViewHelper webViewHelper; | |
744 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam e, true); | |
745 int pageWidth = 640; | |
746 int pageHeight = 480; | |
747 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
748 webViewImpl->layout(); | |
749 | |
750 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | |
751 | |
752 { | |
753 WebMouseWheelEvent webMouseWheelEvent; | |
754 webMouseWheelEvent.type = WebInputEvent::MouseWheel; | |
755 webMouseWheelEvent.x = 10; | |
756 webMouseWheelEvent.y = 10; | |
Rick Byers
2014/12/02 15:48:21
nit: don't repeat values. That way your test woul
lanwei
2014/12/02 22:27:54
Done.
| |
757 webMouseWheelEvent.deltaX = 5; | |
758 webMouseWheelEvent.deltaY = 5; | |
759 webMouseWheelEvent.modifiers = WebInputEvent::ControlKey; | |
760 webMouseWheelEvent.hasPreciseScrollingDeltas = true; | |
761 webMouseWheelEvent.canScroll = true; | |
762 | |
763 PlatformWheelEventBuilder platformWheelBuilder(view, webMouseWheelEvent) ; | |
764 EXPECT_EQ(10, platformWheelBuilder.position().x()); | |
765 EXPECT_EQ(10, platformWheelBuilder.position().y()); | |
766 EXPECT_EQ(5, platformWheelBuilder.deltaX()); | |
767 EXPECT_EQ(5, platformWheelBuilder.deltaY()); | |
768 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | |
769 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | |
770 EXPECT_TRUE(platformWheelBuilder.canScroll()); | |
771 } | |
772 } | |
716 } // anonymous namespace | 773 } // anonymous namespace |
OLD | NEW |