| Index: Source/web/tests/WebFrameTest.cpp
|
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
|
| index d95da729465af4e13ce8c37168ead70d74dd3090..0d7215e4d7a6bce26704ce0df5230d2a3e663cc7 100644
|
| --- a/Source/web/tests/WebFrameTest.cpp
|
| +++ b/Source/web/tests/WebFrameTest.cpp
|
| @@ -121,6 +121,10 @@ const int touchPointPadding = 32;
|
| EXPECT_EQ(a.width(), b.width()); \
|
| EXPECT_EQ(a.height(), b.height());
|
|
|
| +#define EXPECT_EQ_POINT(a, b) \
|
| + EXPECT_EQ(a.x(), b.x()); \
|
| + EXPECT_EQ(a.y(), b.y());
|
| +
|
| class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient {
|
| public:
|
| virtual bool enterFullScreen() OVERRIDE { return true; }
|
| @@ -5730,6 +5734,50 @@ TEST_F(WebFrameTest, FrameViewSetFrameRect)
|
| EXPECT_EQ_RECT(IntRect(100, 100, 200, 200), frameView->frameRect());
|
| }
|
|
|
| +TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls)
|
| +{
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + webViewHelper.initializeAndLoad("about:blank");
|
| +
|
| + WebViewImpl* webView = webViewHelper.webViewImpl();
|
| + FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameView();
|
| +
|
| + webView->setTopControlsLayoutHeight(0);
|
| + webView->resize(WebSize(100, 100));
|
| + webView->setPageScaleFactor(2.0f);
|
| + webView->layout();
|
| +
|
| + webView->setMainFrameScrollOffset(WebPoint(20, 100));
|
| + EXPECT_EQ_POINT(IntPoint(20, 50), IntPoint(frameView->scrollOffset()));
|
| +
|
| + // Simulate the top controls showing by 20px, thus shrinking the viewport
|
| + // and allowing it to scroll an additional 10px (since we're 2X zoomed).
|
| + webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
|
| + EXPECT_EQ_POINT(IntPoint(50, 60), frameView->maximumScrollPosition());
|
| +
|
| + // Show more, make sure the scroll actually gets clamped. Horizontal
|
| + // direction shouldn't be affected.
|
| + webView->applyViewportDeltas(WebSize(0, 0), 1.0f, 20.0f);
|
| + webView->setMainFrameScrollOffset(WebPoint(100, 100));
|
| + EXPECT_EQ_POINT(IntPoint(50, 70), IntPoint(frameView->scrollOffset()));
|
| +
|
| + // Hide until there's 10px showing.
|
| + webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -30.0f);
|
| + EXPECT_EQ_POINT(IntPoint(50, 55), frameView->maximumScrollPosition());
|
| +
|
| + // Simulate a RenderWidget::resize. The frame is resized to accomodate
|
| + // the top controls and Blink's view of the top controls matches that of
|
| + // the CC
|
| + webView->setTopControlsLayoutHeight(10.0f);
|
| + webView->resize(WebSize(100, 90));
|
| + webView->layout();
|
| + EXPECT_EQ_POINT(IntPoint(50, 45), frameView->maximumScrollPosition());
|
| +
|
| + // Now simulate hiding.
|
| + webView->applyViewportDeltas(WebSize(0, 0), 1.0f, -10.0f);
|
| + EXPECT_EQ_POINT(IntPoint(50, 40), frameView->maximumScrollPosition());
|
| +}
|
| +
|
| TEST_F(WebFrameTest, FullscreenLayerNonScrollable)
|
| {
|
| FakeCompositingWebViewClient client;
|
|
|