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

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

Issue 560623002: Adjust maximum scroll bounds on FrameView to account for top controls. (Blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 2 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/WebViewImpl.cpp ('k') | public/web/WebWidget.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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 using namespace blink; 116 using namespace blink;
117 117
118 const int touchPointPadding = 32; 118 const int touchPointPadding = 32;
119 119
120 #define EXPECT_EQ_RECT(a, b) \ 120 #define EXPECT_EQ_RECT(a, b) \
121 EXPECT_EQ(a.x(), b.x()); \ 121 EXPECT_EQ(a.x(), b.x()); \
122 EXPECT_EQ(a.y(), b.y()); \ 122 EXPECT_EQ(a.y(), b.y()); \
123 EXPECT_EQ(a.width(), b.width()); \ 123 EXPECT_EQ(a.width(), b.width()); \
124 EXPECT_EQ(a.height(), b.height()); 124 EXPECT_EQ(a.height(), b.height());
125 125
126 #define EXPECT_EQ_POINT(a, b) \
127 EXPECT_EQ(a.x(), b.x()); \
128 EXPECT_EQ(a.y(), b.y());
129
126 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { 130 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
127 public: 131 public:
128 virtual bool enterFullScreen() OVERRIDE { return true; } 132 virtual bool enterFullScreen() OVERRIDE { return true; }
129 }; 133 };
130 134
131 class WebFrameTest : public testing::Test { 135 class WebFrameTest : public testing::Test {
132 protected: 136 protected:
133 WebFrameTest() 137 WebFrameTest()
134 : m_baseURL("http://www.test.com/") 138 : m_baseURL("http://www.test.com/")
135 , m_chromeURL("chrome://") 139 , m_chromeURL("chrome://")
(...skipping 5661 matching lines...) Expand 10 before | Expand all | Expand 10 after
5797 FrameTestHelpers::WebViewHelper webViewHelper; 5801 FrameTestHelpers::WebViewHelper webViewHelper;
5798 webViewHelper.initializeAndLoad("about:blank"); 5802 webViewHelper.initializeAndLoad("about:blank");
5799 5803
5800 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 5804 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
5801 frameView->setFrameRect(IntRect(0, 0, 200, 200)); 5805 frameView->setFrameRect(IntRect(0, 0, 200, 200));
5802 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); 5806 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect());
5803 frameView->setFrameRect(IntRect(100, 100, 200, 200)); 5807 frameView->setFrameRect(IntRect(100, 100, 200, 200));
5804 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); 5808 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect());
5805 } 5809 }
5806 5810
5811 // FIXME(bokan) Renable once Chromium-side of patch lands
5812 TEST_F(WebFrameTest, DISABLED_FrameViewScrollAccountsForTopControls)
5813 {
5814 FrameTestHelpers::WebViewHelper webViewHelper;
5815 webViewHelper.initializeAndLoad("about:blank");
5816
5817 WebViewImpl* webView = webViewHelper.webViewImpl();
5818 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
5819
5820 webView->setTopControlsLayoutHeight(0);
5821 webView->resize(WebSize(100, 100));
5822 webView->setPageScaleFactor(2.0f);
5823 webView->layout();
5824
5825 webView->setMainFrameScrollOffset(WebPoint(20, 100));
5826 EXPECT_EQ_POINT(IntPoint(20, 50), IntPoint(frameView->scrollOffset()));
5827
5828 // Simulate the top controls showing by 20px, thus shrinking the viewport
5829 // and allowing it to scroll an additional 10px (since we're 2X zoomed).
5830 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
5831 EXPECT_EQ_POINT(IntPoint(50, 60), frameView->maximumScrollPosition());
5832
5833 // Show more, make sure the scroll actually gets clamped. Horizontal
5834 // direction shouldn't be affected.
5835 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
5836 webView->setMainFrameScrollOffset(WebPoint(100, 100));
5837 EXPECT_EQ_POINT(IntPoint(50, 70), IntPoint(frameView->scrollOffset()));
5838
5839 // Hide until there's 10px showing.
5840 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -30.0f);
5841 EXPECT_EQ_POINT(IntPoint(50, 55), frameView->maximumScrollPosition());
5842
5843 // Simulate a RenderWidget::resize. The frame is resized to accomodate
5844 // the top controls and Blink's view of the top controls matches that of
5845 // the CC
5846 webView->setTopControlsLayoutHeight(10.0f);
5847 webView->resize(WebSize(100, 90));
5848 webView->layout();
5849 EXPECT_EQ_POINT(IntPoint(50, 45), frameView->maximumScrollPosition());
5850
5851 // Now simulate hiding.
5852 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -10.0f);
5853 EXPECT_EQ_POINT(IntPoint(50, 40), frameView->maximumScrollPosition());
5854
5855 // Reset to original state: 100px widget height, top controls fully hidden.
5856 webView->setTopControlsLayoutHeight(0.0f);
5857 webView->resize(WebSize(100, 100));
5858 webView->layout();
5859 EXPECT_EQ_POINT(IntPoint(50, 50), frameView->maximumScrollPosition());
5860
5861 // Show the top controls by just 1px, since we're zoomed in to 2X, that
5862 // should allow an extra 0.5px of scrolling, but since we quantize to ints
5863 // it should clamp such that we don't show anything outside bounds.
5864 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 1.0f);
5865 EXPECT_EQ_POINT(IntPoint(50, 50), frameView->maximumScrollPosition());
5866
5867 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 2.0f);
5868 EXPECT_EQ_POINT(IntPoint(50, 51), frameView->maximumScrollPosition());
5869
5870
5871 }
5872
5807 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) 5873 TEST_F(WebFrameTest, FullscreenLayerNonScrollable)
5808 { 5874 {
5809 FakeCompositingWebViewClient client; 5875 FakeCompositingWebViewClient client;
5810 registerMockedHttpURLLoad("fullscreen_div.html"); 5876 registerMockedHttpURLLoad("fullscreen_div.html");
5811 FrameTestHelpers::WebViewHelper webViewHelper; 5877 FrameTestHelpers::WebViewHelper webViewHelper;
5812 int viewportWidth = 640; 5878 int viewportWidth = 640;
5813 int viewportHeight = 480; 5879 int viewportHeight = 480;
5814 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); 5880 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView);
5815 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 5881 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
5816 webViewImpl->layout(); 5882 webViewImpl->layout();
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
6346 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6412 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6347 6413
6348 // Neither should a page reload. 6414 // Neither should a page reload.
6349 localFrame->reload(); 6415 localFrame->reload();
6350 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6416 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6351 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6417 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6352 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6418 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6353 } 6419 }
6354 6420
6355 } // namespace 6421 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/web/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698