OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/VisualViewport.h" | 5 #include "core/frame/VisualViewport.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/BrowserControls.h" | 8 #include "core/frame/BrowserControls.h" |
9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 | 1137 |
1138 // Test that the context menu's location is correct in the presence of visual | 1138 // Test that the context menu's location is correct in the presence of visual |
1139 // viewport offset. | 1139 // viewport offset. |
1140 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { | 1140 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { |
1141 initializeWithDesktopSettings(); | 1141 initializeWithDesktopSettings(); |
1142 webViewImpl()->resize(IntSize(200, 300)); | 1142 webViewImpl()->resize(IntSize(200, 300)); |
1143 | 1143 |
1144 registerMockedHttpURLLoad("200-by-300.html"); | 1144 registerMockedHttpURLLoad("200-by-300.html"); |
1145 navigateTo(m_baseURL + "200-by-300.html"); | 1145 navigateTo(m_baseURL + "200-by-300.html"); |
1146 | 1146 |
1147 WebMouseEvent mouseDownEvent; | 1147 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, |
1148 mouseDownEvent.type = WebInputEvent::MouseDown; | 1148 WebInputEvent::NoModifiers, |
| 1149 WebInputEvent::TimeStampForTesting); |
1149 mouseDownEvent.x = 10; | 1150 mouseDownEvent.x = 10; |
1150 mouseDownEvent.y = 10; | 1151 mouseDownEvent.y = 10; |
1151 mouseDownEvent.windowX = 10; | 1152 mouseDownEvent.windowX = 10; |
1152 mouseDownEvent.windowY = 10; | 1153 mouseDownEvent.windowY = 10; |
1153 mouseDownEvent.globalX = 110; | 1154 mouseDownEvent.globalX = 110; |
1154 mouseDownEvent.globalY = 210; | 1155 mouseDownEvent.globalY = 210; |
1155 mouseDownEvent.clickCount = 1; | 1156 mouseDownEvent.clickCount = 1; |
1156 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1157 mouseDownEvent.button = WebMouseEvent::Button::Right; |
1157 | 1158 |
1158 // Corresponding release event (Windows shows context menu on release). | 1159 // Corresponding release event (Windows shows context menu on release). |
1159 WebMouseEvent mouseUpEvent(mouseDownEvent); | 1160 WebMouseEvent mouseUpEvent(mouseDownEvent); |
1160 mouseUpEvent.type = WebInputEvent::MouseUp; | 1161 mouseUpEvent.setType(WebInputEvent::MouseUp); |
1161 | 1162 |
1162 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1163 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
1163 MockWebFrameClient mockWebFrameClient; | 1164 MockWebFrameClient mockWebFrameClient; |
1164 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1165 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
1165 mouseDownEvent.x, mouseDownEvent.y))); | 1166 mouseDownEvent.x, mouseDownEvent.y))); |
1166 | 1167 |
1167 // Do a sanity check with no scale applied. | 1168 // Do a sanity check with no scale applied. |
1168 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1169 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
1169 webViewImpl()->handleInputEvent(mouseDownEvent); | 1170 webViewImpl()->handleInputEvent(mouseDownEvent); |
1170 webViewImpl()->handleInputEvent(mouseUpEvent); | 1171 webViewImpl()->handleInputEvent(mouseUpEvent); |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 std::string(output->innerHTML().ascii().data())); | 1998 std::string(output->innerHTML().ascii().data())); |
1998 } | 1999 } |
1999 | 2000 |
2000 TEST_P(VisualViewportTest, PinchZoomGestureScrollsVisualViewportOnly) { | 2001 TEST_P(VisualViewportTest, PinchZoomGestureScrollsVisualViewportOnly) { |
2001 initializeWithDesktopSettings(); | 2002 initializeWithDesktopSettings(); |
2002 webViewImpl()->resize(IntSize(100, 100)); | 2003 webViewImpl()->resize(IntSize(100, 100)); |
2003 | 2004 |
2004 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 2005 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
2005 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 2006 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
2006 | 2007 |
2007 WebGestureEvent pinchUpdate; | 2008 WebGestureEvent pinchUpdate(WebInputEvent::GesturePinchUpdate, |
2008 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; | 2009 WebInputEvent::NoModifiers, |
| 2010 WebInputEvent::TimeStampForTesting); |
2009 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; | 2011 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; |
2010 pinchUpdate.x = 100; | 2012 pinchUpdate.x = 100; |
2011 pinchUpdate.y = 100; | 2013 pinchUpdate.y = 100; |
2012 pinchUpdate.data.pinchUpdate.scale = 2; | 2014 pinchUpdate.data.pinchUpdate.scale = 2; |
2013 pinchUpdate.data.pinchUpdate.zoomDisabled = false; | 2015 pinchUpdate.data.pinchUpdate.zoomDisabled = false; |
2014 | 2016 |
2015 webViewImpl()->handleInputEvent(pinchUpdate); | 2017 webViewImpl()->handleInputEvent(pinchUpdate); |
2016 | 2018 |
2017 VisualViewport& visualViewport = | 2019 VisualViewport& visualViewport = |
2018 webViewImpl()->page()->frameHost().visualViewport(); | 2020 webViewImpl()->page()->frameHost().visualViewport(); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 ASSERT_EQ(1u, rasterInvalidations->size()); | 2450 ASSERT_EQ(1u, rasterInvalidations->size()); |
2449 EXPECT_EQ(IntRect(0, 0, pageWidth, largestHeight), | 2451 EXPECT_EQ(IntRect(0, 0, pageWidth, largestHeight), |
2450 (*rasterInvalidations)[0].rect); | 2452 (*rasterInvalidations)[0].rect); |
2451 } | 2453 } |
2452 | 2454 |
2453 document->view()->setTracksPaintInvalidations(false); | 2455 document->view()->setTracksPaintInvalidations(false); |
2454 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2456 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
2455 } | 2457 } |
2456 | 2458 |
2457 } // namespace | 2459 } // namespace |
OLD | NEW |