Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Truncated to int on input, git cl format Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { 1119 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) {
1120 initializeWithDesktopSettings(); 1120 initializeWithDesktopSettings();
1121 webViewImpl()->resize(IntSize(200, 300)); 1121 webViewImpl()->resize(IntSize(200, 300));
1122 1122
1123 registerMockedHttpURLLoad("200-by-300.html"); 1123 registerMockedHttpURLLoad("200-by-300.html");
1124 navigateTo(m_baseURL + "200-by-300.html"); 1124 navigateTo(m_baseURL + "200-by-300.html");
1125 1125
1126 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, 1126 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown,
1127 WebInputEvent::NoModifiers, 1127 WebInputEvent::NoModifiers,
1128 WebInputEvent::TimeStampForTesting); 1128 WebInputEvent::TimeStampForTesting);
1129 mouseDownEvent.x = 10; 1129 mouseDownEvent.setPositionInWidget(10, 10);
1130 mouseDownEvent.y = 10; 1130 mouseDownEvent.setPositionInScreen(110, 210);
1131 mouseDownEvent.globalX = 110;
1132 mouseDownEvent.globalY = 210;
1133 mouseDownEvent.clickCount = 1; 1131 mouseDownEvent.clickCount = 1;
1134 mouseDownEvent.button = WebMouseEvent::Button::Right; 1132 mouseDownEvent.button = WebMouseEvent::Button::Right;
1135 1133
1136 // Corresponding release event (Windows shows context menu on release). 1134 // Corresponding release event (Windows shows context menu on release).
1137 WebMouseEvent mouseUpEvent(mouseDownEvent); 1135 WebMouseEvent mouseUpEvent(mouseDownEvent);
1138 mouseUpEvent.setType(WebInputEvent::MouseUp); 1136 mouseUpEvent.setType(WebInputEvent::MouseUp);
1139 1137
1140 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); 1138 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client();
1141 MockWebFrameClient mockWebFrameClient; 1139 MockWebFrameClient mockWebFrameClient;
1142 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( 1140 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation(
1143 mouseDownEvent.x, mouseDownEvent.y))); 1141 mouseDownEvent.positionInWidget().x,
1142 mouseDownEvent.positionInWidget().y)));
1144 1143
1145 // Do a sanity check with no scale applied. 1144 // Do a sanity check with no scale applied.
1146 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); 1145 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient);
1147 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1146 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1148 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1147 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1149 1148
1150 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1149 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1151 mouseDownEvent.button = WebMouseEvent::Button::Left; 1150 mouseDownEvent.button = WebMouseEvent::Button::Left;
1152 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1151 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1153 1152
1154 // Now pinch zoom into the page and move the visual viewport. The context menu 1153 // Now pinch zoom into the page and move the visual viewport. The context menu
1155 // should still appear at the location of the event, relative to the WebView. 1154 // should still appear at the location of the event, relative to the WebView.
1156 VisualViewport& visualViewport = frame()->page()->visualViewport(); 1155 VisualViewport& visualViewport = frame()->page()->visualViewport();
1157 webViewImpl()->setPageScaleFactor(2); 1156 webViewImpl()->setPageScaleFactor(2);
1158 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1157 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1159 visualViewport.setLocation(FloatPoint(60, 80)); 1158 visualViewport.setLocation(FloatPoint(60, 80));
1160 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( 1159 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation(
1161 mouseDownEvent.x, mouseDownEvent.y))); 1160 mouseDownEvent.positionInWidget().x,
1161 mouseDownEvent.positionInWidget().y)));
1162 1162
1163 mouseDownEvent.button = WebMouseEvent::Button::Right; 1163 mouseDownEvent.button = WebMouseEvent::Button::Right;
1164 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1164 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1165 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1165 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1166 1166
1167 // Reset the old client so destruction can occur naturally. 1167 // Reset the old client so destruction can occur naturally.
1168 webViewImpl()->mainFrameImpl()->setClient(oldClient); 1168 webViewImpl()->mainFrameImpl()->setClient(oldClient);
1169 } 1169 }
1170 1170
1171 // Test that the client is notified if page scroll events. 1171 // Test that the client is notified if page scroll events.
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 " body {" 2430 " body {"
2431 " margin: 0px;" 2431 " margin: 0px;"
2432 " }" 2432 " }"
2433 " div { height:110vh; width: 110vw; }" 2433 " div { height:110vh; width: 110vw; }"
2434 "</style>" 2434 "</style>"
2435 "<div></div>", 2435 "<div></div>",
2436 baseURL); 2436 baseURL);
2437 } 2437 }
2438 2438
2439 } // namespace 2439 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698