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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "web/WebViewImpl.h" | 50 #include "web/WebViewImpl.h" |
51 #include "web/tests/FrameTestHelpers.h" | 51 #include "web/tests/FrameTestHelpers.h" |
52 #include <gtest/gtest.h> | 52 #include <gtest/gtest.h> |
53 | 53 |
54 using namespace blink; | 54 using namespace blink; |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 PassRefPtrWillBeRawPtr<KeyboardEvent> createKeyboardEventWithLocation(KeyboardEv
ent::KeyLocationCode location) | 58 PassRefPtrWillBeRawPtr<KeyboardEvent> createKeyboardEventWithLocation(KeyboardEv
ent::KeyLocationCode location) |
59 { | 59 { |
60 return KeyboardEvent::create("keydown", true, true, 0, "", location, false,
false, false, false); | 60 return KeyboardEvent::create("keydown", true, true, 0, "", "", location, fal
se, false, false, false); |
61 } | 61 } |
62 | 62 |
63 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) | 63 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) |
64 { | 64 { |
65 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo
cation); | 65 RefPtrWillBeRawPtr<KeyboardEvent> event = createKeyboardEventWithLocation(lo
cation); |
66 WebKeyboardEventBuilder convertedEvent(*event); | 66 WebKeyboardEventBuilder convertedEvent(*event); |
67 return convertedEvent.modifiers; | 67 return convertedEvent.modifiers; |
68 } | 68 } |
69 | 69 |
70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) | 70 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 732 TEST(WebInputEventConversionTest, ElasticOverscroll) |
733 { | 733 { |
734 const std::string baseURL("http://www.test5.com/"); | 734 const std::string baseURL("http://www.test6.com/"); |
735 const std::string fileName("fixed_layout.html"); | 735 const std::string fileName("fixed_layout.html"); |
736 | 736 |
737 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 737 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
738 FrameTestHelpers::WebViewHelper webViewHelper; | 738 FrameTestHelpers::WebViewHelper webViewHelper; |
739 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, 0, setupVirtualViewportPinch); | 739 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true, 0, 0, setupVirtualViewportPinch); |
740 int pageWidth = 640; | 740 int pageWidth = 640; |
741 int pageHeight = 480; | 741 int pageHeight = 480; |
742 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 742 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
743 webViewImpl->layout(); | 743 webViewImpl->layout(); |
744 | 744 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 785 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
786 EXPECT_EQ(webMouseEvent.x / pageScale + pinchOffset.x() + elasticOverscr
oll.width(), platformMouseBuilder.position().x()); | 786 EXPECT_EQ(webMouseEvent.x / pageScale + pinchOffset.x() + elasticOverscr
oll.width(), platformMouseBuilder.position().x()); |
787 EXPECT_EQ(webMouseEvent.y / pageScale + pinchOffset.y() + elasticOverscr
oll.height(), platformMouseBuilder.position().y()); | 787 EXPECT_EQ(webMouseEvent.y / pageScale + pinchOffset.y() + elasticOverscr
oll.height(), platformMouseBuilder.position().y()); |
788 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); | 788 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); |
789 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); | 789 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); |
790 } | 790 } |
791 } | 791 } |
792 | 792 |
793 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) | 793 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) |
794 { | 794 { |
795 const std::string baseURL("http://www.test6.com/"); | 795 const std::string baseURL("http://www.test5.com/"); |
796 const std::string fileName("fixed_layout.html"); | 796 const std::string fileName("fixed_layout.html"); |
797 | 797 |
798 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 798 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
799 FrameTestHelpers::WebViewHelper webViewHelper; | 799 FrameTestHelpers::WebViewHelper webViewHelper; |
800 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 800 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
801 int pageWidth = 640; | 801 int pageWidth = 640; |
802 int pageHeight = 480; | 802 int pageHeight = 480; |
803 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 803 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
804 webViewImpl->layout(); | 804 webViewImpl->layout(); |
805 | 805 |
(...skipping 10 matching lines...) Expand all Loading... |
816 EXPECT_EQ(6, webMouseWheel.globalY); | 816 EXPECT_EQ(6, webMouseWheel.globalY); |
817 EXPECT_EQ(10, webMouseWheel.windowX); | 817 EXPECT_EQ(10, webMouseWheel.windowX); |
818 EXPECT_EQ(30, webMouseWheel.windowY); | 818 EXPECT_EQ(30, webMouseWheel.windowY); |
819 EXPECT_TRUE(webMouseWheel.scrollByPage); | 819 EXPECT_TRUE(webMouseWheel.scrollByPage); |
820 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | 820 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); |
821 EXPECT_TRUE(webMouseWheel.canScroll); | 821 EXPECT_TRUE(webMouseWheel.canScroll); |
822 } | 822 } |
823 | 823 |
824 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | 824 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
825 { | 825 { |
826 const std::string baseURL("http://www.test7.com/"); | 826 const std::string baseURL("http://www.test6.com/"); |
827 const std::string fileName("fixed_layout.html"); | 827 const std::string fileName("fixed_layout.html"); |
828 | 828 |
829 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 829 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
830 FrameTestHelpers::WebViewHelper webViewHelper; | 830 FrameTestHelpers::WebViewHelper webViewHelper; |
831 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 831 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
832 int pageWidth = 640; | 832 int pageWidth = 640; |
833 int pageHeight = 480; | 833 int pageHeight = 480; |
834 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 834 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
835 webViewImpl->layout(); | 835 webViewImpl->layout(); |
836 | 836 |
(...skipping 15 matching lines...) Expand all Loading... |
852 EXPECT_EQ(5, platformWheelBuilder.position().y()); | 852 EXPECT_EQ(5, platformWheelBuilder.position().y()); |
853 EXPECT_EQ(10, platformWheelBuilder.deltaX()); | 853 EXPECT_EQ(10, platformWheelBuilder.deltaX()); |
854 EXPECT_EQ(15, platformWheelBuilder.deltaY()); | 854 EXPECT_EQ(15, platformWheelBuilder.deltaY()); |
855 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); | 855 EXPECT_EQ(WebInputEvent::ControlKey, platformWheelBuilder.modifiers()); |
856 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 856 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
857 EXPECT_TRUE(platformWheelBuilder.canScroll()); | 857 EXPECT_TRUE(platformWheelBuilder.canScroll()); |
858 } | 858 } |
859 } | 859 } |
860 | 860 |
861 } // anonymous namespace | 861 } // anonymous namespace |
OLD | NEW |