Chromium Code Reviews| Index: LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
| diff --git a/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..78e6c2649a86378e60d0a112fd3a8e72952238b5 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
| @@ -0,0 +1,81 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <script src="/w3c/resources/testharness.js"></script> |
| + <script src="/w3c/resources/testharnessreport.js"></script> |
| + <script src="mediasource-util.js"></script> |
| + <script src="/media/resources/media-source/webm/segment-info.js"></script> |
| + <link rel="stylesheet" href="/w3c/resources/testharness.css"> |
| + </head> |
| + <body> |
| + <div id='log'></div> |
| + |
| + <script> |
| + |
| + function seekBackAfterPlayingTest(testFunction, description, options) |
| + { |
| + mediasource_test(function(test, mediaElement, mediaSource) |
| + { |
| + var segmentInfo = WebMSegmentInfo.testWebM; |
| + assert_equals(segmentInfo.duration, 6.042, 'Expected test media duration'); |
| + test.failOnEvent(mediaElement, 'error'); |
| + |
| + var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); |
| + MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData) |
| + { |
| + testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData); |
| + }); |
| + }, description, options); |
| + } |
| + |
| + seekBackAfterPlayingTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| + { |
| + |
| + mediaElement.play(); |
| + // Append all the segments |
| + test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); |
| + test.expectEvent(mediaElement, 'playing', 'Playing triggered'); |
| + sourceBuffer.appendBuffer(mediaData); |
| + |
| + var confirmPlayAfterSeek = test.step_func(function(){ |
|
wolenetz
2013/08/02 23:06:45
nit: { on next line.
anandc
2013/08/02 23:46:43
Done.
|
| + test.waitForExpectedEvents(function() |
| + { |
| + var delayedPlayAfterSeekHandler = test.step_func(function() |
| + { |
| + assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started after seek.'); |
|
wolenetz
2013/08/02 23:06:45
nit: indent 4. hmm. I missed this one earlier, too
anandc
2013/08/02 23:46:43
Done.
|
| + test.done(); |
| + }); |
| + test.expectDelayedCallback(delayedPlayAfterSeekHandler, 300); |
| + }); |
| + }); |
| + |
| + var seekAndPlayAgain = test.step_func(function(){ |
| + test.waitForExpectedEvents(function() |
| + { |
| + assert_true(mediaElement.seeking, 'mediaElement is seeking'); |
| + assert_equals(mediaElement.currentTime, 0.0, 'Current time is 0.0'); |
| + test.expectEvent(mediaElement, 'timeupdate', 'timeupdate fired.'); |
| + test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek'); |
| + |
| + confirmPlayAfterSeek(); |
|
wolenetz
2013/08/02 23:06:45
low-pri nit: (like below; read the next comment fi
anandc
2013/08/02 23:46:43
Done.
|
| + }); |
| + }); |
| + |
| + var delayedPlayHandler = test.step_func(function() |
| + { |
| + assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started.'); |
| + test.expectEvent(mediaElement, 'seeking', 'mediaElement'); |
| + mediaElement.currentTime = 0.0; |
| + |
| + seekAndPlayAgain(); |
|
wolenetz
2013/08/02 23:06:45
low-pri nit: Wrap this call inside test.waitForExp
anandc
2013/08/02 23:46:43
Done.
anandc
2013/08/02 23:49:11
Done the first part. Didn't chain calls. Maybe for
wolenetz
2013/08/03 00:06:28
looks good. chaining was just an idea for readabil
|
| + }); |
| + |
| + test.waitForExpectedEvents(function() |
| + { |
| + test.expectDelayedCallback(delayedPlayHandler, 300); |
| + }); |
| + |
| + }, 'Test playing then seeking back.'); |
| + </script> |
| + </body> |
| +</html> |