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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html

Issue 2226443002: Support multiple media tracks in MSE / ChunkDemuxer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed integer overflow Created 4 years, 3 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: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html
index 2fe975473577e630e711e79848d6ac0d7b5f6045..dc2bfd0052a7b1aa6c17151e9658efd3daf721c8 100644
--- a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html
+++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-addsourcebuffer.html
@@ -39,7 +39,7 @@
"addSourceBuffer() threw an exception when passed null.");
test.done();
}, "Test addSourceBuffer() with null");
-
+
mediasource_test(function(test, mediaElement, mediaSource)
{
assert_throws("NotSupportedError",
@@ -90,7 +90,7 @@
assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBuffer is not in mediaSource.activeSourceBuffers");
test.done();
}, "Test addSourceBuffer() video only");
-
+
mediasource_test(function(test, mediaElement, mediaSource)
{
var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE;
@@ -134,24 +134,48 @@
test.done();
}, "Test addSourceBuffer() with AAC and H.264 in separate SourceBuffers");
- mediasource_test(function(test, mediaElement, mediaSource)
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ test.expectEvent(sourceBuffer, "updateend");
+ sourceBuffer.appendBuffer(mediaData);
+ test.waitForExpectedEvents(function()
+ {
+ assert_throws({name: "QuotaExceededError"},
+ function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); },
+ "addSourceBuffer must throw an exception if the MediaSource has already received init segments for all sourcebuffers added at the time");
+ test.done();
+ });
+ }, "Test addSourceBuffer() throws QuotaExceededError after MediaSource has completed init.");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{
- var reachedLimit = false;
-
- // The 20 here is an arbitrary upper limit to make sure the test terminates. This test
- // assumes that implementations won't support more than 20 SourceBuffers simultaneously.
- for (var i = 0; i < 20; ++i) {
- try {
- mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
- } catch(e) {
- assert_equals(e.name, "QuotaExceededError");
- reachedLimit = true;
- break;
- }
- }
- assert_true(reachedLimit, "Reached SourceBuffer limit.");
- test.done();
- }, "Test addSourceBuffer() QuotaExceededError.");
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ test.expectEvent(sourceBuffer, "updateend");
+ // Append incomplete init segment to the first SourceBuffer.
+ sourceBuffer.appendBuffer(initSegment.slice(0, initSegment.length - 1));
+ test.waitForExpectedEvents(function()
+ {
+ // We have not added a full init segment for the first SourceBuffer yet, so MediaSource init is not yet
+ // finished and we should be able to add/remove one more SourceBuffer.
+ var sourceBuffer2 = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
+ mediaSource.removeSourceBuffer(sourceBuffer2);
+
+ // Now append the rest of the init segment, this should complete the initialization of the MediaSource.
+ test.expectEvent(sourceBuffer, "updateend");
+ test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata.");
+ sourceBuffer.appendBuffer(initSegment.slice(initSegment.length - 1));
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ // MediaSource is fully initialized now, so adding new SourceBuffers is no longer possible.
+ assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA);
+ assert_throws({name: "QuotaExceededError"},
+ function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); },
+ "addSourceBuffer must throw an exception if the media element has already reached HAVE_METADATA");
+ test.done();
+ });
+ }, "Test addSourceBuffer() succeeds while incomplete init segment is appended, fails after MediaSource init completed.");
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698