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

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

Issue 2454913003: MainFrame scrollbars should work with RFV instead of FV (Closed)
Patch Set: add test + rebase Created 4 years, 1 month 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/FrameHost.h" 9 #include "core/frame/FrameHost.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 expectedLocation, 268 expectedLocation,
269 frameView.getScrollableArea()->visibleContentRect().location()); 269 frameView.getScrollableArea()->visibleContentRect().location());
270 270
271 webViewImpl()->resize(IntSize(800, 600)); 271 webViewImpl()->resize(IntSize(800, 600));
272 272
273 EXPECT_POINT_EQ( 273 EXPECT_POINT_EQ(
274 expectedLocation, 274 expectedLocation,
275 frameView.getScrollableArea()->visibleContentRect().location()); 275 frameView.getScrollableArea()->visibleContentRect().location());
276 } 276 }
277 277
278 // Test the main frame scrollbars take visual viewport into account.
279 TEST_F(VisualViewportTest, VerifyScrollbarBehavior) {
280 initializeWithDesktopSettings();
281
282 registerMockedHttpURLLoad("200-by-800-viewport.html");
283 navigateTo(m_baseURL + "200-by-800-viewport.html");
284
285 webViewImpl()->resize(IntSize(300, 200));
286
287 // Initially, there is no horizontal scrollbar since the content fits.
288 EXPECT_FALSE(frame()->view()->horizontalScrollbar());
289 EXPECT_TRUE(frame()->view()->verticalScrollbar());
290
291 // Scroll layout viewport.
292 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200));
293 EXPECT_SIZE_EQ(
294 ScrollOffset(0, 200),
295 frame()->view()->layoutViewportScrollableArea()->scrollOffset());
296
297 webViewImpl()->setPageScaleFactor(2.0);
298
299 // Pinch-zooming should add horizontal scrollbar.
300 EXPECT_TRUE(frame()->view()->horizontalScrollbar());
301 EXPECT_TRUE(frame()->view()->verticalScrollbar());
302
303 // Scroll visual viewport.
304 VisualViewport& visualViewport =
305 frame()->page()->frameHost().visualViewport();
306 visualViewport.setLocation(FloatPoint(100, 100));
307 EXPECT_FLOAT_SIZE_EQ(FloatSize(100, 100), visualViewport.scrollOffset());
308
309 // Scrollbar offset should take visual viewport into account.
310 EXPECT_FLOAT_EQ(100, frame()->view()->horizontalScrollbar()->currentPos());
311 EXPECT_FLOAT_EQ(300, frame()->view()->verticalScrollbar()->currentPos());
312 }
313
278 // Test that the VisualViewport works as expected in case of a scaled 314 // Test that the VisualViewport works as expected in case of a scaled
279 // and scrolled viewport - scroll down. 315 // and scrolled viewport - scroll down.
280 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) { 316 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) {
281 /* 317 /*
282 200 200 318 200 200
283 | | | | 319 | | | |
284 | | | | 320 | | | |
285 | | 800 | | 800 321 | | 800 | | 800
286 |-------------------| | | 322 |-------------------| | |
287 | | | | 323 | | | |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 webViewImpl()->resize(IntSize(600, 800)); 2107 webViewImpl()->resize(IntSize(600, 800));
2072 2108
2073 EXPECT_SIZE_EQ(ScrollOffset(), 2109 EXPECT_SIZE_EQ(ScrollOffset(),
2074 frameView.layoutViewportScrollableArea()->scrollOffset()); 2110 frameView.layoutViewportScrollableArea()->scrollOffset());
2075 EXPECT_EQ(600, scroller->scrollTop()); 2111 EXPECT_EQ(600, scroller->scrollTop());
2076 2112
2077 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); 2113 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled);
2078 } 2114 }
2079 2115
2080 } // namespace 2116 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698