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

Side by Side 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, 6 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test that dragging the timebar thumb causes seeks.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <title>drag timebar test</title> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src=media-controls.js></script> 5 <script src="media-file.js"></script>
6 <script src=media-file.js></script> 6 <script src="media-controls.js"></script>
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 7 <video controls></video>
8 (Please avoid writing new tests using video-test.js) --> 8 <script>
9 <script src=video-test.js></script> 9 async_test(function(t) {
10 <script> 10 var currentMousePosition = {
foolip 2016/05/30 13:33:27 Any reason to group these into an object? fooPosit
11 var x; 11 seekPosition: [],
foolip 2016/05/30 13:33:27 Suggest null as the initial value. This empty arra
12 var y; 12 seekCount: 0,
13 var seekCount; 13 moveCount: 0
14 var moveCount; 14 };
15 15
16 if (window.testRunner) 16 var video = document.querySelector("video");
17 testRunner.dumpAsText(); 17 video.onplaying = t.step_func(test);
18 video.onseeked = t.step_func(seeked);
19 video.src = findMediaFile("video", "content/test");
20 video.play();
18 21
19 function test() 22 function test() {
foolip 2016/05/30 13:33:28 Suggest renaming this to playing, calling it test
Srirama 2016/05/30 13:59:22 Done.
20 { 23 video.onplaying = null;
21 seekCount = 0; 24 assert_equals(video.paused, false);
22 moveCount = 0;
23 25
24 testExpected("video.paused", false); 26 currentMousePosition.seekPosition = mediaControlsButtonCoordinates(video , "timeline");
25 27
26 if (window.eventSender) { 28 eventSender.dragMode = false;
27 var seekCoords; 29 eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMou sePosition.seekPosition[1]);
28 try { 30 eventSender.mouseDown();
29 seekCoords = mediaControlsButtonCoordinates(video, "time line");
30 } catch (exception) {
31 failTest(exception.description);
32 return;
33 }
34 x = seekCoords[0];
35 y = seekCoords[1];
36 31
37 eventSender.dragMode = false; 32 assert_equals(video.paused, true);
38 eventSender.mouseMoveTo(x, y);
39 eventSender.mouseDown();
40 33
41 testExpected("video.paused", true); 34 // Drag mouse off of the slider thumb to make sure it continues to track
35 currentMousePosition.seekPosition[1] += 100;
36 eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMou sePosition.seekPosition[1]);
42 37
43 // Drag mouse off of the slider thumb to make sure it contin ues to track 38 setTimeout(t.step_func(move), 100);
44 y += 100; 39 }
45 eventSender.mouseMoveTo(x, y);
46 }
47 window.setTimeout("move()", 100);
48 }
49 40
50 function move() 41 function move() {
51 { 42 ++(currentMousePosition.moveCount);
foolip 2016/05/30 13:33:27 Looks funny, can you use currentMousePosition.move
52 ++moveCount;
53 43
54 var delta = (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1); 44 currentMousePosition.seekPosition[0] += (10 + currentMousePosition.moveC ount * 2)
45 * (currentMousePosition.moveCount % 2 ? 1 : -1);
46 eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMou sePosition.seekPosition[1]);
47 }
55 48
56 if (window.eventSender) { 49 function seeked() {
57 x += delta; 50 ++(currentMousePosition.seekCount);
58 eventSender.mouseMoveTo(x, y); 51 if (currentMousePosition.seekCount < 6) {
59 } 52 setTimeout(t.step_func(move), 100);
60 } 53 return;
54 }
61 55
62 function seeked() 56 assert_equals(video.paused, true);
63 { 57 eventSender.mouseUp();
64 58
65 ++seekCount; 59 assert_equals(video.paused, false);
66 if (seekCount < 6) { 60 t.done();
67 window.setTimeout("move()", 100); 61 }
68 return; 62 });
69 } 63 </script>
70
71 if (window.eventSender) {
72 testExpected("video.paused", true);
73 eventSender.mouseUp();
74 }
75
76 testExpected("video.paused", false);
77
78 endTest();
79 }
80
81 function start()
82 {
83 findMediaElement();
84 waitForEventOnce('playing', test);
85 waitForEvent('seeked', seeked);
86 video.src = findMediaFile("video", "content/test");
87 video.play();
88 }
89 </script>
90 </head>
91
92 <body onload="start()">
93 <p>Test that dragging the timebar thumb causes seeks.</p>
94 <video controls></video>
95 </body>
96 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698