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" |
11 #include "core/paint/StubChromeClientForSPv2.h" | 11 #include "core/paint/StubChromeClientForSPv2.h" |
12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
13 #include "platform/testing/UnitTestHelpers.h" | 14 #include "platform/testing/UnitTestHelpers.h" |
14 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
15 #include "public/platform/WebCompositorSupport.h" | 16 #include "public/platform/WebCompositorSupport.h" |
16 #include "public/platform/WebLayer.h" | 17 #include "public/platform/WebLayer.h" |
17 #include "public/platform/WebMediaPlayer.h" | 18 #include "public/platform/WebMediaPlayer.h" |
18 #include "public/platform/WebSize.h" | 19 #include "public/platform/WebSize.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 // Integration tests of video painting code (in SPv2 mode). | 22 // Integration tests of video painting code (in SPv2 mode). |
22 | 23 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 public: | 83 public: |
83 // FrameLoaderClient | 84 // FrameLoaderClient |
84 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( | 85 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( |
85 HTMLMediaElement&, | 86 HTMLMediaElement&, |
86 const WebMediaPlayerSource&, | 87 const WebMediaPlayerSource&, |
87 WebMediaPlayerClient* client) override { | 88 WebMediaPlayerClient* client) override { |
88 return WTF::makeUnique<StubWebMediaPlayer>(client); | 89 return WTF::makeUnique<StubWebMediaPlayer>(client); |
89 } | 90 } |
90 }; | 91 }; |
91 | 92 |
92 class VideoPainterTestForSPv2 : public ::testing::Test { | 93 class VideoPainterTestForSPv2 : public ::testing::Test, |
| 94 private ScopedSlimmingPaintV2ForTest { |
| 95 public: |
| 96 VideoPainterTestForSPv2() : ScopedSlimmingPaintV2ForTest(true) {} |
| 97 |
93 protected: | 98 protected: |
94 void SetUp() override { | 99 void SetUp() override { |
95 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | |
96 m_chromeClient = new StubChromeClientForSPv2(); | 100 m_chromeClient = new StubChromeClientForSPv2(); |
97 m_frameLoaderClient = new StubFrameLoaderClient; | 101 m_frameLoaderClient = new StubFrameLoaderClient; |
98 Page::PageClients clients; | 102 Page::PageClients clients; |
99 fillWithEmptyClients(clients); | 103 fillWithEmptyClients(clients); |
100 clients.chromeClient = m_chromeClient.get(); | 104 clients.chromeClient = m_chromeClient.get(); |
101 m_pageHolder = DummyPageHolder::create( | 105 m_pageHolder = DummyPageHolder::create( |
102 IntSize(800, 600), &clients, m_frameLoaderClient.get(), | 106 IntSize(800, 600), &clients, m_frameLoaderClient.get(), |
103 [](Settings& settings) { | 107 [](Settings& settings) { |
104 settings.setAcceleratedCompositingEnabled(true); | 108 settings.setAcceleratedCompositingEnabled(true); |
105 }); | 109 }); |
106 document().view()->setParentVisible(true); | 110 document().view()->setParentVisible(true); |
107 document().view()->setSelfVisible(true); | 111 document().view()->setSelfVisible(true); |
108 document().setURL(KURL(KURL(), "https://example.com/")); | 112 document().setURL(KURL(KURL(), "https://example.com/")); |
109 } | 113 } |
110 | 114 |
111 void TearDown() override { m_featuresBackup.restore(); } | |
112 | |
113 Document& document() { return m_pageHolder->document(); } | 115 Document& document() { return m_pageHolder->document(); } |
114 bool hasLayerAttached(const WebLayer& layer) { | 116 bool hasLayerAttached(const WebLayer& layer) { |
115 return m_chromeClient->hasLayer(layer); | 117 return m_chromeClient->hasLayer(layer); |
116 } | 118 } |
117 | 119 |
118 private: | 120 private: |
119 RuntimeEnabledFeatures::Backup m_featuresBackup; | |
120 Persistent<StubChromeClientForSPv2> m_chromeClient; | 121 Persistent<StubChromeClientForSPv2> m_chromeClient; |
121 Persistent<StubFrameLoaderClient> m_frameLoaderClient; | 122 Persistent<StubFrameLoaderClient> m_frameLoaderClient; |
122 std::unique_ptr<DummyPageHolder> m_pageHolder; | 123 std::unique_ptr<DummyPageHolder> m_pageHolder; |
123 }; | 124 }; |
124 | 125 |
125 TEST_F(VideoPainterTestForSPv2, VideoLayerAppearsInLayerTree) { | 126 TEST_F(VideoPainterTestForSPv2, VideoLayerAppearsInLayerTree) { |
126 // Insert a <video> and allow it to begin loading. | 127 // Insert a <video> and allow it to begin loading. |
127 document().body()->setInnerHTML("<video width=300 height=200 src=test.ogv>"); | 128 document().body()->setInnerHTML("<video width=300 height=200 src=test.ogv>"); |
128 testing::runPendingTasks(); | 129 testing::runPendingTasks(); |
129 | 130 |
130 // Force the page to paint. | 131 // Force the page to paint. |
131 document().view()->updateAllLifecyclePhases(); | 132 document().view()->updateAllLifecyclePhases(); |
132 | 133 |
133 // Fetch the layer associated with the <video>, and check that it was | 134 // Fetch the layer associated with the <video>, and check that it was |
134 // correctly configured in the layer tree. | 135 // correctly configured in the layer tree. |
135 HTMLMediaElement* element = | 136 HTMLMediaElement* element = |
136 toHTMLMediaElement(document().body()->firstChild()); | 137 toHTMLMediaElement(document().body()->firstChild()); |
137 StubWebMediaPlayer* player = | 138 StubWebMediaPlayer* player = |
138 static_cast<StubWebMediaPlayer*>(element->webMediaPlayer()); | 139 static_cast<StubWebMediaPlayer*>(element->webMediaPlayer()); |
139 const WebLayer* layer = player->getWebLayer(); | 140 const WebLayer* layer = player->getWebLayer(); |
140 ASSERT_TRUE(layer); | 141 ASSERT_TRUE(layer); |
141 EXPECT_TRUE(hasLayerAttached(*layer)); | 142 EXPECT_TRUE(hasLayerAttached(*layer)); |
142 EXPECT_EQ(WebSize(300, 200), layer->bounds()); | 143 EXPECT_EQ(WebSize(300, 200), layer->bounds()); |
143 } | 144 } |
144 | 145 |
145 } // namespace | 146 } // namespace |
146 } // namespace blink | 147 } // namespace blink |
OLD | NEW |