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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2527093003: Improve Fullscreen unit tests (Closed)
Patch Set: avoid ugly cast Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/fetch/MemoryCache.h" 54 #include "core/fetch/MemoryCache.h"
55 #include "core/fetch/ResourceFetcher.h" 55 #include "core/fetch/ResourceFetcher.h"
56 #include "core/frame/FrameHost.h" 56 #include "core/frame/FrameHost.h"
57 #include "core/frame/FrameView.h" 57 #include "core/frame/FrameView.h"
58 #include "core/frame/LocalFrame.h" 58 #include "core/frame/LocalFrame.h"
59 #include "core/frame/RemoteFrame.h" 59 #include "core/frame/RemoteFrame.h"
60 #include "core/frame/Settings.h" 60 #include "core/frame/Settings.h"
61 #include "core/frame/VisualViewport.h" 61 #include "core/frame/VisualViewport.h"
62 #include "core/html/HTMLBodyElement.h" 62 #include "core/html/HTMLBodyElement.h"
63 #include "core/html/HTMLFormElement.h" 63 #include "core/html/HTMLFormElement.h"
64 #include "core/html/HTMLMediaElement.h" 64 #include "core/html/HTMLVideoElement.h"
65 #include "core/html/ImageDocument.h" 65 #include "core/html/ImageDocument.h"
66 #include "core/input/EventHandler.h" 66 #include "core/input/EventHandler.h"
67 #include "core/layout/HitTestResult.h" 67 #include "core/layout/HitTestResult.h"
68 #include "core/layout/LayoutFullScreen.h" 68 #include "core/layout/LayoutFullScreen.h"
69 #include "core/layout/api/LayoutViewItem.h" 69 #include "core/layout/api/LayoutViewItem.h"
70 #include "core/layout/compositing/PaintLayerCompositor.h" 70 #include "core/layout/compositing/PaintLayerCompositor.h"
71 #include "core/loader/DocumentLoader.h" 71 #include "core/loader/DocumentLoader.h"
72 #include "core/loader/DocumentThreadableLoader.h" 72 #include "core/loader/DocumentThreadableLoader.h"
73 #include "core/loader/DocumentThreadableLoaderClient.h" 73 #include "core/loader/DocumentThreadableLoaderClient.h"
74 #include "core/loader/FrameLoadRequest.h" 74 #include "core/loader/FrameLoadRequest.h"
(...skipping 7518 matching lines...) Expand 10 before | Expand all | Expand 10 after
7593 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 7593 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
7594 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr, 7594 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr,
7595 configureAndroid); 7595 configureAndroid);
7596 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7596 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7597 webViewImpl->updateAllLifecyclePhases(); 7597 webViewImpl->updateAllLifecyclePhases();
7598 7598
7599 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7599 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7600 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7600 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7601 Element* divFullscreen = document->getElementById("div1"); 7601 Element* divFullscreen = document->getElementById("div1");
7602 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 7602 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7603 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
7604 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7603 webViewImpl->didEnterFullscreen(); 7605 webViewImpl->didEnterFullscreen();
7606 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7607 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7604 webViewImpl->updateAllLifecyclePhases(); 7608 webViewImpl->updateAllLifecyclePhases();
7605 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen); 7609 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7610 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7606 7611
7607 // Verify that the element is sized to the viewport. 7612 // Verify that the element is sized to the viewport.
7608 LayoutFullScreen* fullscreenLayoutObject = 7613 LayoutFullScreen* fullscreenLayoutObject =
7609 Fullscreen::from(*document).fullScreenLayoutObject(); 7614 Fullscreen::from(*document).fullScreenLayoutObject();
7610 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt()); 7615 EXPECT_EQ(viewportWidth, fullscreenLayoutObject->logicalWidth().toInt());
7611 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt()); 7616 EXPECT_EQ(viewportHeight, fullscreenLayoutObject->logicalHeight().toInt());
7612 7617
7613 // Verify it's updated after a device rotation. 7618 // Verify it's updated after a device rotation.
7614 client.m_screenInfo.rect.width = viewportHeight; 7619 client.m_screenInfo.rect.width = viewportHeight;
7615 client.m_screenInfo.rect.height = viewportWidth; 7620 client.m_screenInfo.rect.height = viewportWidth;
(...skipping 12 matching lines...) Expand all
7628 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 7633 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
7629 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr, 7634 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr,
7630 configureAndroid); 7635 configureAndroid);
7631 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7636 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7632 webViewImpl->updateAllLifecyclePhases(); 7637 webViewImpl->updateAllLifecyclePhases();
7633 7638
7634 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7639 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7635 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7640 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7636 Element* divFullscreen = document->getElementById("div1"); 7641 Element* divFullscreen = document->getElementById("div1");
7637 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest); 7642 Fullscreen::requestFullscreen(*divFullscreen, Fullscreen::PrefixedRequest);
7643 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
7644 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7638 webViewImpl->didEnterFullscreen(); 7645 webViewImpl->didEnterFullscreen();
7646 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7647 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7639 webViewImpl->updateAllLifecyclePhases(); 7648 webViewImpl->updateAllLifecyclePhases();
7649 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7650 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7640 7651
7641 // Verify that the viewports are nonscrollable. 7652 // Verify that the viewports are nonscrollable.
7642 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7643 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); 7653 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
7644 WebLayer* layoutViewportScrollLayer = 7654 WebLayer* layoutViewportScrollLayer =
7645 webViewImpl->compositor()->scrollLayer()->platformLayer(); 7655 webViewImpl->compositor()->scrollLayer()->platformLayer();
7646 WebLayer* visualViewportScrollLayer = frameView->page() 7656 WebLayer* visualViewportScrollLayer = frameView->page()
7647 ->frameHost() 7657 ->frameHost()
7648 .visualViewport() 7658 .visualViewport()
7649 .scrollLayer() 7659 .scrollLayer()
7650 ->platformLayer(); 7660 ->platformLayer();
7651 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal()); 7661 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableHorizontal());
7652 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical()); 7662 ASSERT_FALSE(layoutViewportScrollLayer->userScrollableVertical());
7653 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal()); 7663 ASSERT_FALSE(visualViewportScrollLayer->userScrollableHorizontal());
7654 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical()); 7664 ASSERT_FALSE(visualViewportScrollLayer->userScrollableVertical());
7655 7665
7656 // Verify that the viewports are scrollable upon exiting fullscreen. 7666 // Verify that the viewports are scrollable upon exiting fullscreen.
7667 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), divFullscreen);
7668 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), divFullscreen);
7657 webViewImpl->didExitFullscreen(); 7669 webViewImpl->didExitFullscreen();
7670 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
7671 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), nullptr);
7658 webViewImpl->updateAllLifecyclePhases(); 7672 webViewImpl->updateAllLifecyclePhases();
7659 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr); 7673 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
7674 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document), nullptr);
7660 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal()); 7675 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableHorizontal());
7661 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical()); 7676 ASSERT_TRUE(layoutViewportScrollLayer->userScrollableVertical());
7662 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal()); 7677 ASSERT_TRUE(visualViewportScrollLayer->userScrollableHorizontal());
7663 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical()); 7678 ASSERT_TRUE(visualViewportScrollLayer->userScrollableVertical());
7664 } 7679 }
7665 7680
7666 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) { 7681 TEST_P(ParameterizedWebFrameTest, FullscreenMainFrame) {
7667 FakeCompositingWebViewClient client; 7682 FakeCompositingWebViewClient client;
7668 registerMockedHttpURLLoad("fullscreen_div.html"); 7683 registerMockedHttpURLLoad("fullscreen_div.html");
7669 FrameTestHelpers::WebViewHelper webViewHelper; 7684 FrameTestHelpers::WebViewHelper webViewHelper;
7670 int viewportWidth = 640; 7685 int viewportWidth = 640;
7671 int viewportHeight = 480; 7686 int viewportHeight = 480;
7672 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad( 7687 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
7673 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr, 7688 m_baseURL + "fullscreen_div.html", true, nullptr, &client, nullptr,
7674 configureAndroid); 7689 configureAndroid);
7675 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 7690 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
7676 webViewImpl->updateAllLifecyclePhases(); 7691 webViewImpl->updateAllLifecyclePhases();
7677 7692
7678 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 7693 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
7679 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 7694 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
7680 Fullscreen::requestFullscreen(*document->documentElement(), 7695 Fullscreen::requestFullscreen(*document->documentElement(),
7681 Fullscreen::PrefixedRequest); 7696 Fullscreen::PrefixedRequest);
7697 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document), nullptr);
7698 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
7699 document->documentElement());
7682 webViewImpl->didEnterFullscreen(); 7700 webViewImpl->didEnterFullscreen();
7701 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document),
7702 document->documentElement());
7703 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
7704 document->documentElement());
7683 webViewImpl->updateAllLifecyclePhases(); 7705 webViewImpl->updateAllLifecyclePhases();
7706 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document),
7707 document->documentElement());
7708 EXPECT_EQ(Fullscreen::fullscreenElementFrom(*document),
7709 document->documentElement());
7684 7710
7685 // Verify that the main frame is still scrollable. 7711 // Verify that the main frame is still scrollable.
7686 EXPECT_EQ(Fullscreen::currentFullScreenElementFrom(*document),
7687 document->documentElement());
7688 WebLayer* webScrollLayer = 7712 WebLayer* webScrollLayer =
7689 webViewImpl->compositor()->scrollLayer()->platformLayer(); 7713 webViewImpl->compositor()->scrollLayer()->platformLayer();
7690 ASSERT_TRUE(webScrollLayer->scrollable()); 7714 ASSERT_TRUE(webScrollLayer->scrollable());
7691 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 7715 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
7692 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 7716 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
7693 7717
7694 // Verify the main frame still behaves correctly after a resize. 7718 // Verify the main frame still behaves correctly after a resize.
7695 webViewHelper.resize(WebSize(viewportHeight, viewportWidth)); 7719 webViewHelper.resize(WebSize(viewportHeight, viewportWidth));
7696 ASSERT_TRUE(webScrollLayer->scrollable()); 7720 ASSERT_TRUE(webScrollLayer->scrollable());
7697 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 7721 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
7947 7971
7948 // Make sure the new page's layout size and scale factor limits aren't 7972 // Make sure the new page's layout size and scale factor limits aren't
7949 // overridden. 7973 // overridden.
7950 layoutViewItem = webViewImpl->mainFrameImpl()->frameView()->layoutViewItem(); 7974 layoutViewItem = webViewImpl->mainFrameImpl()->frameView()->layoutViewItem();
7951 EXPECT_EQ(200, layoutViewItem.logicalWidth().floor()); 7975 EXPECT_EQ(200, layoutViewItem.logicalWidth().floor());
7952 EXPECT_EQ(400, layoutViewItem.logicalHeight().floor()); 7976 EXPECT_EQ(400, layoutViewItem.logicalHeight().floor());
7953 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor()); 7977 EXPECT_FLOAT_EQ(0.5, webViewImpl->minimumPageScaleFactor());
7954 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor()); 7978 EXPECT_FLOAT_EQ(5.0, webViewImpl->maximumPageScaleFactor());
7955 } 7979 }
7956 7980
7981 namespace {
7982
7983 class TestFullscreenWebLayerTreeView : public WebLayerTreeView {
7984 public:
7985 void setHasTransparentBackground(bool value) override {
7986 hasTransparentBackground = value;
7987 }
7988 bool hasTransparentBackground = false;
7989 };
7990
7991 class TestFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient {
7992 public:
7993 WebLayerTreeView* layerTreeView() override {
7994 return &testFullscreenLayerTreeView;
7995 }
7996 TestFullscreenWebLayerTreeView testFullscreenLayerTreeView;
7997 };
7998
7999 } // anonymous namespace
8000
8001 TEST_P(ParameterizedWebFrameTest, OverlayFullscreenVideo) {
8002 RuntimeEnabledFeatures::setForceOverlayFullscreenVideoEnabled(true);
8003 registerMockedHttpURLLoad("fullscreen_video.html");
8004 TestFullscreenWebViewClient webViewClient;
8005 FrameTestHelpers::WebViewHelper webViewHelper;
8006 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(
8007 m_baseURL + "fullscreen_video.html", true, nullptr, &webViewClient);
8008
8009 const TestFullscreenWebLayerTreeView& layerTreeView =
8010 webViewClient.testFullscreenLayerTreeView;
8011
8012 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
8013 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
8014 HTMLVideoElement* video =
8015 toHTMLVideoElement(document->getElementById("video"));
8016 EXPECT_TRUE(video->usesOverlayFullscreenVideo());
8017 EXPECT_FALSE(video->isFullscreen());
8018 EXPECT_FALSE(layerTreeView.hasTransparentBackground);
8019
8020 video->enterFullscreen();
8021 webViewImpl->didEnterFullscreen();
8022 webViewImpl->updateAllLifecyclePhases();
8023 EXPECT_TRUE(video->isFullscreen());
8024 EXPECT_TRUE(layerTreeView.hasTransparentBackground);
8025
8026 webViewImpl->didExitFullscreen();
8027 webViewImpl->updateAllLifecyclePhases();
8028 EXPECT_FALSE(video->isFullscreen());
8029 EXPECT_FALSE(layerTreeView.hasTransparentBackground);
8030 }
8031
7957 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) { 8032 TEST_P(ParameterizedWebFrameTest, LayoutBlockPercentHeightDescendants) {
7958 registerMockedHttpURLLoad("percent-height-descendants.html"); 8033 registerMockedHttpURLLoad("percent-height-descendants.html");
7959 FrameTestHelpers::WebViewHelper webViewHelper; 8034 FrameTestHelpers::WebViewHelper webViewHelper;
7960 webViewHelper.initializeAndLoad(m_baseURL + 8035 webViewHelper.initializeAndLoad(m_baseURL +
7961 "percent-height-descendants.html"); 8036 "percent-height-descendants.html");
7962 8037
7963 WebViewImpl* webView = webViewHelper.webView(); 8038 WebViewImpl* webView = webViewHelper.webView();
7964 webViewHelper.resize(WebSize(800, 800)); 8039 webViewHelper.resize(WebSize(800, 800));
7965 webView->updateAllLifecyclePhases(); 8040 webView->updateAllLifecyclePhases();
7966 8041
(...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after
10866 10941
10867 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); 10942 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached());
10868 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); 10943 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading());
10869 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); 10944 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad());
10870 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); 10945 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents());
10871 10946
10872 webViewHelper.reset(); 10947 webViewHelper.reset();
10873 } 10948 }
10874 10949
10875 } // namespace blink 10950 } // namespace blink
OLDNEW
« 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