Index: LayoutTests/media/controls-overlay-cast-button.html |
diff --git a/LayoutTests/media/controls-overlay-cast-button.html b/LayoutTests/media/controls-overlay-cast-button.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..460e6a0e152b2d9588c07ebe4bf388ee8b86c100 |
--- /dev/null |
+++ b/LayoutTests/media/controls-overlay-cast-button.html |
@@ -0,0 +1,48 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>media controls cast button</title> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ <script src="media-file.js"></script> |
+ <script src="media-controls.js"></script> |
+ <script src="video-test.js"></script> |
+ </head> |
+ <body> |
+ <video></video> |
+ <script> |
+ async_test(function(t) |
+ { |
+ findMediaElement(); |
+ video.src = findMediaFile("video", "content/test"); |
+ mediaElement.addEventListener("loadedmetadata", function() |
+ { |
+ // Should not have a cast button by default |
+ button = mediaControlsButton(video, "overlay-cast-button"); |
+ 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 = mediaControlsButtonDimensions(video, "overlay-cast-button"); |
+ 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 |
+ rect = button.getBoundingClientRect(); |
+ videoRect = video.getBoundingClientRect(); |
+ assert_greater_than_equal(rect.top, videoRect.top, "button should be at top left of video"); |
+ assert_greater_than_equal(rect.left, videoRect.left, "button should be at top left of video"); |
+ 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> |