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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 882683003: Normalize top controls offset to (0, 1), Blink-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename to shownratio Created 5 years, 10 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
« no previous file with comments | « Source/web/tests/PinchViewportTest.cpp ('k') | public/platform/WebLayerTreeView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 6147 matching lines...) Expand 10 before | Expand all | Expand 10 after
6158 FrameTestHelpers::WebViewHelper webViewHelper; 6158 FrameTestHelpers::WebViewHelper webViewHelper;
6159 webViewHelper.initializeAndLoad("about:blank"); 6159 webViewHelper.initializeAndLoad("about:blank");
6160 6160
6161 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6161 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
6162 frameView->setFrameRect(IntRect(0, 0, 200, 200)); 6162 frameView->setFrameRect(IntRect(0, 0, 200, 200));
6163 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); 6163 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect());
6164 frameView->setFrameRect(IntRect(100, 100, 200, 200)); 6164 frameView->setFrameRect(IntRect(100, 100, 200, 200));
6165 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); 6165 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect());
6166 } 6166 }
6167 6167
6168 // FIXME(bokan) Renable once Chromium-side of patch lands 6168 TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls)
6169 TEST_F(WebFrameTest, DISABLED_FrameViewScrollAccountsForTopControls)
6170 { 6169 {
6170 UseMockScrollbarSettings mockScrollbarSettings;
6171 FrameTestHelpers::WebViewHelper webViewHelper; 6171 FrameTestHelpers::WebViewHelper webViewHelper;
6172 webViewHelper.initializeAndLoad("about:blank"); 6172 webViewHelper.initializeAndLoad("about:blank");
6173 6173
6174 WebViewImpl* webView = webViewHelper.webViewImpl(); 6174 WebViewImpl* webView = webViewHelper.webViewImpl();
6175 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6175 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
6176 6176
6177 webView->setTopControlsLayoutHeight(0); 6177 float topControlsHeight = 40;
6178 webView->setTopControlsHeight(topControlsHeight, false);
6178 webView->resize(WebSize(100, 100)); 6179 webView->resize(WebSize(100, 100));
6179 webView->setPageScaleFactor(2.0f); 6180 webView->setPageScaleFactor(2.0f);
6180 webView->layout(); 6181 webView->layout();
6181 6182
6182 webView->setMainFrameScrollOffset(WebPoint(20, 100)); 6183 webView->setMainFrameScrollOffset(WebPoint(20, 100));
6183 EXPECT_POINT_EQ(IntPoint(20, 50), IntPoint(frameView->scrollOffset())); 6184 EXPECT_POINT_EQ(IntPoint(20, 50), IntPoint(frameView->scrollOffset()));
6184 6185
6185 // Simulate the top controls showing by 20px, thus shrinking the viewport 6186 // Simulate the top controls showing by 20px, thus shrinking the viewport
6186 // and allowing it to scroll an additional 10px (since we're 2X zoomed). 6187 // and allowing it to scroll an additional 10px (since we're 2X zoomed).
6187 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f); 6188 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f / topControlsHeight) ;
6188 EXPECT_POINT_EQ(IntPoint(50, 60), frameView->maximumScrollPosition()); 6189 EXPECT_POINT_EQ(IntPoint(50, 60), frameView->maximumScrollPosition());
6189 6190
6190 // Show more, make sure the scroll actually gets clamped. Horizontal 6191 // Show more, make sure the scroll actually gets clamped. Horizontal
6191 // direction shouldn't be affected. 6192 // direction shouldn't be affected.
6192 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f); 6193 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f / topControlsHeight) ;
6193 webView->setMainFrameScrollOffset(WebPoint(100, 100)); 6194 webView->setMainFrameScrollOffset(WebPoint(100, 100));
6194 EXPECT_POINT_EQ(IntPoint(50, 70), IntPoint(frameView->scrollOffset())); 6195 EXPECT_POINT_EQ(IntPoint(50, 70), IntPoint(frameView->scrollOffset()));
6195 6196
6196 // Hide until there's 10px showing. 6197 // Hide until there's 10px showing.
6197 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -30.0f); 6198 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -30.0f / topControlsHeight );
6198 EXPECT_POINT_EQ(IntPoint(50, 55), frameView->maximumScrollPosition()); 6199 EXPECT_POINT_EQ(IntPoint(50, 55), frameView->maximumScrollPosition());
6199 6200
6200 // Simulate a RenderPart::resize. The frame is resized to accomodate 6201 // Simulate a RenderPart::resize. The frame is resized to accomodate
6201 // the top controls and Blink's view of the top controls matches that of 6202 // the top controls and Blink's view of the top controls matches that of
6202 // the CC 6203 // the CC
6203 webView->setTopControlsLayoutHeight(10.0f); 6204 webView->setTopControlsHeight(40.0f, true);
6204 webView->resize(WebSize(100, 90)); 6205 webView->resize(WebSize(100, 90));
6205 webView->layout(); 6206 webView->layout();
6206 EXPECT_POINT_EQ(IntPoint(50, 45), frameView->maximumScrollPosition()); 6207 EXPECT_POINT_EQ(IntPoint(50, 30), frameView->maximumScrollPosition());
6207 6208
6208 // Now simulate hiding. 6209 // Now simulate hiding.
6209 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -10.0f); 6210 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -10.0f / topControlsHeight );
6210 EXPECT_POINT_EQ(IntPoint(50, 40), frameView->maximumScrollPosition()); 6211 EXPECT_POINT_EQ(IntPoint(50, 25), frameView->maximumScrollPosition());
6211 6212
6212 // Reset to original state: 100px widget height, top controls fully hidden. 6213 // Reset to original state: 100px widget height, top controls fully hidden.
6213 webView->setTopControlsLayoutHeight(0.0f); 6214 webView->setTopControlsHeight(topControlsHeight, false);
6214 webView->resize(WebSize(100, 100)); 6215 webView->resize(WebSize(100, 100));
6215 webView->layout(); 6216 webView->layout();
6216 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); 6217 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition());
6217 6218
6218 // Show the top controls by just 1px, since we're zoomed in to 2X, that 6219 // Show the top controls by just 1px, since we're zoomed in to 2X, that
6219 // should allow an extra 0.5px of scrolling, but since we quantize to ints 6220 // should allow an extra 0.5px of scrolling, but since we quantize to ints
6220 // it should clamp such that we don't show anything outside bounds. 6221 // it should clamp such that we don't show anything outside bounds.
6221 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f); 6222 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f / topControlsHeight);
6222 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition()); 6223 EXPECT_POINT_EQ(IntPoint(50, 50), frameView->maximumScrollPosition());
6223 6224
6224 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f); 6225 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f / topControlsHeight);
6225 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition()); 6226 EXPECT_POINT_EQ(IntPoint(50, 51), frameView->maximumScrollPosition());
6226 } 6227 }
6227 6228
6228 TEST_F(WebFrameTest, FullscreenLayerSize) 6229 TEST_F(WebFrameTest, FullscreenLayerSize)
6229 { 6230 {
6230 FakeCompositingWebViewClient client; 6231 FakeCompositingWebViewClient client;
6231 registerMockedHttpURLLoad("fullscreen_div.html"); 6232 registerMockedHttpURLLoad("fullscreen_div.html");
6232 FrameTestHelpers::WebViewHelper webViewHelper; 6233 FrameTestHelpers::WebViewHelper webViewHelper;
6233 int viewportWidth = 640; 6234 int viewportWidth = 640;
6234 int viewportHeight = 480; 6235 int viewportHeight = 480;
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
7019 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7020 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7020 7021
7021 // Neither should a page reload. 7022 // Neither should a page reload.
7022 localFrame->reload(); 7023 localFrame->reload();
7023 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 7024 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
7024 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 7025 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
7025 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7026 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7026 } 7027 }
7027 7028
7028 } // namespace 7029 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/PinchViewportTest.cpp ('k') | public/platform/WebLayerTreeView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698