| Index: LayoutTests/media/controls-cast-button-narrow.html
|
| diff --git a/LayoutTests/media/controls-overlay-cast-button.html b/LayoutTests/media/controls-cast-button-narrow.html
|
| similarity index 66%
|
| copy from LayoutTests/media/controls-overlay-cast-button.html
|
| copy to LayoutTests/media/controls-cast-button-narrow.html
|
| index 32719d6c42c633426cc4437226b8aaf7786457bb..e5a2a912969b215f1a8583eff5bf20a909e87843 100644
|
| --- a/LayoutTests/media/controls-overlay-cast-button.html
|
| +++ b/LayoutTests/media/controls-cast-button-narrow.html
|
| @@ -9,8 +9,16 @@
|
| <script src="video-test.js"></script>
|
| </head>
|
| <body>
|
| - <video></video>
|
| + <video width="100" controls></video>
|
| <script>
|
| + function castButton(element)
|
| + {
|
| + var controlID = "-internal-media-controls-cast-button";
|
| + var button = mediaControlsElement(window.internals.shadowRoot(element).firstChild, controlID);
|
| + if (!button)
|
| + throw "Failed to find cast button";
|
| + return button;
|
| + }
|
| function overlayCastButton(element)
|
| {
|
| var controlID = "-internal-media-controls-overlay-cast-button";
|
| @@ -19,31 +27,35 @@
|
| throw "Failed to find cast button";
|
| return button;
|
| }
|
| - function overlayCastButtonDimensions(element)
|
| + function castButtonDimensions(element)
|
| {
|
| - var button = overlayCastButton(element);
|
| + var button = castButton(element);
|
| var buttonBoundingRect = button.getBoundingClientRect();
|
| return new Array(buttonBoundingRect.width, buttonBoundingRect.height);
|
| }
|
| + function castButtonCoordinates(element, id)
|
| + {
|
| + var button = castButton(element);
|
| + var buttonBoundingRect = button.getBoundingClientRect();
|
| + var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
|
| + var y = buttonBoundingRect.top + buttonBoundingRect.height / 2;
|
| + return new Array(x, y);
|
| + }
|
| async_test(function(t)
|
| {
|
| findMediaElement();
|
| video.src = findMediaFile("video", "content/test");
|
| mediaElement.addEventListener("loadedmetadata", function()
|
| {
|
| - // Should not have a cast button by default
|
| - button = overlayCastButton(video);
|
| - assert_equals(button.style.display, "none", "button should not be visible with no cast devices");
|
| -
|
| // Pretend we have a cast device
|
| internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
|
| - // Now should have cast button
|
| - assert_false(("display" in button.style) && (button.style.display == "none"), "button should exist");
|
| - dimensions = overlayCastButtonDimensions(video);
|
| - assert_not_equals(dimensions[0], 0, "button should exist");
|
| - assert_not_equals(dimensions[1], 0, "button should exist");
|
|
|
| - // Check position, should be in the top left corner of the video
|
| + // Video should not have a cast button since the video is too narrow
|
| + button = castButton(video);
|
| + assert_equals(button.style.display, "none", "button should not be visible with no cast devices");
|
| +
|
| + // It should, however, have an overlay cast button instead
|
| + button = overlayCastButton(video);
|
| rect = button.getBoundingClientRect();
|
| videoRect = video.getBoundingClientRect();
|
| assert_greater_than_equal(rect.top, videoRect.top, "button should be at top left of video");
|
| @@ -51,12 +63,9 @@
|
| assert_less_than_equal(rect.bottom, videoRect.top + videoRect.height / 2, "button should be at top left of video");
|
| assert_less_than_equal(rect.right, videoRect.left + videoRect.width / 2, "button should be at top left of video");
|
|
|
| - // Remove cast device - cast button should go away
|
| - internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false);
|
| - assert_equals(button.style.display, "none", "button should not be visible after cast device goes away");
|
| t.done();
|
| })
|
| });
|
| </script>
|
| </body>
|
| -</html>
|
| +</html>
|
|
|