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

Side by Side Diff: LayoutTests/media/media-controls.js

Issue 302603003: Cleanup tests related to controls hiding/fading in/out (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tweaks. Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 var captionsButtonElement; 1 var captionsButtonElement;
2 var captionsButtonCoordinates; 2 var captionsButtonCoordinates;
3 3
4 // These reflect the values used to fade in/out the media controls. Should
5 // mirror the values 'fadeInDuration'/'fadeOutDuration' in MediaControlElements. cpp.
6 const controlsFadeInDurationMs = 100;
7 const controlsFadeOutDurationMs = 300;
8
9 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and
10 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls'
11 // in MediaControls.cpp.
12 const controlsMouseMovementTimeoutMs = 3000;
13
4 function mediaControlsElement(first, id) 14 function mediaControlsElement(first, id)
5 { 15 {
6 for (var element = first; element; element = element.nextSibling) { 16 for (var element = first; element; element = element.nextSibling) {
7 // Not every element in the media controls has a shadow pseudo ID, eg. t he 17 // Not every element in the media controls has a shadow pseudo ID, eg. t he
8 // text nodes for the time values, so guard against exceptions. 18 // text nodes for the time values, so guard against exceptions.
9 try { 19 try {
10 if (internals.shadowPseudoId(element) == id) 20 if (internals.shadowPseudoId(element) == id)
11 return element; 21 return element;
12 } catch (exception) { } 22 } catch (exception) { }
13 23
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 112 }
103 } 113 }
104 114
105 function clickCCButton() 115 function clickCCButton()
106 { 116 {
107 consoleWrite("*** Click the CC button."); 117 consoleWrite("*** Click the CC button.");
108 eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordina tes[1]); 118 eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordina tes[1]);
109 eventSender.mouseDown(); 119 eventSender.mouseDown();
110 eventSender.mouseUp(); 120 eventSender.mouseUp();
111 } 121 }
122
123 function runAfterControlsHidden(func, mediaElement)
124 {
125 if (mediaElement.paused)
126 throw "The media element is not playing";
127
128 // Compute the time it'll take until the controls will be invisible -
129 // assuming playback has been started prior to invoking this
130 // function. Allow 500ms slack.
131 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration Ms + 500;
132
133 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m ediaElement.currentTime))
134 throw "The media will end before the controls have been hidden";
135
136 setTimeout(func, hideTimeoutMs);
137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698