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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/html/shadow/MediaControls.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>media controls cast button</title> 4 <title>media controls cast button</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script> 6 <script src="../resources/testharnessreport.js"></script>
7 <script src="media-file.js"></script> 7 <script src="media-file.js"></script>
8 <script src="media-controls.js"></script> 8 <script src="media-controls.js"></script>
9 <script src="video-test.js"></script> 9 <script src="video-test.js"></script>
10 </head> 10 </head>
11 <body> 11 <body>
12 <video></video> 12 <video width="100" controls></video>
13 <script> 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 }
14 function overlayCastButton(element) 22 function overlayCastButton(element)
15 { 23 {
16 var controlID = "-internal-media-controls-overlay-cast-button"; 24 var controlID = "-internal-media-controls-overlay-cast-button";
17 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID); 25 var button = mediaControlsElement(window.internals.shadowRoot(elemen t).firstChild, controlID);
18 if (!button) 26 if (!button)
19 throw "Failed to find cast button"; 27 throw "Failed to find cast button";
20 return button; 28 return button;
21 } 29 }
22 function overlayCastButtonDimensions(element) 30 function castButtonDimensions(element)
23 { 31 {
24 var button = overlayCastButton(element); 32 var button = castButton(element);
25 var buttonBoundingRect = button.getBoundingClientRect(); 33 var buttonBoundingRect = button.getBoundingClientRect();
26 return new Array(buttonBoundingRect.width, buttonBoundingRect.height ); 34 return new Array(buttonBoundingRect.width, buttonBoundingRect.height );
27 } 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 }
28 async_test(function(t) 44 async_test(function(t)
29 { 45 {
30 findMediaElement(); 46 findMediaElement();
31 video.src = findMediaFile("video", "content/test"); 47 video.src = findMediaFile("video", "content/test");
32 mediaElement.addEventListener("loadedmetadata", function() 48 mediaElement.addEventListener("loadedmetadata", function()
33 { 49 {
34 // Should not have a cast button by default
35 button = overlayCastButton(video);
36 assert_equals(button.style.display, "none", "button should not b e visible with no cast devices");
37
38 // Pretend we have a cast device 50 // Pretend we have a cast device
39 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true) ; 51 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true) ;
40 // Now should have cast button
41 assert_false(("display" in button.style) && (button.style.displa y == "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 52
46 // Check position, should be in the top left corner of the video 53 // Video should not have a cast button since the video is too na rrow
54 button = castButton(video);
55 assert_equals(button.style.display, "none", "button should not b e visible with no cast devices");
56
57 // It should, however, have an overlay cast button instead
58 button = overlayCastButton(video);
47 rect = button.getBoundingClientRect(); 59 rect = button.getBoundingClientRect();
48 videoRect = video.getBoundingClientRect(); 60 videoRect = video.getBoundingClientRect();
49 assert_greater_than_equal(rect.top, videoRect.top, "button shoul d be at top left of video"); 61 assert_greater_than_equal(rect.top, videoRect.top, "button shoul d be at top left of video");
50 assert_greater_than_equal(rect.left, videoRect.left, "button sho uld be at top left of video"); 62 assert_greater_than_equal(rect.left, videoRect.left, "button sho uld be at top left of video");
51 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.he ight / 2, "button should be at top left of video"); 63 assert_less_than_equal(rect.bottom, videoRect.top + videoRect.he ight / 2, "button should be at top left of video");
52 assert_less_than_equal(rect.right, videoRect.left + videoRect.wi dth / 2, "button should be at top left of video"); 64 assert_less_than_equal(rect.right, videoRect.left + videoRect.wi dth / 2, "button should be at top left of video");
53 65
54 // Remove cast device - cast button should go away
55 internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false );
56 assert_equals(button.style.display, "none", "button should not b e visible after cast device goes away");
57 t.done(); 66 t.done();
58 }) 67 })
59 }); 68 });
60 </script> 69 </script>
61 </body> 70 </body>
62 </html> 71 </html>
OLDNEW
« 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