Commit 55783f9a authored by prabhur@chromium.org's avatar prabhur@chromium.org

Adding a few new MSE tests based on the spec.

This is intended to make the MSE implementation more spec compliant.
More such CLs to follow after this initial round is checked in.

BUG=
TEST=new test pass

Review URL: https://codereview.chromium.org/267333006

git-svn-id: svn://svn.chromium.org/blink/trunk@173667 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8b406e63
PASS Test addSourceBuffer() in 'ended' state.
PASS Test addSourceBuffer() with empty type
PASS Test addSourceBuffer() with null
PASS Test addSourceBuffer() with unsupported type
PASS Test addSourceBuffer() with Vorbis and VP8
PASS Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffers
PASS Test addSourceBuffer() video only
PASS Test addSourceBuffer() audio only
FAIL Test addSourceBuffer() with AAC and H.264 assert_true: video/mp4;codecs="avc1.4D4001,mp4a.40.2" is supported expected true got false
FAIL Test addSourceBuffer() with AAC and H.264 in separate SourceBuffers assert_true: video/mp4;codecs="avc1.4D4001" is supported expected true got false
PASS Test addSourceBuffer() QuotaExceededError.
......
......@@ -26,7 +26,15 @@
"addSourceBuffer() threw an exception when passed an empty string.");
test.done();
}, "Test addSourceBuffer() with empty type");
mediasource_test(function(test, mediaElement, mediaSource)
{
assert_throws("NotSupportedError",
function() { mediaSource.addSourceBuffer(null); },
"addSourceBuffer() threw an exception when passed null.");
test.done();
}, "Test addSourceBuffer() with null");
mediasource_test(function(test, mediaElement, mediaSource)
{
assert_throws("NotSupportedError",
......@@ -47,7 +55,7 @@
assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "SourceBuffer is in mediaSource.activeSourceBuffers");
test.done();
}, "Test addSourceBuffer() with Vorbis and VP8");
mediasource_test(function(test, mediaElement, mediaSource)
{
var videoMimetype = 'video/webm;codecs="vp8"';
......@@ -65,6 +73,32 @@
test.done();
}, "Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffers");
mediasource_test(function(test, mediaElement, mediaSource)
{
var mimetype = MediaSourceUtil.VIDEO_ONLY_TYPE;
assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported");
var sourceBuffer = mediaSource.addSourceBuffer(mimetype);
assert_true(sourceBuffer != null, "New SourceBuffer returned");
assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceBuffer is in mediaSource.sourceBuffers");
assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "SourceBuffer is in mediaSource.activeSourceBuffers");
test.done();
}, "Test addSourceBuffer() video only");
mediasource_test(function(test, mediaElement, mediaSource)
{
var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE;
assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported");
var sourceBuffer = mediaSource.addSourceBuffer(mimetype);
assert_true(sourceBuffer != null, "New SourceBuffer returned");
assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceBuffer is in mediaSource.sourceBuffers");
assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "SourceBuffer is in mediaSource.activeSourceBuffers");
test.done();
}, "Test addSourceBuffer() audio only");
mediasource_test(function(test, mediaElement, mediaSource)
{
var mimetype = 'video/mp4;codecs="avc1.4D4001,mp4a.40.2"';
......
......@@ -3,5 +3,9 @@ PASS Test attribute values on a closed MediaSource object.
PASS Test addSourceBuffer() while closed.
PASS Test removeSourceBuffer() while closed.
PASS Test endOfStream() while closed.
PASS Test endOfStream(decode) while closed.
PASS Test endOfStream(network) while closed.
PASS Test setting duration while closed.
PASS Test setting duration while open->closed.
PASS Test getting duration while open->closed.
......@@ -36,6 +36,7 @@
assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuffers is empty");
assert_equals(mediaSource.activeSourceBuffers.length, 0, "activeSourceBuffers is empty");
assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
assert_true(Number.isNaN(mediaSource.duration), "duration is NaN");
assert_throws("NotFoundError",
function() { mediaSource.removeSourceBuffer(sourceBuffer); },
"removeSourceBuffer() throws an exception when closed.");
......@@ -54,6 +55,22 @@
"endOfStream() throws an exception when closed.");
}, "Test endOfStream() while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("decode"); },
"endOfStream(decode) throws an exception when closed.");
}, "Test endOfStream(decode) while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("network"); },
"endOfStream(network) throws an exception when closed.");
}, "Test endOfStream(network) while closed.");
test(function ()
{
......@@ -63,6 +80,41 @@
"Setting duration throws an exception when closed.");
}, "Test setting duration while closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
// Setup a handler to run when the MediaSource closes.
mediaSource.addEventListener('sourceclose', test.step_func(function (event)
{
assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
assert_throws("InvalidStateError",
function() { mediaSource.duration = 10; },
"Setting duration when closed throws an exception");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test setting duration while open->closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
// Setup a handler to run when the MediaSource closes.
mediaSource.addEventListener('sourceclose', test.step_func(function (event)
{
assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
assert_true(Number.isNaN(mediaSource.duration), "duration is NaN");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test getting duration while open->closed.");
</script>
</body>
</html>
PASS Test MediaSource.endOfStream() with invalid non-empty error string.
PASS Test MediaSource.endOfStream() with invalid empty error string.
PASS Test MediaSource.endOfStream() with when readyState is ended.
PASS Test MediaSource.endOfStream(decode) with when readyState is ended.
PASS Test MediaSource.endOfStream(network) with when readyState is ended.
PASS Test MediaSource.endOfStream() with invalid null error parameter.
......@@ -35,6 +35,54 @@
test.done();
}, 'Test MediaSource.endOfStream() with invalid empty error string.');
mediasource_test(function(test, mediaElement, mediaSource)
{
test.failOnEvent(mediaElement, 'error');
assert_equals(mediaSource.readyState, 'open');
test.expectEvent(mediaSource, 'sourceend');
mediaSource.endOfStream();
assert_equals(mediaSource.readyState, 'ended');
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream(); },
"endofStream() threw an exception when in ended state");
test.done();
}, 'Test MediaSource.endOfStream() with when readyState is ended.');
mediasource_test(function(test, mediaElement, mediaSource)
{
test.failOnEvent(mediaElement, 'error');
assert_equals(mediaSource.readyState, 'open');
test.expectEvent(mediaSource, 'sourceend');
mediaSource.endOfStream();
assert_equals(mediaSource.readyState, 'ended');
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("decode"); },
"endofStream() threw an exception when in ended state");
test.done();
}, 'Test MediaSource.endOfStream(decode) with when readyState is ended.');
mediasource_test(function(test, mediaElement, mediaSource)
{
test.failOnEvent(mediaElement, 'error');
assert_equals(mediaSource.readyState, 'open');
test.expectEvent(mediaSource, 'sourceend');
mediaSource.endOfStream();
assert_equals(mediaSource.readyState, 'ended');
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("network"); },
"endofStream() threw an exception when in ended state");
test.done();
}, 'Test MediaSource.endOfStream(network) with when readyState is ended.');
mediasource_test(function(test, mediaElement, mediaSource)
{
test.failOnEvent(mediaElement, 'error');
......
......@@ -8,6 +8,9 @@ PASS Test invalid MIME format "video/webm;codecs="
PASS Test invalid MIME format "video/webm;codecs=""
PASS Test invalid MIME format "video/webm;codecs="""
PASS Test invalid MIME format "video/webm;codecs=",""
PASS Test invalid MIME format "unsupported_mediatype"
PASS Test invalid MIME format ""
PASS Test invalid MIME format "null"
PASS Test invalid mismatch between major type and codec ID "audio/webm;codecs="vp8""
PASS Test invalid mismatch between major type and codec ID "audio/mp4;codecs="avc1.4d001e""
PASS Test invalid mismatch between minor type and codec ID "audio/mp4;codecs="vorbis""
......@@ -25,6 +28,7 @@ PASS Test valid WebM type "video/webm;codecs="vorbis""
PASS Test valid WebM type "video/webm;codecs="vp8,vorbis""
PASS Test valid WebM type "video/webm;codecs="vorbis, vp8""
PASS Test valid WebM type "audio/webm;codecs="vorbis""
PASS Test valid WebM type "AUDIO/WEBM;CODECS="vorbis""
FAIL Test valid MP4 type "video/mp4;codecs="avc1.4d001e"" assert_equals: supported expected true but got false
FAIL Test valid MP4 type "video/mp4;codecs="avc1.42001e"" assert_equals: supported expected true but got false
FAIL Test valid MP4 type "audio/mp4;codecs="mp4a.40.2"" assert_equals: supported expected true but got false
......
......@@ -30,6 +30,9 @@
'video/webm;codecs="',
'video/webm;codecs=""',
'video/webm;codecs=","',
'unsupported_mediatype',
'',
null,
], false, 'Test invalid MIME format');
test_type_support([
......@@ -59,6 +62,7 @@
'video/webm;codecs="vp8,vorbis"',
'video/webm;codecs="vorbis, vp8"',
'audio/webm;codecs="vorbis"',
'AUDIO/WEBM;CODECS="vorbis"',
], true, 'Test valid WebM type');
test_type_support([
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment