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

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html

Issue 245893002: Improve unprefixed MediaSource test coverage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html b/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
index 1896fe43235904bba8cb98b064679c8fceb30673..8a6339e286977f8f29a8d7dd6cd5defdf0f07124 100644
--- a/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
+++ b/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
@@ -119,6 +119,47 @@
test.failOnEvent(mediaElement, 'error');
test.expectEvent(sourceBuffer, "updatestart", "Append started.");
+ test.expectEvent(sourceBuffer, "update", "Append success.");
+ test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ sourceBuffer.appendBuffer(mediaData);
+ assert_true(sourceBuffer.updating, "updating attribute is true");
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_false(sourceBuffer.updating, "updating attribute is false");
+
+ test.expectEvent(mediaSource, "sourceended", "MediaSource sourceended event");
+ mediaSource.endOfStream();
+ assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+
+ test.expectEvent(mediaSource, "sourceopen", "MediaSource sourceopen event");
+ test.expectEvent(sourceBuffer, "updatestart", "Append started.");
+ test.expectEvent(sourceBuffer, "update", "Append success.");
+ test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ sourceBuffer.appendBuffer(new Uint8Array(0));
+
+ assert_equals(mediaSource.readyState, "open", "MediaSource readyState is 'open'");
+ assert_true(sourceBuffer.updating, "updating attribute is true");
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaSource.readyState, "open", "MediaSource readyState is 'open'");
+ assert_false(sourceBuffer.updating, "updating attribute is false");
+ test.done();
+ });
+ }, "Test zero byte SourceBuffer.appendBuffer() call triggering an 'ended' to 'open' transition.");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ test.failOnEvent(mediaElement, 'error');
+
+ test.expectEvent(sourceBuffer, "updatestart", "Append started.");
test.expectEvent(sourceBuffer, "abort", "Append aborted.");
test.expectEvent(sourceBuffer, "updateend", "Append ended.");
sourceBuffer.appendBuffer(mediaData);
@@ -246,6 +287,103 @@
});
}, "Test appending an empty ArrayBuffer.");
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ var partialInitSegment = initSegment.subarray(0, initSegment.length / 2);
+ var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
+
+ test.expectEvent(sourceBuffer, "updateend", "partialInitSegment append ended.");
+ sourceBuffer.appendBuffer(partialInitSegment);
+
+ test.waitForExpectedEvents(function()
+ {
+ // Call abort to reset the parser.
+ sourceBuffer.abort();
+
+ // Append the full intiialization segment.
+ test.expectEvent(sourceBuffer, "updateend", "initSegment append ended.");
+ sourceBuffer.appendBuffer(initSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
+ test.expectEvent(mediaElement, "loadeddata", "loadeddata fired.");
+ sourceBuffer.appendBuffer(mediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.done();
+ });
+ }, "Test abort in the middle of an initialization segment.");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
+ var partialMediaSegment = mediaSegment.subarray(0, 3 * mediaSegment.length / 4);
+ var partialBufferedRanges = null;
+
+ test.expectEvent(sourceBuffer, "updateend", "initSegment append ended.");
+ sourceBuffer.appendBuffer(initSegment);
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(sourceBuffer, "updateend", "partialMediaSegment append ended.");
+ sourceBuffer.appendBuffer(partialMediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ // Call abort to reset the parser.
+ sourceBuffer.abort();
+
+ // Keep a copy of the buffered ranges before we append the whole media segment.
+ partialBufferedRanges = sourceBuffer.buffered;
+ assert_equals(partialBufferedRanges.length, 1, "partialBufferedRanges has 1 range");
+
+ // Append the full media segment.
+ test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
+ sourceBuffer.appendBuffer(mediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+
+ assert_equals(sourceBuffer.buffered.length, 1, "sourceBuffer.buffered has 1 range");
+ assert_equals(sourceBuffer.buffered.length, partialBufferedRanges.length, "sourceBuffer.buffered and partialBufferedRanges are the same length.");
+ assert_equals(sourceBuffer.buffered.start(0), partialBufferedRanges.start(0), "sourceBuffer.buffered and partialBufferedRanges start times match.");
+ assert_greater_than(sourceBuffer.buffered.end(0), partialBufferedRanges.end(0), "sourceBuffer.buffered has a higher end time than partialBufferedRanges.");
+ test.done();
+ });
+ }, "Test abort in the middle of a media segment.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE);
+
+ test.expectEvent(sourceBuffer, "updatestart", "Append started.");
+ test.expectEvent(sourceBuffer, "update", "Append success.");
+ test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+
+ assert_throws( { name: "TypeError"} ,
+ function() { sourceBuffer.appendBuffer(null); },
+ "appendBuffer(null) throws an exception.");
+ test.done();
+ }, "Test appending null.");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ mediaSource.removeSourceBuffer(sourceBuffer);
+
+ assert_throws( { name: "InvalidStateError"} ,
+ function() { sourceBuffer.appendBuffer(mediaData); },
+ "appendBuffer() throws an exception when called after removeSourceBuffer().");
+ test.done();
+ }, "Test appending after removeSourceBuffer().");
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698