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

Unified Diff: third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp

Issue 2758233003: Fix the conditions when fullscreen detector listeners are registered (Closed)
Patch Set: addressed mlamouri's comments Created 3 years, 9 months 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 | « third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
diff --git a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
index 0f78b0034413eb98521a5abb0f9633b047830f18..9a1eea922fbec95f4bb1a5e57d2f9af583d28eb4 100644
--- a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
+++ b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
@@ -33,9 +33,6 @@ class MediaCustomControlsFullscreenDetectorTest : public ::testing::Test {
m_pageHolder = DummyPageHolder::create();
m_newPageHolder = DummyPageHolder::create();
-
- m_video = HTMLVideoElement::create(m_pageHolder->document());
- document().body()->appendChild(&videoElement());
}
void TearDown() override {
@@ -43,9 +40,17 @@ class MediaCustomControlsFullscreenDetectorTest : public ::testing::Test {
m_originalVideoFullscreenDetectionEnabled);
}
- HTMLVideoElement& videoElement() const { return *m_video; }
- MediaCustomControlsFullscreenDetector& fullscreenDetector() const {
- return *videoElement().m_customControlsFullscreenDetector;
+ HTMLVideoElement* videoElement() const {
+ return toHTMLVideoElement(document().querySelector("video"));
+ }
+
+ static MediaCustomControlsFullscreenDetector* fullscreenDetectorFor(
+ HTMLVideoElement* videoElement) {
+ return videoElement->m_customControlsFullscreenDetector;
+ }
+
+ MediaCustomControlsFullscreenDetector* fullscreenDetector() const {
+ return fullscreenDetectorFor(videoElement());
}
Document& document() const { return m_pageHolder->document(); }
@@ -109,30 +114,73 @@ TEST_F(MediaCustomControlsFullscreenDetectorTest, computeIsDominantVideo) {
}
}
-TEST_F(MediaCustomControlsFullscreenDetectorTest, documentMove) {
+TEST_F(MediaCustomControlsFullscreenDetectorTest,
+ hasNoListenersBeforeAddingToDocument) {
+ HTMLVideoElement* video =
+ toHTMLVideoElement(document().createElement("video"));
+
+ EXPECT_FALSE(checkEventListenerRegistered(document(),
+ EventTypeNames::fullscreenchange,
+ fullscreenDetectorFor(video)));
+ EXPECT_FALSE(checkEventListenerRegistered(
+ document(), EventTypeNames::webkitfullscreenchange,
+ fullscreenDetectorFor(video)));
+ EXPECT_FALSE(checkEventListenerRegistered(
+ *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video)));
+}
+
+TEST_F(MediaCustomControlsFullscreenDetectorTest,
+ hasListenersAfterAddToDocumentByScript) {
+ HTMLVideoElement* video =
+ toHTMLVideoElement(document().createElement("video"));
+ document().body()->appendChild(video);
+
EXPECT_TRUE(checkEventListenerRegistered(
- document(), EventTypeNames::fullscreenchange, &fullscreenDetector()));
+ document(), EventTypeNames::fullscreenchange, fullscreenDetector()));
EXPECT_TRUE(checkEventListenerRegistered(
document(), EventTypeNames::webkitfullscreenchange,
- &fullscreenDetector()));
- EXPECT_FALSE(checkEventListenerRegistered(
- newDocument(), EventTypeNames::fullscreenchange, &fullscreenDetector()));
- EXPECT_FALSE(checkEventListenerRegistered(
- newDocument(), EventTypeNames::webkitfullscreenchange,
- &fullscreenDetector()));
+ fullscreenDetector()));
+ EXPECT_TRUE(checkEventListenerRegistered(
+ *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector()));
+}
- newDocument().body()->appendChild(&videoElement());
+TEST_F(MediaCustomControlsFullscreenDetectorTest,
+ hasListenersAfterAddToDocumentByParser) {
+ document().body()->setInnerHTML("<body><video></video></body>");
- EXPECT_FALSE(checkEventListenerRegistered(
- document(), EventTypeNames::fullscreenchange, &fullscreenDetector()));
- EXPECT_FALSE(checkEventListenerRegistered(
+ EXPECT_TRUE(checkEventListenerRegistered(
+ document(), EventTypeNames::fullscreenchange, fullscreenDetector()));
+ EXPECT_TRUE(checkEventListenerRegistered(
document(), EventTypeNames::webkitfullscreenchange,
- &fullscreenDetector()));
+ fullscreenDetector()));
EXPECT_TRUE(checkEventListenerRegistered(
- newDocument(), EventTypeNames::fullscreenchange, &fullscreenDetector()));
+ *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector()));
+}
+
+TEST_F(MediaCustomControlsFullscreenDetectorTest,
+ hasListenersAfterDocumentMove) {
+ HTMLVideoElement* video =
+ toHTMLVideoElement(document().createElement("video"));
+ document().body()->appendChild(video);
+
+ newDocument().body()->appendChild(videoElement());
+
+ EXPECT_FALSE(checkEventListenerRegistered(document(),
+ EventTypeNames::fullscreenchange,
+ fullscreenDetectorFor(video)));
+ EXPECT_FALSE(checkEventListenerRegistered(
+ document(), EventTypeNames::webkitfullscreenchange,
+ fullscreenDetectorFor(video)));
+
+ EXPECT_TRUE(checkEventListenerRegistered(newDocument(),
+ EventTypeNames::fullscreenchange,
+ fullscreenDetectorFor(video)));
EXPECT_TRUE(checkEventListenerRegistered(
newDocument(), EventTypeNames::webkitfullscreenchange,
- &fullscreenDetector()));
+ fullscreenDetectorFor(video)));
+
+ EXPECT_TRUE(checkEventListenerRegistered(
+ *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video)));
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698