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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/media/media-controls.js
diff --git a/LayoutTests/media/media-controls.js b/LayoutTests/media/media-controls.js
index 30da5ba7c7f3eaff3f03266baf70c73687df2b4d..6a3c87d10ca7b5c0c72935edd613c9256cd0d98d 100644
--- a/LayoutTests/media/media-controls.js
+++ b/LayoutTests/media/media-controls.js
@@ -1,6 +1,16 @@
var captionsButtonElement;
var captionsButtonCoordinates;
+// These reflect the values used to fade in/out the media controls. Should
+// mirror the values 'fadeInDuration'/'fadeOutDuration' in MediaControlElements.cpp.
+const controlsFadeInDurationMs = 100;
+const controlsFadeOutDurationMs = 300;
+
+// The timeout for the hide-after-no-mouse-movement behavior. Defined (and
+// should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls'
+// in MediaControls.cpp.
+const controlsMouseMovementTimeoutMs = 3000;
+
function mediaControlsElement(first, id)
{
for (var element = first; element; element = element.nextSibling) {
@@ -109,3 +119,19 @@ function clickCCButton()
eventSender.mouseDown();
eventSender.mouseUp();
}
+
+function runAfterControlsHidden(func, mediaElement)
+{
+ if (mediaElement.paused)
+ throw "The media element is not playing";
+
+ // Compute the time it'll take until the controls will be invisible -
+ // assuming playback has been started prior to invoking this
+ // function. Allow 500ms slack.
+ var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDurationMs + 500;
+
+ if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - mediaElement.currentTime))
+ throw "The media will end before the controls have been hidden";
+
+ setTimeout(func, hideTimeoutMs);
+}

Powered by Google App Engine
This is Rietveld 408576698