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