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, fal
se, false, false, false); | 60 return KeyboardEvent::create("keydown", true, true, 0, "", "", "", location,
false, 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); | 740 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); |
741 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); | 741 EXPECT_FLOAT_EQ(10.6f, platformTouchBuilder.touchPoints()[0].screenPos()
.x()); |
742 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); | 742 EXPECT_FLOAT_EQ(10.4f, platformTouchBuilder.touchPoints()[0].screenPos()
.y()); |
743 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); | 743 EXPECT_FLOAT_EQ(5.3f + pinchOffset.x(), platformTouchBuilder.touchPoints
()[0].pos().x()); |
744 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); | 744 EXPECT_FLOAT_EQ(5.2f + pinchOffset.y(), platformTouchBuilder.touchPoints
()[0].pos().y()); |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 TEST(WebInputEventConversionTest, ElasticOverscroll) | 748 TEST(WebInputEventConversionTest, ElasticOverscroll) |
749 { | 749 { |
750 const std::string baseURL("http://www.test6.com/"); | 750 const std::string baseURL("http://www.test5.com/"); |
751 const std::string fileName("fixed_layout.html"); | 751 const std::string fileName("fixed_layout.html"); |
752 | 752 |
753 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 753 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
754 FrameTestHelpers::WebViewHelper webViewHelper; | 754 FrameTestHelpers::WebViewHelper webViewHelper; |
755 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 755 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
756 int pageWidth = 640; | 756 int pageWidth = 640; |
757 int pageHeight = 480; | 757 int pageHeight = 480; |
758 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 758 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
759 webViewImpl->layout(); | 759 webViewImpl->layout(); |
760 | 760 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); | 801 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); |
802 EXPECT_EQ(webMouseEvent.x / pageScale + pinchOffset.x() + elasticOverscr
oll.width(), platformMouseBuilder.position().x()); | 802 EXPECT_EQ(webMouseEvent.x / pageScale + pinchOffset.x() + elasticOverscr
oll.width(), platformMouseBuilder.position().x()); |
803 EXPECT_EQ(webMouseEvent.y / pageScale + pinchOffset.y() + elasticOverscr
oll.height(), platformMouseBuilder.position().y()); | 803 EXPECT_EQ(webMouseEvent.y / pageScale + pinchOffset.y() + elasticOverscr
oll.height(), platformMouseBuilder.position().y()); |
804 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); | 804 EXPECT_EQ(webMouseEvent.globalX, platformMouseBuilder.globalPosition().x
()); |
805 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); | 805 EXPECT_EQ(webMouseEvent.globalY, platformMouseBuilder.globalPosition().y
()); |
806 } | 806 } |
807 } | 807 } |
808 | 808 |
809 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) | 809 TEST(WebInputEventConversionTest, WebMouseWheelEventBuilder) |
810 { | 810 { |
811 const std::string baseURL("http://www.test5.com/"); | 811 const std::string baseURL("http://www.test6.com/"); |
812 const std::string fileName("fixed_layout.html"); | 812 const std::string fileName("fixed_layout.html"); |
813 | 813 |
814 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 814 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
815 FrameTestHelpers::WebViewHelper webViewHelper; | 815 FrameTestHelpers::WebViewHelper webViewHelper; |
816 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 816 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
817 int pageWidth = 640; | 817 int pageWidth = 640; |
818 int pageHeight = 480; | 818 int pageHeight = 480; |
819 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 819 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
820 webViewImpl->layout(); | 820 webViewImpl->layout(); |
821 | 821 |
(...skipping 11 matching lines...) Expand all Loading... |
833 EXPECT_EQ(10, webMouseWheel.windowX); | 833 EXPECT_EQ(10, webMouseWheel.windowX); |
834 EXPECT_EQ(30, webMouseWheel.windowY); | 834 EXPECT_EQ(30, webMouseWheel.windowY); |
835 EXPECT_TRUE(webMouseWheel.scrollByPage); | 835 EXPECT_TRUE(webMouseWheel.scrollByPage); |
836 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | 836 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); |
837 EXPECT_TRUE(webMouseWheel.canScroll); | 837 EXPECT_TRUE(webMouseWheel.canScroll); |
838 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); | 838 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); |
839 } | 839 } |
840 | 840 |
841 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | 841 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
842 { | 842 { |
843 const std::string baseURL("http://www.test6.com/"); | 843 const std::string baseURL("http://www.test7.com/"); |
844 const std::string fileName("fixed_layout.html"); | 844 const std::string fileName("fixed_layout.html"); |
845 | 845 |
846 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); | 846 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_s
tr()), WebString::fromUTF8("fixed_layout.html")); |
847 FrameTestHelpers::WebViewHelper webViewHelper; | 847 FrameTestHelpers::WebViewHelper webViewHelper; |
848 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 848 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
849 int pageWidth = 640; | 849 int pageWidth = 640; |
850 int pageHeight = 480; | 850 int pageHeight = 480; |
851 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 851 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
852 webViewImpl->layout(); | 852 webViewImpl->layout(); |
853 | 853 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 EXPECT_EQ(15, platformWheelBuilder.deltaX()); | 917 EXPECT_EQ(15, platformWheelBuilder.deltaX()); |
918 EXPECT_EQ(10, platformWheelBuilder.deltaY()); | 918 EXPECT_EQ(10, platformWheelBuilder.deltaY()); |
919 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.modifiers()); | 919 EXPECT_EQ(PlatformEvent::AltKey, platformWheelBuilder.modifiers()); |
920 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); | 920 EXPECT_TRUE(platformWheelBuilder.hasPreciseScrollingDeltas()); |
921 EXPECT_FALSE(platformWheelBuilder.canScroll()); | 921 EXPECT_FALSE(platformWheelBuilder.canScroll()); |
922 EXPECT_EQ(platformWheelBuilder.railsMode(), PlatformEvent::RailsModeVert
ical); | 922 EXPECT_EQ(platformWheelBuilder.railsMode(), PlatformEvent::RailsModeVert
ical); |
923 } | 923 } |
924 } | 924 } |
925 | 925 |
926 } // anonymous namespace | 926 } // anonymous namespace |
OLD | NEW |