OLD | NEW |
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test that the overlay cast button fades at the right time (neither too so
on nor too late).</title> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <title>Test that the overlay cast button fades at the right time (neithe
r too soon nor too late).</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="media-file.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="media-controls.js"></script> |
7 <script src="media-file.js"></script> | 7 <video loop></video> |
8 <script src="media-controls.js"></script> | 8 <script> |
9 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 9 async_test(function(t) { |
10 (Please avoid writing new tests using video-test.js) --> | 10 // The cast button should be visible for at least the controlsMouseMovementT
imeout, |
11 <script src="video-test.js"></script> | 11 // and no more than that plus the fadeout time. Allow 500ms margin at either
side. |
12 </head> | 12 var hideTimeoutLowerBound = controlsMouseMovementTimeoutMs - 500; |
13 <body> | 13 var hideTimeoutUpperBound = controlsMouseMovementTimeoutMs + controlsFadeOut
DurationMs + 500; |
14 <video loop></video> | 14 |
15 <script> | 15 var video = document.querySelector("video"); |
16 var controls; | 16 video.src = findMediaFile("video", "content/test"); |
17 var test; | 17 |
18 // The cast button should be visible for at least the controlsMouseMovem
entTimeout, and no more | 18 video.onplaying = t.step_func(function() { |
19 // than that plus the fadeout time. Allow 500ms margin at either side. | 19 setTimeout(t.step_func(function() { |
20 var hideTimeoutLowerBound = controlsMouseMovementTimeoutMs - 500; | 20 // Cast button should be visible |
21 var hideTimeoutUpperBound = controlsMouseMovementTimeoutMs + controlsFad
eOutDurationMs + 500; | 21 assert_true(isCastButtonVisible(), "button should exist"); |
22 function overlayCastButton(element) | 22 }), hideTimeoutLowerBound); |
23 { | 23 |
24 var controlID = "-internal-media-controls-overlay-cast-button"; | 24 setTimeout(t.step_func_done(function() { |
25 var button = mediaControlsElement(window.internals.shadowRoot(elemen
t).firstChild, controlID); | 25 // Cast button should be gone |
26 return button; | 26 assert_false(isCastButtonVisible(), "button should not exist"); |
27 } | 27 }), hideTimeoutUpperBound); |
28 async_test(function(t) | 28 }); |
29 { | 29 |
30 findMediaElement(); | 30 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); |
31 video.src = findMediaFile("video", "content/test"); | 31 video.play(); |
32 video.addEventListener("playing", t.step_func(function() | 32 |
33 { | 33 function isCastButtonVisible() { |
34 setTimeout(t.step_func(function() | 34 var controlID = "-internal-media-controls-overlay-cast-button"; |
35 { | 35 var button = mediaControlsElement(internals.shadowRoot(video).firstChild
, controlID); |
36 button = overlayCastButton(video); | 36 var style = getComputedStyle(button); |
37 // Now should have cast button | 37 var visibility = style.getPropertyValue("visibility"); |
38 style = window.getComputedStyle(button); | 38 var display = style.getPropertyValue("display"); |
39 visibility = style.getPropertyValue("visibility"); | 39 return (display != "none" && visibility == "visible"); |
40 display = style.getPropertyValue("display"); | 40 } |
41 assert_true(((display != "none")) && (visibility == "visible
"), | 41 }); |
42 "button should exist, display = \"" + display + '\"'
); | 42 </script> |
43 }), hideTimeoutLowerBound); | |
44 setTimeout(t.step_func(function() | |
45 { | |
46 button = overlayCastButton(video); | |
47 // Cast button shoud be gone | |
48 style = window.getComputedStyle(button); | |
49 visibility = style.getPropertyValue("visibility"); | |
50 display = style.getPropertyValue("display"); | |
51 assert_false(((display != "none")) && (visibility == "visibl
e"), | |
52 "button should not exist, display = \"" + display +
'\"'); | |
53 t.done(); | |
54 }), hideTimeoutUpperBound); | |
55 })); | |
56 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); | |
57 video.play(); | |
58 }); | |
59 </script> | |
60 </body> | |
61 </html> | |
OLD | NEW |