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

Side by Side Diff: third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp

Issue 2793273002: Use internal hooks for notifying fullscreen changes to media controls (Closed)
Patch Set: update more tests Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/html/MediaCustomControlsFullscreenDetector.h" 5 #include "core/html/MediaCustomControlsFullscreenDetector.h"
6 6
7 #include "core/EventTypeNames.h" 7 #include "core/EventTypeNames.h"
8 #include "core/html/HTMLVideoElement.h" 8 #include "core/html/HTMLVideoElement.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "platform/RuntimeEnabledFeatures.h" 10 #include "platform/RuntimeEnabledFeatures.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 computeIsDominantVideo(targetRect, rootRect, intersectionRect)) 112 computeIsDominantVideo(targetRect, rootRect, intersectionRect))
113 << testParam.description << " failed"; 113 << testParam.description << " failed";
114 } 114 }
115 } 115 }
116 116
117 TEST_F(MediaCustomControlsFullscreenDetectorTest, 117 TEST_F(MediaCustomControlsFullscreenDetectorTest,
118 hasNoListenersBeforeAddingToDocument) { 118 hasNoListenersBeforeAddingToDocument) {
119 HTMLVideoElement* video = 119 HTMLVideoElement* video =
120 toHTMLVideoElement(document().createElement("video")); 120 toHTMLVideoElement(document().createElement("video"));
121 121
122 EXPECT_FALSE(checkEventListenerRegistered(document(),
123 EventTypeNames::fullscreenchange,
124 fullscreenDetectorFor(video)));
125 EXPECT_FALSE(checkEventListenerRegistered(
126 document(), EventTypeNames::webkitfullscreenchange,
127 fullscreenDetectorFor(video)));
128 EXPECT_FALSE(checkEventListenerRegistered( 122 EXPECT_FALSE(checkEventListenerRegistered(
129 *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video))); 123 *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video)));
130 } 124 }
131 125
132 TEST_F(MediaCustomControlsFullscreenDetectorTest, 126 TEST_F(MediaCustomControlsFullscreenDetectorTest,
133 hasListenersAfterAddToDocumentByScript) { 127 hasListenersAfterAddToDocumentByScript) {
134 HTMLVideoElement* video = 128 HTMLVideoElement* video =
135 toHTMLVideoElement(document().createElement("video")); 129 toHTMLVideoElement(document().createElement("video"));
136 document().body()->appendChild(video); 130 document().body()->appendChild(video);
137 131
138 EXPECT_TRUE(checkEventListenerRegistered( 132 EXPECT_TRUE(checkEventListenerRegistered(
139 document(), EventTypeNames::fullscreenchange, fullscreenDetector()));
140 EXPECT_TRUE(checkEventListenerRegistered(
141 document(), EventTypeNames::webkitfullscreenchange,
142 fullscreenDetector()));
143 EXPECT_TRUE(checkEventListenerRegistered(
144 *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector())); 133 *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector()));
145 } 134 }
146 135
147 TEST_F(MediaCustomControlsFullscreenDetectorTest, 136 TEST_F(MediaCustomControlsFullscreenDetectorTest,
148 hasListenersAfterAddToDocumentByParser) { 137 hasListenersAfterAddToDocumentByParser) {
149 document().body()->setInnerHTML("<body><video></video></body>"); 138 document().body()->setInnerHTML("<body><video></video></body>");
150 139
151 EXPECT_TRUE(checkEventListenerRegistered( 140 EXPECT_TRUE(checkEventListenerRegistered(
152 document(), EventTypeNames::fullscreenchange, fullscreenDetector()));
153 EXPECT_TRUE(checkEventListenerRegistered(
154 document(), EventTypeNames::webkitfullscreenchange,
155 fullscreenDetector()));
156 EXPECT_TRUE(checkEventListenerRegistered(
157 *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector())); 141 *videoElement(), EventTypeNames::loadedmetadata, fullscreenDetector()));
158 } 142 }
159 143
160 TEST_F(MediaCustomControlsFullscreenDetectorTest, 144 TEST_F(MediaCustomControlsFullscreenDetectorTest,
161 hasListenersAfterDocumentMove) { 145 hasListenersAfterDocumentMove) {
162 HTMLVideoElement* video = 146 HTMLVideoElement* video =
163 toHTMLVideoElement(document().createElement("video")); 147 toHTMLVideoElement(document().createElement("video"));
164 document().body()->appendChild(video); 148 document().body()->appendChild(video);
165 149
166 newDocument().body()->appendChild(videoElement()); 150 newDocument().body()->appendChild(videoElement());
167 151
168 EXPECT_FALSE(checkEventListenerRegistered(document(),
169 EventTypeNames::fullscreenchange,
170 fullscreenDetectorFor(video)));
171 EXPECT_FALSE(checkEventListenerRegistered(
172 document(), EventTypeNames::webkitfullscreenchange,
173 fullscreenDetectorFor(video)));
174
175 EXPECT_TRUE(checkEventListenerRegistered(newDocument(),
176 EventTypeNames::fullscreenchange,
177 fullscreenDetectorFor(video)));
178 EXPECT_TRUE(checkEventListenerRegistered(
179 newDocument(), EventTypeNames::webkitfullscreenchange,
180 fullscreenDetectorFor(video)));
181
182 EXPECT_TRUE(checkEventListenerRegistered( 152 EXPECT_TRUE(checkEventListenerRegistered(
183 *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video))); 153 *video, EventTypeNames::loadedmetadata, fullscreenDetectorFor(video)));
184 } 154 }
185 155
186 } // namespace blink 156 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698