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

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2527093003: Improve Fullscreen unit tests (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 6f76fac03bb0dcbf2e4ea7fe3e963934d5d475d3..3f5e4376a8f6af9e0d7a3ce554269e5b5f36950c 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -61,7 +61,7 @@
#include "core/frame/VisualViewport.h"
#include "core/html/HTMLBodyElement.h"
#include "core/html/HTMLFormElement.h"
-#include "core/html/HTMLMediaElement.h"
+#include "core/html/HTMLVideoElement.h"
#include "core/html/ImageDocument.h"
#include "core/input/EventHandler.h"
#include "core/layout/HitTestResult.h"
@@ -95,6 +95,7 @@
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
+#include "platform/testing/WebLayerTreeViewImplForTesting.h"
#include "platform/weborigin/KURLHash.h"
#include "platform/weborigin/SchemeRegistry.h"
#include "platform/weborigin/SecurityOrigin.h"
@@ -7600,9 +7601,14 @@ TEST_P(ParameterizedWebFrameTest, FullscreenLayerSize) {
UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
Element* divFullscreen = document->getElementById("div1");
Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
webViewImpl->didEnterFullscreen();
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
webViewImpl->updateAllLifecyclePhases();
EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
// Verify that the element is sized to the viewport.
LayoutFullScreen* fullscreenLayoutObject =
@@ -7635,11 +7641,16 @@ TEST_F(WebFrameTest, FullscreenLayerNonScrollable) {
UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
Element* divFullscreen = document->getElementById("div1");
Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
webViewImpl->didEnterFullscreen();
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
webViewImpl->updateAllLifecyclePhases();
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
// Verify that the viewports are nonscrollable.
- EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
WebLayer* layoutViewportScrollLayer =
webViewImpl->compositor()->scrollLayer()->platformLayer();
@@ -7654,9 +7665,14 @@ TEST_F(WebFrameTest, FullscreenLayerNonScrollable) {
ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical());
// Verify that the viewports are scrollable upon exiting fullscreen.
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
webViewImpl->didExitFullscreen();
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), nullptr);
webViewImpl->updateAllLifecyclePhases();
EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), nullptr);
ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal());
ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical());
ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal());
@@ -7679,12 +7695,21 @@ TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) {
UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
Fullscreen::requestFullscreen(*document->documentElement(),
Fullscreen::PrefixedRequest);
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
+ document->documentElement());
webViewImpl->didEnterFullscreen();
+ EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document),
+ document->documentElement());
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
+ document->documentElement());
webViewImpl->updateAllLifecyclePhases();
-
- // Verify that the main frame is still scrollable.
EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document),
document->documentElement());
+ EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
+ document->documentElement());
+
+ // Verify that the main frame is still scrollable.
WebLayer* webScrollLayer =
webViewImpl->compositor()->scrollLayer()->platformLayer();
ASSERT_TRUE(webScrollLayer->scrollable());
@@ -7954,6 +7979,38 @@ TEST_P(ParameterizedWebFrameTest, ClearFullscreenConstraintsOnNavigation) {
EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
}
+TEST_P(ParameterizedWebFrameTest, OverlayFullscreenVideo) {
+ RuntimeEnabledFeatures::setForceOverlayFullscreenVideoEnabled(true);
+ registerMockedHttpURLLoad("fullscreen_video.html");
+ FrameTestHelpers::TestWebViewClient webViewClient;
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
+ m_baseURL + "fullscreen_video.html", true, nullptr, &webViewClient);
+
+ WebLayerTreeViewImplForTesting* layerTreeView =
+ static_cast<WebLayerTreeViewImplForTesting*>(
foolip 2016/11/24 17:08:53 I can only assume this isn't cool? Is it acceptabl
eae 2016/11/24 21:45:31 It is a little gross but not without precedence. E
foolip 2016/11/28 14:23:37 A new week and it wasn't nearly as messy as I thou
+ webViewClient.layerTreeView());
+
+ Document* document = webViewImpl->mainFrameImpl()->frame()->document();
+ UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
+ HTMLVideoElement* video =
+ toHTMLVideoElement(document->getElementById("video"));
+ EXPECT_TRUE(video->usesOverlayFullscreenVideo());
+ EXPECT_FALSE(video->isFullscreen());
+ EXPECT_FALSE(layerTreeView->hasTransparentBackground());
+
+ video->enterFullscreen();
+ webViewImpl->didEnterFullscreen();
+ webViewImpl->updateAllLifecyclePhases();
+ EXPECT_TRUE(video->isFullscreen());
+ EXPECT_TRUE(layerTreeView->hasTransparentBackground());
+
+ webViewImpl->didExitFullscreen();
+ webViewImpl->updateAllLifecyclePhases();
+ EXPECT_FALSE(video->isFullscreen());
+ EXPECT_FALSE(layerTreeView->hasTransparentBackground());
+}
+
TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) {
registerMockedHttpURLLoad("percent-height-descendants.html");
FrameTestHelpers::WebViewHelper webViewHelper;

Powered by Google App Engine
This is Rietveld 408576698