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

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: Created 6 years, 3 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 /* 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 using namespace blink; 114 using namespace blink;
115 115
116 const int touchPointPadding = 32; 116 const int touchPointPadding = 32;
117 117
118 #define EXPECT_EQ_RECT(a, b) \ 118 #define EXPECT_EQ_RECT(a, b) \
119 EXPECT_EQ(a.x(), b.x()); \ 119 EXPECT_EQ(a.x(), b.x()); \
120 EXPECT_EQ(a.y(), b.y()); \ 120 EXPECT_EQ(a.y(), b.y()); \
121 EXPECT_EQ(a.width(), b.width()); \ 121 EXPECT_EQ(a.width(), b.width()); \
122 EXPECT_EQ(a.height(), b.height()); 122 EXPECT_EQ(a.height(), b.height());
123 123
124 #define EXPECT_EQ_POINT(a, b) \
125 EXPECT_EQ(a.x(), b.x()); \
126 EXPECT_EQ(a.y(), b.y());
127
124 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { 128 class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
125 public: 129 public:
126 virtual bool enterFullScreen() OVERRIDE { return true; } 130 virtual bool enterFullScreen() OVERRIDE { return true; }
127 }; 131 };
128 132
129 class WebFrameTest : public testing::Test { 133 class WebFrameTest : public testing::Test {
130 protected: 134 protected:
131 WebFrameTest() 135 WebFrameTest()
132 : m_baseURL("http://www.test.com/") 136 : m_baseURL("http://www.test.com/")
133 , m_chromeURL("chrome://") 137 , m_chromeURL("chrome://")
(...skipping 5589 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 FrameTestHelpers::WebViewHelper webViewHelper; 5727 FrameTestHelpers::WebViewHelper webViewHelper;
5724 webViewHelper.initializeAndLoad("about:blank"); 5728 webViewHelper.initializeAndLoad("about:blank");
5725 5729
5726 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 5730 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
5727 frameView->setFrameRect(IntRect(0, 0, 200, 200)); 5731 frameView->setFrameRect(IntRect(0, 0, 200, 200));
5728 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect()); 5732 EXPECT_EQ_RECT(IntRect(0, 0, 200, 200), frameView->frameRect());
5729 frameView->setFrameRect(IntRect(100, 100, 200, 200)); 5733 frameView->setFrameRect(IntRect(100, 100, 200, 200));
5730 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect()); 5734 EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect());
5731 } 5735 }
5732 5736
5737 TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls)
5738 {
5739 FrameTestHelpers::WebViewHelper webViewHelper;
5740 webViewHelper.initializeAndLoad("about:blank");
5741
5742 WebViewImpl* webView = webViewHelper.webViewImpl();
5743 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
5744
5745 webView->setTopControlsLayoutHeight(0);
5746 webView->resize(WebSize(100, 100));
5747 webView->setPageScaleFactor(2.0f);
5748 webView->layout();
5749
5750 webView->setMainFrameScrollOffset(WebPoint(20, 100));
5751 EXPECT_EQ_POINT(IntPoint(20, 50), IntPoint(frameView->scrollOffset()));
5752
5753 // Simulate the top controls showing by 20px, thus shrinking the viewport
5754 // and allowing it to scroll an additional 10px (since we're 2X zoomed).
5755 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
5756 EXPECT_EQ_POINT(IntPoint(50, 60), frameView->maximumScrollPosition());
5757
5758 // Show more, make sure the scroll actually gets clamped. Horizontal
5759 // direction shouldn't be affected.
5760 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
5761 webView->setMainFrameScrollOffset(WebPoint(100, 100));
5762 EXPECT_EQ_POINT(IntPoint(50, 70), IntPoint(frameView->scrollOffset()));
5763
5764 // Hide until there's 10px showing.
5765 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -30.0f);
5766 EXPECT_EQ_POINT(IntPoint(50, 55), frameView->maximumScrollPosition());
5767
5768 // Simulate a RenderWidget::resize. The frame is resized to accomodate
5769 // the top controls and Blink's view of the top controls matches that of
5770 // the CC
5771 webView->setTopControlsLayoutHeight(10.0f);
5772 webView->resize(WebSize(100, 90));
5773 webView->layout();
5774 EXPECT_EQ_POINT(IntPoint(50, 45), frameView->maximumScrollPosition());
5775
5776 // Now simulate hiding.
5777 webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -10.0f);
5778 EXPECT_EQ_POINT(IntPoint(50, 40), frameView->maximumScrollPosition());
5779 }
5780
5733 TEST_F(WebFrameTest, FullscreenLayerNonScrollable) 5781 TEST_F(WebFrameTest, FullscreenLayerNonScrollable)
5734 { 5782 {
5735 FakeCompositingWebViewClient client; 5783 FakeCompositingWebViewClient client;
5736 registerMockedHttpURLLoad("fullscreen_div.html"); 5784 registerMockedHttpURLLoad("fullscreen_div.html");
5737 FrameTestHelpers::WebViewHelper webViewHelper; 5785 FrameTestHelpers::WebViewHelper webViewHelper;
5738 int viewportWidth = 640; 5786 int viewportWidth = 640;
5739 int viewportHeight = 480; 5787 int viewportHeight = 480;
5740 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView); 5788 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "full screen_div.html", true, 0, &client, &configueCompositingWebView);
5741 webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); 5789 webViewImpl->resize(WebSize(viewportWidth, viewportHeight));
5742 webViewImpl->layout(); 5790 webViewImpl->layout();
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
6229 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6277 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6230 6278
6231 // Neither should a page reload. 6279 // Neither should a page reload.
6232 localFrame->reload(); 6280 localFrame->reload();
6233 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 6281 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
6234 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 6282 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
6235 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 6283 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
6236 } 6284 }
6237 6285
6238 } // namespace 6286 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698