Index: third_party/WebKit/LayoutTests/virtual/android/media/controls/overlay-play-button-narrow.html |
diff --git a/third_party/WebKit/LayoutTests/virtual/android/media/controls/overlay-play-button-narrow.html b/third_party/WebKit/LayoutTests/virtual/android/media/controls/overlay-play-button-narrow.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec3b6e26dbc0ebf5673ddc904e22a634415c6a3f |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/virtual/android/media/controls/overlay-play-button-narrow.html |
@@ -0,0 +1,76 @@ |
+<!DOCTYPE html> |
+<title>media controls overlay play button narrow</title> |
+<script src="../../../../resources/testharness.js"></script> |
+<script src="../../../../resources/testharnessreport.js"></script> |
+<script src="../../../../media/media-file.js"></script> |
+<script src="../../../../media/media-controls.js"></script> |
+<script> |
+async_test(function(t) { |
+ // Defined in core/html/shadow/MediaControls.cpp. |
+ var MIN_VIDEO_WIDTH = 48; |
+ var MIN_VIDEO_HEIGHT = 164; |
+ |
+ // Make sure the overlay play button is turned on, as it's typically off |
+ // unless we're dealing with Android. |
+ internals.settings.setMediaControlsOverlayPlayButtonEnabled(true); |
+ document.write('<video width="200" height="200" controls></video>'); |
+ var video = document.querySelector("video"); |
+ video.src = findMediaFile("video", "../../../../media/content/test"); |
+ |
+ video.onloadedmetadata = t.step_func(function() { |
+ // Large-enough video should have an overlay play button. |
+ assertOverlayPlayButtonVisible(); |
+ |
+ // If the width goes under the minimum, the button should be hidden. |
+ video.width = MIN_VIDEO_WIDTH - 10; |
+ testRunner.layoutAndPaintAsyncThen(t.step_func(function() { |
+ assertOverlayPlayButtonNotVisible(); |
+ |
+ // Re-widening the video should display the button. |
+ video.width = MIN_VIDEO_WIDTH; |
+ testRunner.layoutAndPaintAsyncThen(t.step_func(function() { |
+ assertOverlayPlayButtonVisible(); |
+ |
+ // If the height goes under the minimum, the button should be hidden. |
+ video.height = MIN_VIDEO_HEIGHT - 10; |
+ testRunner.layoutAndPaintAsyncThen(t.step_func(function() { |
+ assertOverlayPlayButtonNotVisible(); |
+ |
+ // Re-heightening the video should display the button. |
+ video.height = MIN_VIDEO_HEIGHT; |
+ testRunner.layoutAndPaintAsyncThen(t.step_func_done(function() { |
+ assertOverlayPlayButtonVisible(); |
+ })); |
+ })); |
+ })); |
+ })); |
+ }); |
+ |
+ function assertOverlayPlayButtonVisible() { |
+ assert_true(isVisible(overlayPlayButton(video)), |
+ "overlay play button should be visible"); |
+ } |
+ |
+ function assertOverlayPlayButtonNotVisible() { |
+ assert_false(isVisible(overlayPlayButton(video)), |
+ "overlay play button should not be visible"); |
+ } |
+ |
+ function overlayPlayButton(videoElement) { |
+ var controlID = '-webkit-media-controls-overlay-play-button'; |
+ var button = mediaControlsElement( |
+ window.internals.shadowRoot(videoElement).firstChild, |
+ controlID); |
+ if (!button) |
+ throw 'Failed to find overlay play button'; |
+ return button; |
+ } |
+ |
+ function isVisible(button) { |
+ var computedStyle = getComputedStyle(button); |
+ return computedStyle.display !== "none" && |
+ computedStyle.display !== "hidden" && |
+ computedStyle.visibility === "visible"; |
+ } |
+}); |
+</script> |