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

Unified Diff: third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html

Issue 2121613002: Convert video-controls-[captions, overlay, track]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address philip's comments Created 4 years, 5 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: third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html
diff --git a/third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html b/third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html
index 63f3378bf605e34266fb91c698dd345807a9977b..cb83a24de5a7411b40428f5d4dfa9ed679cce2b6 100644
--- a/third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html
+++ b/third_party/WebKit/LayoutTests/media/video-controls-overlay-play-button.html
@@ -1,82 +1,62 @@
-<!doctype html>
-<html>
- <head>
- <title>Test that the overlay play button respects the controls attribute</title>
- <script src="media-controls.js"></script>
- <script src="media-file.js"></script>
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src="video-test.js"></script>
- <script>
- function start()
- {
- window.internals.settings.setMediaControlsOverlayPlayButtonEnabled(true);
-
- // Add element dynamically, since otherwise the controls are created, but
- // hidden, before the setting is set, causing the setting to be ignored.
- addVideoElement();
-
- findMediaElement();
-
- video.controls = true;
-
- button = mediaControlsButton(video, 'overlay-play-button')
- testExpected('getComputedStyle(button).display', 'flex');
-
- waitForEventOnce('loadeddata', loadeddata);
- video.src = findMediaFile('video', 'content/test');
- }
-
- function addVideoElement() {
- element = document.createElement('video');
- document.body.appendChild(element);
- }
-
- function loadeddata()
- {
- waitForEventOnce('play', play1);
- run('video.play()');
- }
-
- function play1()
- {
- testExpected('getComputedStyle(button).display', 'none');
-
- waitForEventOnce('pause', pause1);
- run('video.pause()');
- }
-
- function pause1()
- {
- testExpected('getComputedStyle(button).display', 'flex');
-
- video.controls = false;
- testExpected('getComputedStyle(button).display', 'none');
-
- waitForEventOnce('play', play2);
- run('video.play()');
- }
-
- function play2()
- {
- testExpected('getComputedStyle(button).display', 'none');
-
- waitForEventOnce('pause', pause2);
- run('video.pause()');
- }
-
- function pause2()
- {
- testExpected('getComputedStyle(button).display', 'none');
-
- video.controls = true;
- testExpected('getComputedStyle(button).display', 'flex');
-
- endTest();
- }
- </script>
- </head>
- <body onload="start()">
- <p>Test that the overlay play button respects the controls attribute</p>
- </body>
-</html>
+<!DOCTYPE html>
+<title>Test that the overlay play button respects the controls attribute.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<script src="media-controls.js"></script>
+<script>
+async_test(function(t) {
+ internals.settings.setMediaControlsOverlayPlayButtonEnabled(true);
+
+ // Add video dynamically, since otherwise the controls are created, but
+ // hidden, before the setting is set, causing the setting to be ignored.
+ var video = document.createElement("video");
+ document.documentElement.appendChild(video);
foolip 2016/07/06 10:00:47 That's a weird place to have the video element, ca
Srirama 2016/07/06 11:35:49 To append to body, we need a body tag in the test,
+
+ video.controls = true;
+ var button = mediaControlsButton(video, "overlay-play-button")
+ assert_equals(getComputedStyle(button).display, "flex");
+
+ video.onloadeddata = t.step_func(function() {
+ video.onloadeddata = null;
foolip 2016/07/06 10:00:47 The structure of this test is honestly quite hard
Srirama 2016/07/06 10:53:18 I'm afraid i understood how we can apply eventwatc
foolip 2016/07/06 11:09:18 I haven't done it myself, but https://github.com/w
fs 2016/07/06 11:11:52 I think the mechanism for that is something like:
Srirama 2016/07/06 11:35:49 Done. Thanks @both for the info.
+
+ video.onplay = t.step_func(function() {
+ play(pause1);
+ });
+
+ video.play();
+ });
+
+ function play(pauseFunction) {
+ video.onplay = null;
+ assert_equals(getComputedStyle(button).display, "none");
+
+ video.onpause = t.step_func(pauseFunction);
+ video.pause();
+ }
+
+ function pause1() {
+ video.onpause = null;
+ assert_equals(getComputedStyle(button).display, "flex");
+
+ video.controls = false;
+ assert_equals(getComputedStyle(button).display, "none");
+
+ video.onplay = t.step_func_done(function() {
+ play(pause2);
+ });
+
+ video.play();
+ }
+
+ function pause2() {
+ video.onpause = null;
+ assert_equals(getComputedStyle(button).display, "none");
+
+ video.controls = true;
+ assert_equals(getComputedStyle(button).display, "flex");
+ }
+
+ video.src = findMediaFile("video", "content/test");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698