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 controls width=500></video> | 14 <video controls width=500></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 // Should not have a cast button by default | 52 // Should not have a cast button by default |
51 button = castButton(video); | 53 button = castButton(video); |
52 assert_equals(button.style.display, "none", "button should not b
e visible with no cast devices"); | 54 assert_equals(button.style.display, "none", "button should not b
e visible with no cast devices"); |
53 | 55 |
54 // Pretend we have a cast device | 56 // Pretend we have a cast device |
55 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true)
; | 57 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true)
; |
56 | 58 |
57 // Now should have cast button | 59 // Now should have cast button |
58 assert_false(("display" in button.style) && (button.style.displa
y == "none"), "button should exist"); | 60 assert_false(("display" in button.style) && (button.style.displa
y == "none"), "button should exist"); |
59 dimensions = castButtonDimensions(video); | 61 dimensions = castButtonDimensions(video); |
60 assert_not_equals(dimensions[0], 0, "button should exist"); | 62 assert_not_equals(dimensions[0], 0, "button should exist"); |
61 assert_not_equals(dimensions[1], 0, "button should exist"); | 63 assert_not_equals(dimensions[1], 0, "button should exist"); |
62 | 64 |
63 // Check its position is to the right of the timeline | 65 // Check its position is to the right of the timeline |
64 // (can't test against volume control or closed caption button,
since these don't always exist) | 66 // (can't test against volume control or closed caption button,
since these don't always exist) |
65 position = castButtonCoordinates(video); | 67 position = castButtonCoordinates(video); |
66 timelinePosition = mediaControlsButtonCoordinates(video, "timeli
ne"); | 68 timelinePosition = mediaControlsButtonCoordinates(video, "timeli
ne"); |
67 assert_greater_than(position[0], timelinePosition[0], "button sh
ould be to right of timeline"); | 69 assert_greater_than(position[0], timelinePosition[0], "button sh
ould be to right of timeline"); |
68 | 70 |
69 // Check that we don't have an overlay cast button | 71 // Check that we don't have an overlay cast button |
70 overlayButton = overlayCastButton(video); | 72 overlayButton = overlayCastButton(video); |
71 assert_equals(overlayButton.style.display, "none", "Overlay butt
on should not be visible with controls"); | 73 assert_equals(overlayButton.style.display, "none", "Overlay butt
on should not be visible with controls"); |
72 | 74 |
73 // And to the left of the fullscreen button | 75 // And to the left of the fullscreen button |
74 fullscreenPosition = mediaControlsButtonCoordinates(video, "full
screen-button"); | 76 fullscreenPosition = mediaControlsButtonCoordinates(video, "full
screen-button"); |
75 assert_less_than(position[0], fullscreenPosition[0], "button sho
uld be to left of fullscreen button"); | 77 assert_less_than(position[0], fullscreenPosition[0], "button sho
uld be to left of fullscreen button"); |
76 | 78 |
77 // Remove cast device - cast button should go away | 79 // Remove cast device - cast button should go away |
78 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false
); | 80 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false
); |
79 assert_equals(button.style.display, "none", "button should not b
e visible after cast device goes away"); | 81 assert_equals(button.style.display, "none", "button should not b
e visible after cast device goes away"); |
80 t.done(); | 82 t.done(); |
81 }); | 83 }); |
82 }); | 84 }); |
83 </script> | 85 </script> |
84 </body> | 86 </body> |
85 </html> | 87 </html> |
OLD | NEW |