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

Unified Diff: third_party/WebKit/LayoutTests/media/controls-drag-timebar.html

Issue 2020893002: Convert controls-css*, controls-drag* and controls-overlay* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 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: third_party/WebKit/LayoutTests/media/controls-drag-timebar.html
diff --git a/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html b/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html
index 2b58e979ba9a84c7b416d0c7bf411254a6a1e2c6..33ca8a603c289837c6bbf09a61db78a77fd3a14a 100644
--- a/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html
+++ b/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html
@@ -1,96 +1,65 @@
<!DOCTYPE html>
-<html>
- <head>
- <title>drag timebar test</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>
- var x;
- var y;
- var seekCount;
- var moveCount;
-
- if (window.testRunner)
- testRunner.dumpAsText();
-
- function test()
- {
- seekCount = 0;
- moveCount = 0;
-
- testExpected("video.paused", false);
-
- if (window.eventSender) {
- var seekCoords;
- try {
- seekCoords = mediaControlsButtonCoordinates(video, "timeline");
- } catch (exception) {
- failTest(exception.description);
- return;
- }
- x = seekCoords[0];
- y = seekCoords[1];
-
- eventSender.dragMode = false;
- eventSender.mouseMoveTo(x, y);
- eventSender.mouseDown();
-
- testExpected("video.paused", true);
-
- // Drag mouse off of the slider thumb to make sure it continues to track
- y += 100;
- eventSender.mouseMoveTo(x, y);
- }
- window.setTimeout("move()", 100);
- }
-
- function move()
- {
- ++moveCount;
-
- var delta = (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1);
-
- if (window.eventSender) {
- x += delta;
- eventSender.mouseMoveTo(x, y);
- }
- }
-
- function seeked()
- {
-
- ++seekCount;
- if (seekCount < 6) {
- window.setTimeout("move()", 100);
- return;
- }
-
- if (window.eventSender) {
- testExpected("video.paused", true);
- eventSender.mouseUp();
- }
-
- testExpected("video.paused", false);
-
- endTest();
- }
-
- function start()
- {
- findMediaElement();
- waitForEventOnce('playing', test);
- waitForEvent('seeked', seeked);
- video.src = findMediaFile("video", "content/test");
- video.play();
- }
- </script>
- </head>
-
- <body onload="start()">
- <p>Test that dragging the timebar thumb causes seeks.</p>
- <video controls></video>
- </body>
-</html>
+<title>Test that dragging the timebar thumb causes seeks.</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>
+<video controls></video>
+<script>
+async_test(function(t) {
+ var currentMousePosition = { x: 0, y: 0 };
+ var seekCount;
+ var moveCount;
+
+ var video = document.querySelector("video");
+ video.onplaying = t.step_func(playing);
+ video.onseeked = t.step_func(seeked);
+ video.src = findMediaFile("video", "content/test");
+ video.play();
+
+ function playing() {
+ video.onplaying = null;
+ seekCount = 0;
+ moveCount = 0;
+
+ assert_equals(video.paused, false);
+
+ var seekCoords = mediaControlsButtonCoordinates(video, "timeline");
+ currentMousePosition.x = seekCoords[0];
+ currentMousePosition.y = seekCoords[1];
+
+ eventSender.dragMode = false;
+ eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y);
+ eventSender.mouseDown();
+
+ assert_equals(video.paused, true);
+
+ // Drag mouse off of the slider thumb to make sure it continues to track
+ currentMousePosition.y += 100;
+ eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y);
+
+ setTimeout(t.step_func(move), 100);
+ }
+
+ function move() {
+ ++moveCount;
+
+ currentMousePosition.x += (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1);
+ eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y);
+ }
+
+ function seeked() {
+ ++seekCount;
+ if (seekCount < 6) {
+ setTimeout(t.step_func(move), 100);
+ return;
+ }
+
+ assert_equals(video.paused, true);
+ eventSender.mouseUp();
+
+ assert_equals(video.paused, false);
+ t.done();
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698