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

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

Issue 2016323003: Convert controls-cast-* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 4 years, 7 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
Index: third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html
diff --git a/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html b/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html
index dda2db056eec02108f544596c04cf6d12b41644f..6e3c9e9b37bfd3459b91a3cfabad9fe1d8bdc662 100644
--- a/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html
+++ b/third_party/WebKit/LayoutTests/media/controls-cast-button-narrow.html
@@ -1,73 +1,47 @@
-<!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>
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src="video-test.js"></script>
- </head>
- <body>
- <video width="100" height="200" 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";
- var button = mediaControlsElement(window.internals.shadowRoot(element).firstChild, controlID);
- if (!button)
- throw "Failed to find cast button";
- return button;
- }
- function castButtonDimensions(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()
- {
- // Pretend we have a cast device
- internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
+<!DOCTYPE html>
+<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>
+<video width="100" height="200" controls></video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ video.src = findMediaFile("video", "content/test");
- // 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");
+ video.onloadedmetadata = t.step_func_done(function() {
+ // Pretend we have a cast device
+ internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
- // 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");
- 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");
+ // Video should not have a cast button since the video is too narrow
+ var button = castButton(video);
+ assert_equals(button.style.display, "none", "button should not be visible with no cast devices");
- t.done();
- })
- });
- </script>
- </body>
-</html>
+ // It should, however, have an overlay cast button instead
+ button = overlayCastButton(video);
+ var rect = button.getBoundingClientRect();
+ var 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");
+ });
+
+ function castButton(element) {
+ var controlID = "-internal-media-controls-cast-button";
+ var button = mediaControlsElement(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";
+ var button = mediaControlsElement(internals.shadowRoot(element).firstChild, controlID);
+ if (!button)
+ throw "Failed to find cast button";
+ return button;
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698