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

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

Issue 2556333002: Detect change on video/viewport intersection when rendered remotely (Closed)
Patch Set: Fix nits. 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
OLDNEW
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/dom/Document.h" 5 #include "core/dom/Document.h"
6 #include "core/html/HTMLMediaElement.h" 6 #include "core/html/HTMLMediaElement.h"
7 #include "platform/testing/UnitTestHelpers.h" 7 #include "platform/testing/UnitTestHelpers.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "web/tests/sim/SimCompositor.h" 9 #include "web/tests/sim/SimCompositor.h"
10 #include "web/tests/sim/SimDisplayItemList.h" 10 #include "web/tests/sim/SimDisplayItemList.h"
11 #include "web/tests/sim/SimRequest.h" 11 #include "web/tests/sim/SimRequest.h"
12 #include "web/tests/sim/SimTest.h" 12 #include "web/tests/sim/SimTest.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class MediaElementFillingViewportTest : public SimTest { 16 class MediaElementFillingViewportTest : public SimTest {
17 protected: 17 protected:
18 MediaElementFillingViewportTest() { webView().resize(WebSize(640, 480)); } 18 MediaElementFillingViewportTest() { webView().resize(WebSize(640, 480)); }
19 19
20 bool isMostlyFillingViewport(HTMLMediaElement* element) { 20 bool isMostlyFillingViewport(HTMLMediaElement* element) {
21 return element->m_mostlyFillingViewport; 21 return element->m_mostlyFillingViewport;
22 } 22 }
23 23
24 bool viewportFillDebouncerTimerActive(HTMLMediaElement* element) { 24 bool viewportFillDebouncerTimerActive(HTMLMediaElement* element) {
25 return element->m_viewportFillDebouncerTimer.isActive(); 25 return element->m_viewportFillDebouncerTimer.isActive();
26 } 26 }
27 27
28 void checkViewportIntersectionChanged(HTMLMediaElement* element) { 28 void checkViewportIntersectionChanged(HTMLMediaElement* element) {
29 element->checkViewportIntersectionChanged(); 29 element->activateViewportIntersectionMonitoring(true);
30 EXPECT_TRUE(element->m_checkViewportIntersectionTimer.isActive());
31 // TODO(xjz): Mock the time and wait for 1s instead.
32 element->checkViewportIntersectionTimerFired(nullptr);
30 } 33 }
31 34
32 std::unique_ptr<SimRequest> createMainResource() { 35 std::unique_ptr<SimRequest> createMainResource() {
33 std::unique_ptr<SimRequest> mainResource = 36 std::unique_ptr<SimRequest> mainResource =
34 WTF::wrapUnique(new SimRequest("https://example.com/", "text/html")); 37 WTF::wrapUnique(new SimRequest("https://example.com/", "text/html"));
35 loadURL("https://example.com"); 38 loadURL("https://example.com");
36 return mainResource; 39 return mainResource;
37 } 40 }
38 }; 41 };
39 42
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 element->setAttribute( 147 element->setAttribute(
145 "style", "position:fixed; left:0; top:240px; width:100%; height:100%;", 148 "style", "position:fixed; left:0; top:240px; width:100%; height:100%;",
146 ASSERT_NO_EXCEPTION); 149 ASSERT_NO_EXCEPTION);
147 compositor().beginFrame(); 150 compositor().beginFrame();
148 checkViewportIntersectionChanged(element); 151 checkViewportIntersectionChanged(element);
149 EXPECT_FALSE(isMostlyFillingViewport(element)); 152 EXPECT_FALSE(isMostlyFillingViewport(element));
150 EXPECT_FALSE(viewportFillDebouncerTimerActive(element)); 153 EXPECT_FALSE(viewportFillDebouncerTimerActive(element));
151 } 154 }
152 155
153 } // namespace blink 156 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.cpp ('k') | third_party/WebKit/public/platform/WebMediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698