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 currentMousePosition = { x: 0, y: 0 }; |
11 var x; | 11 var seekCount; |
12 var y; | 12 var moveCount; |
13 var seekCount; | |
14 var moveCount; | |
15 | 13 |
16 if (window.testRunner) | 14 var video = document.querySelector("video"); |
17 testRunner.dumpAsText(); | 15 video.onplaying = t.step_func(playing); |
| 16 video.onseeked = t.step_func(seeked); |
| 17 video.src = findMediaFile("video", "content/test"); |
| 18 video.play(); |
18 | 19 |
19 function test() | 20 function playing() { |
20 { | 21 video.onplaying = null; |
21 seekCount = 0; | 22 seekCount = 0; |
22 moveCount = 0; | 23 moveCount = 0; |
23 | 24 |
24 testExpected("video.paused", false); | 25 assert_equals(video.paused, false); |
25 | 26 |
26 if (window.eventSender) { | 27 var seekCoords = mediaControlsButtonCoordinates(video, "timeline"); |
27 var seekCoords; | 28 currentMousePosition.x = seekCoords[0]; |
28 try { | 29 currentMousePosition.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 | 30 |
37 eventSender.dragMode = false; | 31 eventSender.dragMode = false; |
38 eventSender.mouseMoveTo(x, y); | 32 eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y); |
39 eventSender.mouseDown(); | 33 eventSender.mouseDown(); |
40 | 34 |
41 testExpected("video.paused", true); | 35 assert_equals(video.paused, true); |
42 | 36 |
43 // Drag mouse off of the slider thumb to make sure it contin
ues to track | 37 // Drag mouse off of the slider thumb to make sure it continues to track |
44 y += 100; | 38 currentMousePosition.y += 100; |
45 eventSender.mouseMoveTo(x, y); | 39 eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y); |
46 } | |
47 window.setTimeout("move()", 100); | |
48 } | |
49 | 40 |
50 function move() | 41 setTimeout(t.step_func(move), 100); |
51 { | 42 } |
52 ++moveCount; | |
53 | 43 |
54 var delta = (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1); | 44 function move() { |
| 45 ++moveCount; |
55 | 46 |
56 if (window.eventSender) { | 47 currentMousePosition.x += (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1
); |
57 x += delta; | 48 eventSender.mouseMoveTo(currentMousePosition.x, currentMousePosition.y); |
58 eventSender.mouseMoveTo(x, y); | 49 } |
59 } | |
60 } | |
61 | 50 |
62 function seeked() | 51 function seeked() { |
63 { | 52 ++seekCount; |
| 53 if (seekCount < 6) { |
| 54 setTimeout(t.step_func(move), 100); |
| 55 return; |
| 56 } |
64 | 57 |
65 ++seekCount; | 58 assert_equals(video.paused, true); |
66 if (seekCount < 6) { | 59 eventSender.mouseUp(); |
67 window.setTimeout("move()", 100); | |
68 return; | |
69 } | |
70 | 60 |
71 if (window.eventSender) { | 61 assert_equals(video.paused, false); |
72 testExpected("video.paused", true); | 62 t.done(); |
73 eventSender.mouseUp(); | 63 } |
74 } | 64 }); |
75 | 65 </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 |