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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!DOCTYPE html>
2 <html> 2 <title>media controls cast button</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <title>media controls cast button</title> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="../resources/testharness.js"></script> 5 <script src="media-file.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="media-controls.js"></script>
7 <script src="media-file.js"></script> 7 <video width="100" height="200" controls></video>
8 <script src="media-controls.js"></script> 8 <script>
9 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 9 async_test(function(t) {
10 (Please avoid writing new tests using video-test.js) --> 10 var video = document.querySelector("video");
11 <script src="video-test.js"></script> 11 video.src = findMediaFile("video", "content/test");
12 </head>
13 <body>
14 <video width="100" height="200" controls></video>
15 <script>
16 function castButton(element)
17 {
18 var controlID = "-internal-media-controls-cast-button";
19 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID);
20 if (!button)
21 throw "Failed to find cast button";
22 return button;
23 }
24 function overlayCastButton(element)
25 {
26 var controlID = "-internal-media-controls-overlay-cast-button";
27 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID);
28 if (!button)
29 throw "Failed to find cast button";
30 return button;
31 }
32 function castButtonDimensions(element)
33 {
34 var button = castButton(element);
35 var buttonBoundingRect = button.getBoundingClientRect();
36 return new Array(buttonBoundingRect.width, buttonBoundingRect.height );
37 }
38 function castButtonCoordinates(element, id)
39 {
40 var button = castButton(element);
41 var buttonBoundingRect = button.getBoundingClientRect();
42 var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
43 var y = buttonBoundingRect.top + buttonBoundingRect.height / 2;
44 return new Array(x, y);
45 }
46 async_test(function(t)
47 {
48 findMediaElement();
49 video.src = findMediaFile("video", "content/test");
50 mediaElement.addEventListener("loadedmetadata", function()
51 {
52 // Pretend we have a cast device
53 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true) ;
54 12
55 // Video should not have a cast button since the video is too na rrow 13 video.onloadedmetadata = t.step_func_done(function() {
56 button = castButton(video); 14 // Pretend we have a cast device
57 assert_equals(button.style.display, "none", "button should not b e visible with no cast devices"); 15 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
58 16
59 // It should, however, have an overlay cast button instead 17 // Video should not have a cast button since the video is too narrow
60 button = overlayCastButton(video); 18 var button = castButton(video);
61 rect = button.getBoundingClientRect(); 19 assert_equals(button.style.display, "none", "button should not be visibl e with no cast devices");
62 videoRect = video.getBoundingClientRect();
63 assert_greater_than_equal(rect.top, videoRect.top, "button shoul d be at top left of video");
64 assert_greater_than_equal(rect.left, videoRect.left, "button sho uld be at top left of video");
65 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.he ight / 2, "button should be at top left of video");
66 assert_less_than_equal(rect.right, videoRect.left + videoRect.wi dth / 2, "button should be at top left of video");
67 20
68 t.done(); 21 // It should, however, have an overlay cast button instead
69 }) 22 button = overlayCastButton(video);
70 }); 23 var rect = button.getBoundingClientRect();
71 </script> 24 var videoRect = video.getBoundingClientRect();
72 </body> 25 assert_greater_than_equal(rect.top, videoRect.top, "button should be at top left of video");
73 </html> 26 assert_greater_than_equal(rect.left, videoRect.left, "button should be a t top left of video");
27 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.height / 2 , "button should be at top left of video");
28 assert_less_than_equal(rect.right, videoRect.left + videoRect.width / 2, "button should be at top left of video");
29 });
30
31 function castButton(element) {
32 var controlID = "-internal-media-controls-cast-button";
33 var button = mediaControlsElement(internals.shadowRoot(element).firstChi ld, controlID);
34 if (!button)
35 throw "Failed to find cast button";
36 return button;
37 }
38
39 function overlayCastButton(element) {
40 var controlID = "-internal-media-controls-overlay-cast-button";
41 var button = mediaControlsElement(internals.shadowRoot(element).firstChi ld, controlID);
42 if (!button)
43 throw "Failed to find cast button";
44 return button;
45 }
46 });
47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698