| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/VideoPainter.h" | 5 #include "core/paint/VideoPainter.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/html/HTMLMediaElement.h" | 9 #include "core/html/HTMLMediaElement.h" |
| 10 #include "core/loader/EmptyClients.h" | 10 #include "core/loader/EmptyClients.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 class StubFrameLoaderClient : public EmptyFrameLoaderClient { | 79 class StubFrameLoaderClient : public EmptyFrameLoaderClient { |
| 80 public: | 80 public: |
| 81 // FrameLoaderClient | 81 // FrameLoaderClient |
| 82 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, cons
t WebMediaPlayerSource&, WebMediaPlayerClient* client) override | 82 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, cons
t WebMediaPlayerSource&, WebMediaPlayerClient* client) override |
| 83 { | 83 { |
| 84 return wrapUnique(new StubWebMediaPlayer(client)); | 84 return wrapUnique(new StubWebMediaPlayer(client)); |
| 85 } | 85 } |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class VideoPainterTestForSPv2 : public ::testing::TestWithParam<WebLayerTreeView
ImplForTesting::LayerListPolicy> { | 88 class VideoPainterTestForSPv2 : public ::testing::Test { |
| 89 protected: | 89 protected: |
| 90 void SetUp() override | 90 void SetUp() override |
| 91 { | 91 { |
| 92 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 92 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 93 m_chromeClient = new StubChromeClientForSPv2(GetParam()); | 93 m_chromeClient = new StubChromeClientForSPv2(); |
| 94 m_frameLoaderClient = new StubFrameLoaderClient; | 94 m_frameLoaderClient = new StubFrameLoaderClient; |
| 95 Page::PageClients clients; | 95 Page::PageClients clients; |
| 96 fillWithEmptyClients(clients); | 96 fillWithEmptyClients(clients); |
| 97 clients.chromeClient = m_chromeClient.get(); | 97 clients.chromeClient = m_chromeClient.get(); |
| 98 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients, m_fr
ameLoaderClient.get(), | 98 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients, m_fr
ameLoaderClient.get(), |
| 99 [](Settings& settings) { settings.setAcceleratedCompositingEnabled(t
rue); }); | 99 [](Settings& settings) { settings.setAcceleratedCompositingEnabled(t
rue); }); |
| 100 document().view()->setParentVisible(true); | 100 document().view()->setParentVisible(true); |
| 101 document().view()->setSelfVisible(true); | 101 document().view()->setSelfVisible(true); |
| 102 document().setURL(KURL(KURL(), "https://example.com/")); | 102 document().setURL(KURL(KURL(), "https://example.com/")); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void TearDown() override | 105 void TearDown() override |
| 106 { | 106 { |
| 107 m_featuresBackup.restore(); | 107 m_featuresBackup.restore(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 Document& document() { return m_pageHolder->document(); } | 110 Document& document() { return m_pageHolder->document(); } |
| 111 bool hasLayerAttached(const WebLayer& layer) { return m_chromeClient->hasLay
er(layer); } | 111 bool hasLayerAttached(const WebLayer& layer) { return m_chromeClient->hasLay
er(layer); } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 RuntimeEnabledFeatures::Backup m_featuresBackup; | 114 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 115 Persistent<StubChromeClientForSPv2> m_chromeClient; | 115 Persistent<StubChromeClientForSPv2> m_chromeClient; |
| 116 Persistent<StubFrameLoaderClient> m_frameLoaderClient; | 116 Persistent<StubFrameLoaderClient> m_frameLoaderClient; |
| 117 std::unique_ptr<DummyPageHolder> m_pageHolder; | 117 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 INSTANTIATE_TEST_CASE_P(, VideoPainterTestForSPv2, ::testing::Values( | 120 TEST_F(VideoPainterTestForSPv2, VideoLayerAppearsInLayerTree) |
| 121 WebLayerTreeViewImplForTesting::DontUseLayerLists, | |
| 122 WebLayerTreeViewImplForTesting::UseLayerLists)); | |
| 123 | |
| 124 TEST_P(VideoPainterTestForSPv2, VideoLayerAppearsInLayerTree) | |
| 125 { | 121 { |
| 126 // Insert a <video> and allow it to begin loading. | 122 // Insert a <video> and allow it to begin loading. |
| 127 document().body()->setInnerHTML("<video width=300 height=200 src=test.ogv>",
ASSERT_NO_EXCEPTION); | 123 document().body()->setInnerHTML("<video width=300 height=200 src=test.ogv>",
ASSERT_NO_EXCEPTION); |
| 128 testing::runPendingTasks(); | 124 testing::runPendingTasks(); |
| 129 | 125 |
| 130 // Force the page to paint. | 126 // Force the page to paint. |
| 131 document().view()->updateAllLifecyclePhases(); | 127 document().view()->updateAllLifecyclePhases(); |
| 132 | 128 |
| 133 // Fetch the layer associated with the <video>, and check that it was | 129 // Fetch the layer associated with the <video>, and check that it was |
| 134 // correctly configured in the layer tree. | 130 // correctly configured in the layer tree. |
| 135 HTMLMediaElement* element = toHTMLMediaElement(document().body()->firstChild
()); | 131 HTMLMediaElement* element = toHTMLMediaElement(document().body()->firstChild
()); |
| 136 StubWebMediaPlayer* player = static_cast<StubWebMediaPlayer*>(element->webMe
diaPlayer()); | 132 StubWebMediaPlayer* player = static_cast<StubWebMediaPlayer*>(element->webMe
diaPlayer()); |
| 137 const WebLayer* layer = player->getWebLayer(); | 133 const WebLayer* layer = player->getWebLayer(); |
| 138 ASSERT_TRUE(layer); | 134 ASSERT_TRUE(layer); |
| 139 EXPECT_TRUE(hasLayerAttached(*layer)); | 135 EXPECT_TRUE(hasLayerAttached(*layer)); |
| 140 EXPECT_EQ(WebSize(300, 200), layer->bounds()); | 136 EXPECT_EQ(WebSize(300, 200), layer->bounds()); |
| 141 } | 137 } |
| 142 | 138 |
| 143 } // namespace | 139 } // namespace |
| 144 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |