| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) | 60 int getModifiersForKeyLocationCode(KeyboardEvent::KeyLocationCode location) |
| 61 { | 61 { |
| 62 KeyboardEvent* event = createKeyboardEventWithLocation(location); | 62 KeyboardEvent* event = createKeyboardEventWithLocation(location); |
| 63 WebKeyboardEventBuilder convertedEvent(*event); | 63 WebKeyboardEventBuilder convertedEvent(*event); |
| 64 return convertedEvent.modifiers; | 64 return convertedEvent.modifiers; |
| 65 } | 65 } |
| 66 | 66 |
| 67 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) | 67 TEST(WebInputEventConversionTest, WebKeyboardEventBuilder) |
| 68 { | 68 { |
| 69 // Test key location conversion. | 69 // Test key location conversion. |
| 70 int modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATI
ON_STANDARD); | 70 int modifiers = getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocatio
nStandard); |
| 71 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsLeft || modifiers & WebInputEvent::IsRight); | 71 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsLeft || modifiers & WebInputEvent::IsRight); |
| 72 | 72 |
| 73 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_L
EFT); | 73 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationLef
t); |
| 74 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); | 74 EXPECT_TRUE(modifiers & WebInputEvent::IsLeft); |
| 75 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsRight); | 75 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsRight); |
| 76 | 76 |
| 77 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_R
IGHT); | 77 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationRig
ht); |
| 78 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); | 78 EXPECT_TRUE(modifiers & WebInputEvent::IsRight); |
| 79 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsLeft); | 79 EXPECT_FALSE(modifiers & WebInputEvent::IsKeyPad || modifiers & WebInputEven
t::IsLeft); |
| 80 | 80 |
| 81 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::DOM_KEY_LOCATION_N
UMPAD); | 81 modifiers = getModifiersForKeyLocationCode(KeyboardEvent::kDomKeyLocationNum
pad); |
| 82 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); | 82 EXPECT_TRUE(modifiers & WebInputEvent::IsKeyPad); |
| 83 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent:
:IsRight); | 83 EXPECT_FALSE(modifiers & WebInputEvent::IsLeft || modifiers & WebInputEvent:
:IsRight); |
| 84 } | 84 } |
| 85 | 85 |
| 86 TEST(WebInputEventConversionTest, WebMouseEventBuilder) | 86 TEST(WebInputEventConversionTest, WebMouseEventBuilder) |
| 87 { | 87 { |
| 88 TouchEvent* event = TouchEvent::create(); | 88 TouchEvent* event = TouchEvent::create(); |
| 89 WebMouseEventBuilder mouse(0, 0, *event); | 89 WebMouseEventBuilder mouse(0, 0, *event); |
| 90 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); | 90 EXPECT_EQ(WebInputEvent::Undefined, mouse.type); |
| 91 } | 91 } |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 FrameTestHelpers::WebViewHelper webViewHelper; | 900 FrameTestHelpers::WebViewHelper webViewHelper; |
| 901 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); | 901 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(baseURL + fileNam
e, true); |
| 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::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(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 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 913 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); | 914 EXPECT_EQ(1, webMouseWheel.wheelTicksX); |
| 915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); | 915 EXPECT_EQ(3, webMouseWheel.wheelTicksY); |
| 916 EXPECT_EQ(5, webMouseWheel.deltaX); | 916 EXPECT_EQ(5, webMouseWheel.deltaX); |
| 917 EXPECT_EQ(10, webMouseWheel.deltaY); | 917 EXPECT_EQ(10, webMouseWheel.deltaY); |
| 918 EXPECT_EQ(2, webMouseWheel.globalX); | 918 EXPECT_EQ(2, webMouseWheel.globalX); |
| 919 EXPECT_EQ(6, webMouseWheel.globalY); | 919 EXPECT_EQ(6, webMouseWheel.globalY); |
| 920 EXPECT_EQ(10, webMouseWheel.windowX); | 920 EXPECT_EQ(10, webMouseWheel.windowX); |
| 921 EXPECT_EQ(30, webMouseWheel.windowY); | 921 EXPECT_EQ(30, webMouseWheel.windowY); |
| 922 EXPECT_TRUE(webMouseWheel.scrollByPage); | 922 EXPECT_TRUE(webMouseWheel.scrollByPage); |
| 923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); | 923 EXPECT_EQ(WebInputEvent::ControlKey, webMouseWheel.modifiers); |
| 924 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); | 924 EXPECT_EQ(WebInputEvent::RailsModeHorizontal, webMouseWheel.railsMode); |
| 925 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); | 925 EXPECT_TRUE(webMouseWheel.hasPreciseScrollingDeltas); |
| 926 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); | 926 EXPECT_EQ(WebInputEvent::Blocking, webMouseWheel.dispatchType); |
| 927 } | 927 } |
| 928 | 928 |
| 929 { | 929 { |
| 930 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), | 930 WheelEvent* event = WheelEvent::create(FloatPoint(1, 3), FloatPoint(5, 1
0), |
| 931 WheelEvent::DOM_DELTA_PAGE, document->domWindow(), IntPoint(2, 6), I
ntPoint(10, 30), | 931 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); | 932 PlatformEvent::CtrlKey, 0, 0, -1 /* null plugin id */, true /* hasPr
eciseScrollingDeltas */, Event::RailsModeHorizontal, false); |
| 933 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); | 933 WebMouseWheelEventBuilder webMouseWheel(toLocalFrame(webViewImpl->page()
->mainFrame())->view(), document->layoutViewItem(), *event); |
| 934 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); | 934 EXPECT_EQ(WebInputEvent::EventNonBlocking, webMouseWheel.dispatchType); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 | 937 |
| 938 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) | 938 TEST(WebInputEventConversionTest, PlatformWheelEventBuilder) |
| 939 { | 939 { |
| 940 const std::string baseURL("http://www.test8.com/"); | 940 const std::string baseURL("http://www.test8.com/"); |
| 941 const std::string fileName("fixed_layout.html"); | 941 const std::string fileName("fixed_layout.html"); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 1082 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); |
| 1083 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | 1083 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); |
| 1084 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); | 1084 EXPECT_EQ(ScrollInertialPhaseNonMomentum, platformGestureBuilder.inertia
lPhase()); |
| 1085 EXPECT_TRUE(platformGestureBuilder.synthetic()); | 1085 EXPECT_TRUE(platformGestureBuilder.synthetic()); |
| 1086 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); | 1086 EXPECT_EQ(ScrollGranularity::ScrollByPage, platformGestureBuilder.deltaU
nits()); |
| 1087 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | 1087 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); |
| 1088 } | 1088 } |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 } // namespace blink | 1091 } // namespace blink |
| OLD | NEW |