Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / media / controls-overlay-cast-button.html
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></video>
13         <script>
14         function overlayCastButton(element)
15         {
16             var controlID = "-internal-media-controls-overlay-cast-button";
17             var button = mediaControlsElement(window.internals.shadowRoot(element).firstChild, controlID);
18             if (!button)
19                 throw "Failed to find cast button";
20             return button;
21         }
22         function overlayCastButtonDimensions(element)
23         {
24             var button = overlayCastButton(element);
25             var buttonBoundingRect = button.getBoundingClientRect();
26             return new Array(buttonBoundingRect.width, buttonBoundingRect.height);
27         }
28         async_test(function(t) 
29         {
30             findMediaElement();
31             video.src = findMediaFile("video", "content/test");
32             mediaElement.addEventListener("loadedmetadata", function()
33             {
34                 // Should not have a cast button by default
35                 button = overlayCastButton(video);
36                 assert_equals(button.style.display, "none", "button should not be visible with no cast devices");
37
38                 // Pretend we have a cast device
39                 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);
40                 // Now should have cast button
41                 assert_false(("display" in button.style) && (button.style.display == "none"), "button should exist");
42                 dimensions = overlayCastButtonDimensions(video);
43                 assert_not_equals(dimensions[0], 0, "button should exist");
44                 assert_not_equals(dimensions[1], 0, "button should exist");
45
46                 // Check position, should be in the top left corner of the video
47                 rect = button.getBoundingClientRect();
48                 videoRect = video.getBoundingClientRect();
49                 assert_greater_than_equal(rect.top, videoRect.top, "button should be at top left of video");
50                 assert_greater_than_equal(rect.left, videoRect.left, "button should be at top left of video");
51                 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.height / 2, "button should be at top left of video");
52                 assert_less_than_equal(rect.right, videoRect.left + videoRect.width / 2, "button should be at top left of video");
53
54                 // Remove cast device - cast button should go away
55                 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false);
56                 assert_equals(button.style.display, "none", "button should not be visible after cast device goes away");
57                 t.done();
58             })
59         });
60         </script>
61     </body>
62 </html>