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

Side by Side Diff: LayoutTests/media/controls-cast-button.html

Issue 291163004: Implement media cast buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to fix merge problem with TestExpectations Created 6 years, 3 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
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>media controls cast button</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="media-file.js"></script>
8 <script src="media-controls.js"></script>
9 <script src="video-test.js"></script>
10 </head>
11 <body>
12 <video controls></video>
13 <script>
14 function castButton(element)
15 {
16 var controlID = "-internal-media-controls-cast-button";
17 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID);
18 if (!button)
19 throw "Failed to find cast button";
20 return button;
21 }
22 function overlayCastButton(element)
23 {
24 var controlID = "-internal-media-controls-overlay-cast-button";
25 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID);
26 if (!button)
27 throw "Failed to find cast button";
28 return button;
29 }
30 function castButtonDimensions(element)
31 {
32 var button = castButton(element);
33 var buttonBoundingRect = button.getBoundingClientRect();
34 return new Array(buttonBoundingRect.width, buttonBoundingRect.height );
35 }
36 function castButtonCoordinates(element, id)
37 {
38 var button = castButton(element);
39 var buttonBoundingRect = button.getBoundingClientRect();
40 var x = buttonBoundingRect.left + buttonBoundingRect.width / 2;
41 var y = buttonBoundingRect.top + buttonBoundingRect.height / 2;
42 return new Array(x, y);
43 }
44 async_test(function(t)
45 {
46 findMediaElement();
47 video.src = findMediaFile("video", "content/test");
48 mediaElement.addEventListener("loadedmetadata", function()
49 {
50 // Should not have a cast button by default
51 button = castButton(video);
52 assert_equals(button.style.display, "none", "button should not b e visible with no cast devices");
53
54 // Pretend we have a cast device
55 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true) ;
56
57 // Now should have cast button
58 assert_false(("display" in button.style) && (button.style.displa y == "none"), "button should exist");
59 dimensions = castButtonDimensions(video);
60 assert_not_equals(dimensions[0], 0, "button should exist");
61 assert_not_equals(dimensions[1], 0, "button should exist");
62
63 // Check its position is to the right of the timeline
64 // (can't test against volume control or closed caption button, since these don't always exist)
65 position = castButtonCoordinates(video);
66 timelinePosition = mediaControlsButtonCoordinates(video, "timeli ne");
67 assert_greater_than(position[0], timelinePosition[0], "button sh ould be to right of timeline");
68
69 // Check that we don't have an overlay cast button
70 overlayButton = overlayCastButton(video);
71 assert_equals(overlayButton.style.display, "none", "Overlay butt on should not be visible with controls");
72
73 // And to the left of the fullscreen button
74 fullscreenPosition = mediaControlsButtonCoordinates(video, "full screen-button");
75 assert_less_than(position[0], fullscreenPosition[0], "button sho uld be to left of fullscreen button");
76
77 // Remove cast device - cast button should go away
78 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false );
79 assert_equals(button.style.display, "none", "button should not b e visible after cast device goes away");
80 t.done();
81 });
82 });
83 </script>
84 </body>
85 </html>
86
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698