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

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

Issue 419673007: Adding more MSE tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing CR comments Created 6 years, 5 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/media-source/mediasource-append-buffer-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16347a57dbf6bfc4311f68b2957c956789e40531..741dd8aabaef7cdf9b4ab46da1ef6bd6b34796d8 100644
--- a/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
+++ b/LayoutTests/http/tests/media/media-source/mediasource-append-buffer.html
@@ -13,334 +13,408 @@
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ 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");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test SourceBuffer.appendBuffer() event dispatching.");
+ }, 'Test SourceBuffer.appendBuffer() event dispatching.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ 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");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
- assert_throws("InvalidStateError",
+ assert_throws('InvalidStateError',
function() { sourceBuffer.appendBuffer(mediaData); },
- "appendBuffer() throws an exception there is a pending append.");
+ 'appendBuffer() throws an exception there is a pending append.');
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test SourceBuffer.appendBuffer() call during a pending appendBuffer().");
+ }, 'Test SourceBuffer.appendBuffer() call during a pending appendBuffer().');
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.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'abort', 'Append aborted.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(mediaData);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
sourceBuffer.abort();
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test SourceBuffer.abort() call during a pending appendBuffer().");
+ }, 'Test SourceBuffer.abort() call during a pending appendBuffer().');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ 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");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
- test.expectEvent(mediaSource, "sourceended", "MediaSource sourceended event");
+ test.expectEvent(mediaSource, 'sourceended', 'MediaSource sourceended event');
mediaSource.endOfStream();
- assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+ assert_equals(mediaSource.readyState, 'ended', 'MediaSource readyState is "ended"');
});
test.waitForExpectedEvents(function()
{
- assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+ 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.");
+ 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(mediaData);
- assert_equals(mediaSource.readyState, "open", "MediaSource readyState is 'open'");
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ 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");
+ assert_equals(mediaSource.readyState, 'open', 'MediaSource readyState is "open"');
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test SourceBuffer.appendBuffer() triggering an 'ended' to 'open' transition.");
+ }, 'Test SourceBuffer.appendBuffer() 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, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ 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");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
- test.expectEvent(mediaSource, "sourceended", "MediaSource sourceended event");
+ test.expectEvent(mediaSource, 'sourceended', 'MediaSource sourceended event');
mediaSource.endOfStream();
- assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+ assert_equals(mediaSource.readyState, 'ended', 'MediaSource readyState is "ended"');
});
test.waitForExpectedEvents(function()
{
- assert_equals(mediaSource.readyState, "ended", "MediaSource readyState is 'ended'");
+ 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.");
+ 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");
+ 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");
+ 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.");
+ }, '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.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'abort', 'Append aborted.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(mediaData);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
- test.expectEvent(mediaSource.activeSourceBuffers, "removesourcebuffer", "activeSourceBuffers");
- test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer", "sourceBuffers");
+ test.expectEvent(mediaSource.activeSourceBuffers, 'removesourcebuffer', 'activeSourceBuffers');
+ test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffer', 'sourceBuffers');
mediaSource.removeSourceBuffer(sourceBuffer);
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
- assert_throws("InvalidStateError",
+ assert_throws('InvalidStateError',
function() { sourceBuffer.appendBuffer(mediaData); },
- "appendBuffer() throws an exception because it isn't attached to the mediaSource anymore.");
+ 'appendBuffer() throws an exception because it isn\'t attached to the mediaSource anymore.');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test MediaSource.removeSourceBuffer() call during a pending appendBuffer().");
+ }, 'Test MediaSource.removeSourceBuffer() call during a pending appendBuffer().');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(mediaData);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
- assert_throws("InvalidStateError",
+ assert_throws('InvalidStateError',
function() { mediaSource.duration = 1.0; },
- "set duration throws an exception when updating attribute is true.");
+ 'set duration throws an exception when updating attribute is true.');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test set MediaSource.duration during a pending appendBuffer() for one of its SourceBuffers.");
+ }, 'Test set MediaSource.duration during a pending appendBuffer() for one of its SourceBuffers.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
- test.failOnEvent(mediaElement, "error");
- test.failOnEvent(mediaSource, "sourceended");
+ test.failOnEvent(mediaElement, 'error');
+ test.failOnEvent(mediaSource, 'sourceended');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(mediaData);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
- assert_throws("InvalidStateError",
+ assert_throws('InvalidStateError',
function() { mediaSource.endOfStream(); },
- "endOfStream() throws an exception when updating attribute is true.");
+ 'endOfStream() throws an exception when updating attribute is true.');
- assert_equals(mediaSource.readyState, "open");
+ assert_equals(mediaSource.readyState, 'open');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
- assert_equals(mediaSource.readyState, "open");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
+ assert_equals(mediaSource.readyState, 'open');
test.done();
});
- }, "Test MediaSource.endOfStream() during a pending appendBuffer() for one of its SourceBuffers.");
+ }, 'Test MediaSource.endOfStream() during a pending appendBuffer() for one of its SourceBuffers.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(mediaData);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
- assert_throws("InvalidStateError",
+ assert_throws('InvalidStateError',
function() { sourceBuffer.timestampOffset = 10.0; },
- "set timestampOffset throws an exception when updating attribute is true.");
+ 'set timestampOffset throws an exception when updating attribute is true.');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test set SourceBuffer.timestampOffset during a pending appendBuffer().");
+ }, 'Test set SourceBuffer.timestampOffset during a pending appendBuffer().');
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.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'update', 'Append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(new Uint8Array(0));
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test appending an empty ArrayBufferView.");
+ }, 'Test appending an empty ArrayBufferView.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'update', 'Append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
var arrayBufferView = new Uint8Array(mediaData);
- assert_equals(arrayBufferView.length, mediaData.length, "arrayBufferView.length before transfer.");
+ assert_equals(arrayBufferView.length, mediaData.length, 'arrayBufferView.length before transfer.');
// Send the buffer as in a message so it gets neutered.
- window.postMessage( "test", "*", [arrayBufferView.buffer]);
+ window.postMessage( 'test', '*', [arrayBufferView.buffer]);
- assert_equals(arrayBufferView.length, 0, "arrayBufferView.length after transfer.");
+ assert_equals(arrayBufferView.length, 0, 'arrayBufferView.length after transfer.');
sourceBuffer.appendBuffer(arrayBufferView);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test appending a neutered ArrayBufferView.");
+ }, 'Test appending a neutered ArrayBufferView.');
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.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'update', 'Append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
sourceBuffer.appendBuffer(new ArrayBuffer(0));
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test appending an empty ArrayBuffer.");
+ }, 'Test appending an empty ArrayBuffer.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
test.failOnEvent(mediaElement, 'error');
- test.expectEvent(sourceBuffer, "updatestart", "Append started.");
- test.expectEvent(sourceBuffer, "update", "Append success.");
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'update', 'Append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
var arrayBuffer = mediaData.buffer.slice();
- assert_equals(arrayBuffer.byteLength, mediaData.buffer.byteLength, "arrayBuffer.byteLength before transfer.");
+ assert_equals(arrayBuffer.byteLength, mediaData.buffer.byteLength, 'arrayBuffer.byteLength before transfer.');
// Send the buffer as in a message so it gets neutered.
- window.postMessage( "test", "*", [arrayBuffer]);
+ window.postMessage( 'test', '*', [arrayBuffer]);
- assert_equals(arrayBuffer.byteLength, 0, "arrayBuffer.byteLength after transfer.");
+ assert_equals(arrayBuffer.byteLength, 0, 'arrayBuffer.byteLength after transfer.');
sourceBuffer.appendBuffer(arrayBuffer);
- assert_true(sourceBuffer.updating, "updating attribute is true");
+ assert_true(sourceBuffer.updating, 'updating attribute is true');
test.waitForExpectedEvents(function()
{
- assert_false(sourceBuffer.updating, "updating attribute is false");
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
test.done();
});
- }, "Test appending a neutered ArrayBuffer.");
+ }, 'Test appending a neutered ArrayBuffer.');
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ var halfIndex = (initSegment.length + 1) / 2;
+ var partialInitSegment = initSegment.subarray(0, halfIndex);
+ var remainingInitSegment = initSegment.subarray(halfIndex);
+ var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
+
+ test.expectEvent(sourceBuffer, 'updateend', 'partialInitSegment append ended.');
+ sourceBuffer.appendBuffer(partialInitSegment);
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaElement.readyState, mediaElement.HAVE_NOTHING);
+ assert_equals(mediaSource.duration, Number.NaN);
+ test.expectEvent(sourceBuffer, 'updateend', 'remainingInitSegment append ended.');
+ test.expectEvent(mediaElement, 'loadedmetadata', 'loadedmetadata event received.');
+ sourceBuffer.appendBuffer(remainingInitSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaElement.readyState, mediaElement.HAVE_METADATA);
+ assert_equals(mediaSource.duration, segmentInfo.durationInInitSegment);
+ test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment append ended.');
+ test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired.');
+ sourceBuffer.appendBuffer(mediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_greater_than_equal(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA);
+ assert_equals(sourceBuffer.updating, false);
+ assert_equals(mediaSource.readyState, 'open');
+ test.done();
+ });
+ }, 'Test appendBuffer with partial init segments.');
+
+ 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 halfIndex = (mediaSegment.length + 1) / 2;
+ var partialMediaSegment = mediaSegment.subarray(0, halfIndex);
+ var remainingMediaSegment = mediaSegment.subarray(halfIndex);
+
+ test.expectEvent(sourceBuffer, 'updateend', 'InitSegment append ended.');
+ test.expectEvent(mediaElement, 'loadedmetadata', 'loadedmetadata done.');
+ sourceBuffer.appendBuffer(initSegment);
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaElement.readyState, mediaElement.HAVE_METADATA);
+ assert_equals(mediaSource.duration, segmentInfo.durationInInitSegment);
+ test.expectEvent(sourceBuffer, 'updateend', 'partial media segment append ended.');
+ sourceBuffer.appendBuffer(partialMediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment append ended.');
+ test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired.');
+ sourceBuffer.appendBuffer(remainingMediaSegment);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_greater_than_equal(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA);
+ assert_equals(mediaSource.readyState, 'open');
+ assert_equals(sourceBuffer.updating, false);
+ test.done();
+ });
+ }, 'Test appendBuffer with partial media segments.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
@@ -348,7 +422,7 @@
var partialInitSegment = initSegment.subarray(0, initSegment.length / 2);
var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
- test.expectEvent(sourceBuffer, "updateend", "partialInitSegment append ended.");
+ test.expectEvent(sourceBuffer, 'updateend', 'partialInitSegment append ended.');
sourceBuffer.appendBuffer(partialInitSegment);
test.waitForExpectedEvents(function()
@@ -357,14 +431,14 @@
sourceBuffer.abort();
// Append the full intiialization segment.
- test.expectEvent(sourceBuffer, "updateend", "initSegment append ended.");
+ 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.");
+ test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment append ended.');
+ test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired.');
sourceBuffer.appendBuffer(mediaSegment);
});
@@ -372,7 +446,7 @@
{
test.done();
});
- }, "Test abort in the middle of an initialization segment.");
+ }, 'Test abort in the middle of an initialization segment.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
@@ -381,12 +455,12 @@
var partialMediaSegment = mediaSegment.subarray(0, 3 * mediaSegment.length / 4);
var partialBufferedRanges = null;
- test.expectEvent(sourceBuffer, "updateend", "initSegment append ended.");
+ test.expectEvent(sourceBuffer, 'updateend', 'initSegment append ended.');
sourceBuffer.appendBuffer(initSegment);
test.waitForExpectedEvents(function()
{
- test.expectEvent(sourceBuffer, "updateend", "partialMediaSegment append ended.");
+ test.expectEvent(sourceBuffer, 'updateend', 'partialMediaSegment append ended.');
sourceBuffer.appendBuffer(partialMediaSegment);
});
@@ -397,48 +471,99 @@
// 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");
+ assert_equals(partialBufferedRanges.length, 1, 'partialBufferedRanges has 1 range');
// Append the full media segment.
- test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
+ test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment append ended.');
sourceBuffer.appendBuffer(mediaSegment);
});
test.waitForExpectedEvents(function()
{
- test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ 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_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffer', 'SourceBuffer removed.');
+ mediaSource.removeSourceBuffer(sourceBuffer);
+ test.waitForExpectedEvents(function()
+ {
+ assert_throws('InvalidStateError',
+ function() { sourceBuffer.abort(); },
+ 'sourceBuffer.abort() throws an exception for InvalidStateError.');
+
+ test.done();
+ });
+ }, 'Test abort after removing sourcebuffer.');
- 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.");
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ test.expectEvent(mediaSource, 'sourceended', 'source ended');
+
+ assert_equals(mediaSource.readyState, 'open', 'readyState is open.');
+ mediaSource.endOfStream();
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaSource.readyState, 'ended', 'readyState is ended.');
+ assert_throws('InvalidStateError',
+ function() { sourceBuffer.abort(); },
+ 'sourceBuffer.abort() throws an exception for InvalidStateError.');
test.done();
});
- }, "Test abort in the middle of a media segment.");
+
+ }, 'Test abort after readyState is ended.');
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
+ sourceBuffer.appendWindowStart = 1;
+ sourceBuffer.appendWindowEnd = 100;
+ sourceBuffer.appendBuffer(mediaData);
+ test.waitForExpectedEvents(function()
+ {
+ assert_false(sourceBuffer.updating, 'updating attribute is false');
+ sourceBuffer.abort();
+ assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindowStart is reset to 0');
+ assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY,
+ 'appendWindowEnd is reset to +INFINITY');
+ test.done();
+ });
+ }, 'Test abort after appendBuffer update ends.');
+
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.");
+ test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
+ test.expectEvent(sourceBuffer, 'update', 'Append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
- assert_throws( { name: "TypeError"} ,
+ assert_throws( { name: 'TypeError'} ,
function() { sourceBuffer.appendBuffer(null); },
- "appendBuffer(null) throws an exception.");
+ 'appendBuffer(null) throws an exception.');
test.done();
- }, "Test appending null.");
+ }, 'Test appending null.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
mediaSource.removeSourceBuffer(sourceBuffer);
- assert_throws( { name: "InvalidStateError"} ,
+ assert_throws( { name: 'InvalidStateError'} ,
function() { sourceBuffer.appendBuffer(mediaData); },
- "appendBuffer() throws an exception when called after removeSourceBuffer().");
+ 'appendBuffer() throws an exception when called after removeSourceBuffer().');
test.done();
- }, "Test appending after removeSourceBuffer().");
+ }, 'Test appending after removeSourceBuffer().');
</script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/media-source/mediasource-append-buffer-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698