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

Side by Side Diff: third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html

Issue 2684973004: Remove unnecessary refreshCastButtonVisibility call (Closed)
Patch Set: Modify narrow video test to test resizing Created 3 years, 10 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>media controls cast button</title> 2 <title>media controls cast button</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="media-file.js"></script> 5 <script src="media-file.js"></script>
6 <script src="media-controls.js"></script> 6 <script src="media-controls.js"></script>
7 <video width="100" height="200" controls></video> 7 <video width="100" height="200" controls></video>
8 <script> 8 <script>
9 async_test(function(t) { 9 async_test(function(t) {
10 var video = document.querySelector("video"); 10 var video = document.querySelector("video");
11 video.src = findMediaFile("video", "content/test"); 11 video.src = findMediaFile("video", "content/test");
12 12
13 video.onloadedmetadata = t.step_func_done(function() { 13 video.onloadedmetadata = t.step_func(function() {
14 // Pretend we have a cast device 14 // Pretend we have a cast device
15 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); 15 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
16 16
17 // Video should not have a cast button since the video is too narrow 17 // Video should not have a cast button since the video is too narrow
18 var button = castButton(video); 18 assert_false(isVisible(castButton(video)), "button should not be visible ");
19 assert_equals(button.style.display, "none", "button should not be visibl e");
20 19
21 // It should not have an overlay cast button too. Instead, the button 20 // It should not have an overlay cast button too. Instead, the button
22 // should appear in the overflow menu. Tested somewhere else. 21 // should appear in the overflow menu. Tested somewhere else.
23 button = overlayCastButton(video); 22 assert_false(isVisible(overlayCastButton(video)), "button should not be visible");
24 assert_equals(button.style.display, "none", "button should not be visibl e"); 23
24 // Make video wider
mlamouri (slow - plz ping) 2017/02/14 09:58:05 Here and below, most of these comments are simply
steimel 2017/02/14 17:31:01 Done.
25 video.width = 500;
26
27 // Delay to give a chance for style to update
28 setTimeout(t.step_func(function() {
29
30 // Video should now have a cast button since the video is wide enoug h
31 assert_true(isVisible(castButton(video)), "button should be visible" );
32
33 // Make video thinner
34 video.width = 100;
35
36 // Delay to give a chance for style to update
37 setTimeout(t.step_func(function() {
mlamouri (slow - plz ping) 2017/02/14 09:58:05 You probably want `testRunner.layoutAndPaintAsyncT
steimel 2017/02/14 17:31:01 Done.
38
39 // Video should no longer have a cast button since the video is too thin
40 assert_false(isVisible(castButton(video)), "button should not be visible");
41
42 // Pretend we no longer have a cast device
43 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false );
44
45 // Make video wider
46 video.width = 500;
47
48 // Delay to give a chance for style to update
49 setTimeout(t.step_func_done(function() {
50
51 // Video should still have no cast button since we have no c ast device
52 assert_false(isVisible(castButton(video)), "button should no t be visible");
53
54 }), 0);
55 }), 0);
56 }), 0);
25 }); 57 });
26 58
27 function castButton(element) { 59 function isVisible(button) {
28 var controlID = "-internal-media-controls-cast-button"; 60 var computedStyle = getComputedStyle(button);
29 var button = mediaControlsElement(internals.shadowRoot(element).firstChi ld, controlID); 61 return computedStyle.display !== "none" &&
30 if (!button) 62 computedStyle.display !== "hidden" &&
31 throw "Failed to find cast button"; 63 computedStyle.visibility === "visible";
32 return button;
33 }
34
35 function overlayCastButton(element) {
36 var controlID = "-internal-media-controls-overlay-cast-button";
37 return mediaControlsElement(internals.shadowRoot(element).firstChild, co ntrolID);
38 return button
39 if (!button)
40 throw "Failed to find cast button";
41 return button;
42 } 64 }
43 }); 65 });
44 </script> 66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698