OLD | NEW |
---|---|
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 x; |
fs
2016/05/29 14:28:17
Maybe group these and call them "currentMousePosit
Srirama
2016/05/30 13:19:19
Done. Is this what you are expecting, or did i mes
foolip
2016/05/30 13:34:14
Oh, you talked about this :) Wait for fs to commen
fs
2016/05/30 13:37:22
I was thinking of 'x' and 'y' only, like:
var cur
Srirama
2016/05/30 13:59:22
Done, assuming that you still want this change.
| |
11 var x; | 11 var y; |
12 var y; | 12 var seekCount; |
13 var seekCount; | 13 var moveCount; |
14 var moveCount; | |
15 | 14 |
16 if (window.testRunner) | 15 var video = document.querySelector("video"); |
17 testRunner.dumpAsText(); | 16 video.onplaying = t.step_func(test); |
17 video.onseeked = t.step_func(seeked); | |
18 video.src = findMediaFile("video", "content/test"); | |
19 video.play(); | |
18 | 20 |
19 function test() | 21 function test() { |
20 { | 22 video.onplaying = null; |
21 seekCount = 0; | 23 seekCount = 0; |
22 moveCount = 0; | 24 moveCount = 0; |
23 | 25 |
24 testExpected("video.paused", false); | 26 assert_equals(video.paused, false); |
25 | 27 |
26 if (window.eventSender) { | 28 var seekCoords = mediaControlsButtonCoordinates(video, "timeline"); |
27 var seekCoords; | 29 x = seekCoords[0]; |
28 try { | 30 y = seekCoords[1]; |
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 eventSender.dragMode = false; |
38 eventSender.mouseMoveTo(x, y); | 33 eventSender.mouseMoveTo(x, y); |
39 eventSender.mouseDown(); | 34 eventSender.mouseDown(); |
40 | 35 |
41 testExpected("video.paused", true); | 36 assert_equals(video.paused, true); |
42 | 37 |
43 // Drag mouse off of the slider thumb to make sure it contin ues to track | 38 // Drag mouse off of the slider thumb to make sure it continues to track |
44 y += 100; | 39 y += 100; |
45 eventSender.mouseMoveTo(x, y); | 40 eventSender.mouseMoveTo(x, y); |
46 } | |
47 window.setTimeout("move()", 100); | |
48 } | |
49 | 41 |
50 function move() | 42 setTimeout(t.step_func(move), 100); |
51 { | 43 } |
52 ++moveCount; | |
53 | 44 |
54 var delta = (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1); | 45 function move() { |
46 ++moveCount; | |
55 | 47 |
56 if (window.eventSender) { | 48 x += (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1); |
57 x += delta; | 49 eventSender.mouseMoveTo(x, y); |
58 eventSender.mouseMoveTo(x, y); | 50 } |
59 } | |
60 } | |
61 | 51 |
62 function seeked() | 52 function seeked() { |
63 { | 53 ++seekCount; |
54 if (seekCount < 6) { | |
55 setTimeout(t.step_func(move), 100); | |
56 return; | |
57 } | |
64 | 58 |
65 ++seekCount; | 59 assert_equals(video.paused, true); |
66 if (seekCount < 6) { | 60 eventSender.mouseUp(); |
67 window.setTimeout("move()", 100); | |
68 return; | |
69 } | |
70 | 61 |
71 if (window.eventSender) { | 62 assert_equals(video.paused, false); |
72 testExpected("video.paused", true); | 63 t.done(); |
73 eventSender.mouseUp(); | 64 } |
74 } | 65 }); |
75 | 66 </script> |
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> | |
OLD | NEW |