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

Unified Diff: Source/web/tests/PinchViewportTest.cpp

Issue 1178273008: Fix PinchViewport::visibleRectInDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/PinchViewport.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/PinchViewportTest.cpp
diff --git a/Source/web/tests/PinchViewportTest.cpp b/Source/web/tests/PinchViewportTest.cpp
index 88230f4754579a5216296dc2b3a5b5b9e4f2cea0..e7a57ed2913417f4e187762f62da623446a00dc9 100644
--- a/Source/web/tests/PinchViewportTest.cpp
+++ b/Source/web/tests/PinchViewportTest.cpp
@@ -462,6 +462,29 @@ TEST_F(PinchViewportTest, TestVisibleRect)
EXPECT_FLOAT_RECT_EQ(expectedRect, pinchViewport.visibleRect());
}
+// Make sure that the visibleRectInDocument method acurately reflects the scale
+// and scroll location of the viewport relative to the document.
+TEST_F(PinchViewportTest, TestVisibleRectInDocument)
+{
+ initializeWithDesktopSettings();
+ webViewImpl()->resize(IntSize(100, 400));
+
+ registerMockedHttpURLLoad("200-by-800-viewport.html");
+ navigateTo(m_baseURL + "200-by-800-viewport.html");
+
+ PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
+
+ // Scale the viewport to 2X and move it.
+ pinchViewport.setScale(2);
+ pinchViewport.setLocation(FloatPoint(10, 15));
+ EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), pinchViewport.visibleRectInDocument());
+
+ // Scroll the layout viewport. Ensure its offset is reflected in visibleRectInDocument().
+ FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
+ frameView.setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll);
+ EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), pinchViewport.visibleRectInDocument());
+}
+
TEST_F(PinchViewportTest, TestFractionalScrollOffsetIsNotOverwritten)
{
initializeWithAndroidSettings();
« no previous file with comments | « Source/core/frame/PinchViewport.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698