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

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

Issue 2527093003: Improve Fullscreen unit tests (Closed)
Patch Set: avoid ugly cast 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5bb2d65cdefaadd1923117005fdb4299d42923ff..b48d7208e4b6132b3d99b20fdcf280843a1df7ae 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"
@@ -7600,9 +7600,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 +7640,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 +7664,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 +7694,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 +7978,57 @@ TEST_P(ParameterizedWebFrameTest, ClearFullscreenConstraintsOnNavigation) {
EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
}
+namespace {
+
+class TestFullscreenWebLayerTreeView : public WebLayerTreeView {
+ public:
+ void setHasTransparentBackground(bool value) override {
+ hasTransparentBackground = value;
+ }
+ bool hasTransparentBackground = false;
+};
+
+class TestFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient {
+ public:
+ WebLayerTreeView* layerTreeView() override {
+ return &testFullscreenLayerTreeView;
+ }
+ TestFullscreenWebLayerTreeView testFullscreenLayerTreeView;
+};
+
+} // anonymous namespace
+
+TEST_P(ParameterizedWebFrameTest, OverlayFullscreenVideo) {
+ RuntimeEnabledFeatures::setForceOverlayFullscreenVideoEnabled(true);
+ registerMockedHttpURLLoad("fullscreen_video.html");
+ TestFullscreenWebViewClient webViewClient;
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
+ m_baseURL + "fullscreen_video.html", true, nullptr, &webViewClient);
+
+ const TestFullscreenWebLayerTreeView& layerTreeView =
+ webViewClient.testFullscreenLayerTreeView;
+
+ 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;
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698