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