| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <title>media controls cast button</title> |
| 3 <head> | 3 <script src="../resources/testharness.js"></script> |
| 4 <title>media controls cast button</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 width="100" height="200" controls></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 { |
| 11 <script src="video-test.js"></script> | 11 var video = document.querySelector("video"); |
| 12 </head> | 12 video.src = findMediaFile("video", "content/test"); |
| 13 <body> | |
| 14 <video width="100" height="200" controls></video> | |
| 15 <script> | |
| 16 function castButton(element) | |
| 17 { | |
| 18 var controlID = "-internal-media-controls-cast-button"; | |
| 19 var button = mediaControlsElement(window.internals.shadowRoot(elemen
t).firstChild, controlID); | |
| 20 if (!button) | |
| 21 throw "Failed to find cast button"; | |
| 22 return button; | |
| 23 } | |
| 24 function overlayCastButton(element) | |
| 25 { | |
| 26 var controlID = "-internal-media-controls-overlay-cast-button"; | |
| 27 var button = mediaControlsElement(window.internals.shadowRoot(elemen
t).firstChild, controlID); | |
| 28 if (!button) | |
| 29 throw "Failed to find cast button"; | |
| 30 return button; | |
| 31 } | |
| 32 function castButtonDimensions(element) | |
| 33 { | |
| 34 var button = castButton(element); | |
| 35 var buttonBoundingRect = button.getBoundingClientRect(); | |
| 36 return new Array(buttonBoundingRect.width, buttonBoundingRect.height
); | |
| 37 } | |
| 38 function castButtonCoordinates(element, id) | |
| 39 { | |
| 40 var button = castButton(element); | |
| 41 var buttonBoundingRect = button.getBoundingClientRect(); | |
| 42 var x = buttonBoundingRect.left + buttonBoundingRect.width / 2; | |
| 43 var y = buttonBoundingRect.top + buttonBoundingRect.height / 2; | |
| 44 return new Array(x, y); | |
| 45 } | |
| 46 async_test(function(t) | |
| 47 { | |
| 48 findMediaElement(); | |
| 49 video.src = findMediaFile("video", "content/test"); | |
| 50 mediaElement.addEventListener("loadedmetadata", function() | |
| 51 { | |
| 52 // Pretend we have a cast device | |
| 53 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true)
; | |
| 54 | 13 |
| 55 // Video should not have a cast button since the video is too na
rrow | 14 video.onloadedmetadata = t.step_func_done(function() |
| 56 button = castButton(video); | 15 { |
| 57 assert_equals(button.style.display, "none", "button should not b
e visible with no cast devices"); | 16 // Pretend we have a cast device |
| 17 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true); |
| 58 | 18 |
| 59 // It should, however, have an overlay cast button instead | 19 // Video should not have a cast button since the video is too narrow |
| 60 button = overlayCastButton(video); | 20 var button = castButton(video); |
| 61 rect = button.getBoundingClientRect(); | 21 assert_equals(button.style.display, "none", "button should not be visibl
e with no cast devices"); |
| 62 videoRect = video.getBoundingClientRect(); | |
| 63 assert_greater_than_equal(rect.top, videoRect.top, "button shoul
d be at top left of video"); | |
| 64 assert_greater_than_equal(rect.left, videoRect.left, "button sho
uld be at top left of video"); | |
| 65 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.he
ight / 2, "button should be at top left of video"); | |
| 66 assert_less_than_equal(rect.right, videoRect.left + videoRect.wi
dth / 2, "button should be at top left of video"); | |
| 67 | 22 |
| 68 t.done(); | 23 // It should, however, have an overlay cast button instead |
| 69 }) | 24 button = overlayCastButton(video); |
| 70 }); | 25 var rect = button.getBoundingClientRect(); |
| 71 </script> | 26 var videoRect = video.getBoundingClientRect(); |
| 72 </body> | 27 assert_greater_than_equal(rect.top, videoRect.top, "button should be at
top left of video"); |
| 73 </html> | 28 assert_greater_than_equal(rect.left, videoRect.left, "button should be a
t top left of video"); |
| 29 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.height / 2
, "button should be at top left of video"); |
| 30 assert_less_than_equal(rect.right, videoRect.left + videoRect.width / 2,
"button should be at top left of video"); |
| 31 }); |
| 32 |
| 33 function castButton(element) |
| 34 { |
| 35 var controlID = "-internal-media-controls-cast-button"; |
| 36 var button = mediaControlsElement(internals.shadowRoot(element).firstChi
ld, controlID); |
| 37 if (!button) |
| 38 throw "Failed to find cast button"; |
| 39 return button; |
| 40 } |
| 41 |
| 42 function overlayCastButton(element) |
| 43 { |
| 44 var controlID = "-internal-media-controls-overlay-cast-button"; |
| 45 var button = mediaControlsElement(internals.shadowRoot(element).firstChi
ld, controlID); |
| 46 if (!button) |
| 47 throw "Failed to find cast button"; |
| 48 return button; |
| 49 } |
| 50 }); |
| 51 </script> |
| OLD | NEW |