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..ab1b1b05826b450ec789632a137292c502a574f5 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/media/media-source/mediasource-play-then-seek-back.html |
| @@ -0,0 +1,77 @@ |
| +<!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) |
|
wolenetz
2013/08/02 21:41:37
nit: Indentation (4 spaces).
anandc
2013/08/02 22:37:48
Done.
|
| + { |
| + 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); |
| + } |
| + |
| + function getSegment(mediaData, info) |
|
wolenetz
2013/08/02 21:41:37
nit: Remove unused function.
anandc
2013/08/02 22:37:48
Huh. Done.
|
| + { |
| + var start = info.offset; |
| + var end = start + info.size; |
| + return mediaData.subarray(start, end); |
| + } |
| + |
| + 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 playTimeoutHandler = test.step_func(function() |
| + { |
| + assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started.'); |
| + test.expectEvent(mediaElement, 'seeking', 'mediaElement'); |
| + mediaElement.currentTime = 0.0; |
| + |
| + 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'); |
| + var playAfterSeekHandler = test.step_func(function() |
| + { |
| + assert_greater_than(mediaElement.currentTime, 0.0, 'Playback has started after seek.'); |
| + test.done(); |
| + }); |
| + test.expectDelayedCallback(playAfterSeekHandler, 300); |
|
wolenetz
2013/08/02 21:41:37
More than a nit:
This line needs to be done only a
anandc
2013/08/02 22:37:48
Thanks for the thorough review and explanations. I
|
| + }); |
| + |
| + }); |
| + |
| + test.waitForExpectedEvents(function() |
| + { |
| + test.expectDelayedCallback(playTimeoutHandler, 300); |
| + }); |
| + |
| + }, 'Test playing then seeking back.'); |
| + </script> |
| + </body> |
| +</html> |