Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: LayoutTests/media/controls-cast-button-narrow.html

Issue 658173002: Reposition cast button on narrow videos (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: trivial editorial change Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/html/shadow/MediaControls.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | Source/core/html/shadow/MediaControls.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698