Chromium Code Reviews| Index: Source/web/tests/WebFrameTest.cpp |
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
| index a768fda700b49ddeb5b49ac541e8c874e0732da9..5a077f95994ef6d6f763bec20f005585d4463780 100644 |
| --- a/Source/web/tests/WebFrameTest.cpp |
| +++ b/Source/web/tests/WebFrameTest.cpp |
| @@ -66,6 +66,7 @@ |
| #include "core/page/EventHandler.h" |
| #include "core/page/Page.h" |
| #include "core/rendering/HitTestResult.h" |
| +#include "core/rendering/RenderFullScreen.h" |
| #include "core/rendering/RenderView.h" |
| #include "core/rendering/compositing/RenderLayerCompositor.h" |
| #include "core/testing/URLTestHelpers.h" |
| @@ -145,11 +146,6 @@ const int touchPointPadding = 32; |
| EXPECT_EQ(a.x(), b.x()); \ |
| EXPECT_EQ(a.y(), b.y()); |
| -class FakeCompositingWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| -public: |
| - virtual bool enterFullScreen() override { return true; } |
| -}; |
| - |
| class WebFrameTest : public testing::Test { |
| protected: |
| WebFrameTest() |
| @@ -705,6 +701,11 @@ class FixedLayoutTestWebViewClient : public FrameTestHelpers::TestWebViewClient |
| WebScreenInfo m_screenInfo; |
| }; |
| +class FakeCompositingWebViewClient : public FixedLayoutTestWebViewClient { |
| +public: |
| + virtual bool enterFullScreen() override { return true; } |
| +}; |
| + |
| // Viewport settings need to be set before the page gets loaded |
| static void enableViewportSettings(WebSettings* settings) |
| { |
| @@ -6102,6 +6103,42 @@ TEST_F(WebFrameTest, DISABLED_FrameViewScrollAccountsForTopControls) |
| } |
| +TEST_F(WebFrameTest, FullscreenLayerSize) |
| +{ |
| + FakeCompositingWebViewClient client; |
| + registerMockedHttpURLLoad("fullscreen_div.html"); |
| + FrameTestHelpers::WebViewHelper webViewHelper; |
| + int viewportWidth = 640; |
| + int viewportHeight = 480; |
| + client.m_screenInfo.rect.width = viewportWidth; |
| + client.m_screenInfo.rect.height = viewportHeight; |
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true, 0, &client, configurePinchVirtualViewport); |
| + webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| + webViewImpl->layout(); |
| + |
| + Document* document = toWebLocalFrameImpl(webViewImpl->mainFrame())->frame()->document(); |
| + UserGestureIndicator gesture(DefinitelyProcessingUserGesture); |
| + Element* divFullscreen = document->getElementById("div1"); |
| + Fullscreen::from(*document).requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); |
| + webViewImpl->didEnterFullScreen(); |
| + webViewImpl->layout(); |
| + ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| + |
| + // Verify that the element is sized to the viewport. |
| + RenderFullScreen* fullscreenRenderer = Fullscreen::from(*document).fullScreenRenderer(); |
| + EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalWidth().toInt()); |
| + EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalHeight().toInt()); |
| + |
| + // Verify it's updated after a device rotation. |
| + client.m_screenInfo.rect.width = viewportHeight; |
| + client.m_screenInfo.rect.height = viewportWidth; |
| + webViewImpl->resize(WebSize(viewportHeight, viewportWidth)); |
| + webViewImpl->layout(); |
| + EXPECT_EQ(viewportHeight, fullscreenRenderer->logicalWidth().toInt()); |
| + EXPECT_EQ(viewportWidth, fullscreenRenderer->logicalHeight().toInt()); |
| + |
| +} |
| + |
| TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
| { |
| FakeCompositingWebViewClient client; |
| @@ -6109,7 +6146,7 @@ TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
| FrameTestHelpers::WebViewHelper webViewHelper; |
| int viewportWidth = 640; |
| int viewportHeight = 480; |
| - WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true, 0, &client, &configueCompositingWebView); |
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true, 0, &client, configurePinchVirtualViewport); |
|
bokan
2014/10/09 02:19:18
Do you think it's worth keeping a copy of these te
aelias_OOO_until_Jul13
2014/10/09 03:56:24
I don't think we should, as we're going to turn on
|
| webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| webViewImpl->layout(); |
| @@ -6120,17 +6157,19 @@ TEST_F(WebFrameTest, FullscreenLayerNonScrollable) |
| webViewImpl->didEnterFullScreen(); |
| webViewImpl->layout(); |
| - // Verify that the main frame bounds are empty. |
| + // Verify that the main frame is nonscrollable. |
| ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
| - ASSERT_EQ(WebSize(), webScrollLayer->bounds()); |
| + ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); |
| + ASSERT_FALSE(webScrollLayer->userScrollableVertical()); |
| // Verify that the main frame is scrollable upon exiting fullscreen. |
| webViewImpl->didExitFullScreen(); |
| webViewImpl->layout(); |
| ASSERT_FALSE(Fullscreen::isFullScreen(*document)); |
| webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
| - ASSERT_NE(WebSize(), webScrollLayer->bounds()); |
| + ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| + ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| } |
| TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
| @@ -6140,7 +6179,7 @@ TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
| FrameTestHelpers::WebViewHelper webViewHelper; |
| int viewportWidth = 640; |
| int viewportHeight = 480; |
| - WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true, 0, &client, &configueCompositingWebView); |
| + WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_div.html", true, 0, &client, configurePinchVirtualViewport); |
| webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); |
| webViewImpl->layout(); |
| @@ -6154,6 +6193,8 @@ TEST_F(WebFrameTest, FullscreenMainFrameScrollable) |
| ASSERT_TRUE(Fullscreen::isFullScreen(*document)); |
| WebLayer* webScrollLayer = webViewImpl->compositor()->scrollLayer()->platformLayer(); |
| ASSERT_TRUE(webScrollLayer->scrollable()); |
| + ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); |
| + ASSERT_TRUE(webScrollLayer->userScrollableVertical()); |
| } |
| TEST_F(WebFrameTest, RenderBlockPercentHeightDescendants) |