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

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

Issue 1678523003: Implement InitSegmentReceived algorithm in blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-audiotrack
Patch Set: Don't check track ids in tests Created 4 years, 6 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-initsegmentreceived-alg.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-initsegmentreceived-alg.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-initsegmentreceived-alg.html
new file mode 100644
index 0000000000000000000000000000000000000000..c7aa122d3dcc9124a6c02c93b3ac10fde0918c85
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-initsegmentreceived-alg.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="/w3c/resources/testharness.js"></script>
+ <script src="/w3c/resources/testharnessreport.js"></script>
+ <script src="mediasource-util.js"></script>
+ </head>
+ <body>
+ <script>
+ function verifyTrackProperties(trackType, track, expectedTrackInfo) {
+ assert_equals(track.kind, expectedTrackInfo.kind, trackType + ".kind");
+ assert_equals(track.label, expectedTrackInfo.label, trackType + ".label");
+ assert_equals(track.language, expectedTrackInfo.language, trackType + ".language");
+ }
+
+ function loadMediaAndVerifyAddedTracks(test, mediaElement, segmentInfo, sourceBuffer, mediaData, expectedAudioTrackInfo, expectedVideoTrackInfo, successCallback)
+ {
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ test.expectEvent(sourceBuffer.audioTracks, "addtrack", "sourceBuffer.audioTracks addtrack event");
+ test.expectEvent(sourceBuffer.videoTracks, "addtrack", "sourceBuffer.videoTracks addtrack event");
+ test.expectEvent(mediaElement.audioTracks, "addtrack", "mediaElement.audioTracks addtrack event");
+ test.expectEvent(mediaElement.videoTracks, "addtrack", "mediaElement.videoTracks addtrack event");
+ test.expectEvent(mediaElement, "loadedmetadata", "loadedmetadata done.");
+ test.expectEvent(sourceBuffer, "updateend", "initSegment append ended.");
+ sourceBuffer.appendBuffer(initSegment);
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(sourceBuffer.audioTracks.length, 1, "audioTracks.length");
+ verifyTrackProperties("audio", sourceBuffer.audioTracks[0], expectedAudioTrackInfo);
+ assert_equals(sourceBuffer.audioTracks[0].sourceBuffer, sourceBuffer, "audioTrack.sourceBuffer");
+ // The first audio track is enabled by default.
+ assert_true(sourceBuffer.audioTracks[0].enabled, "sourceBuffer.audioTracks[0].enabled");
+
+ assert_equals(sourceBuffer.videoTracks.length, 1, "videoTracks.length");
+ verifyTrackProperties("video", sourceBuffer.videoTracks[0], expectedVideoTrackInfo);
+ assert_equals(sourceBuffer.videoTracks[0].sourceBuffer, sourceBuffer, "videoTrack.sourceBuffer");
+ // The first video track is selected by default.
+ assert_true(sourceBuffer.videoTracks[0].selected, "sourceBuffer.videoTracks[0].selected");
+
+ assert_not_equals(sourceBuffer.audioTracks[0].id, sourceBuffer.videoTracks[0].id, "track ids must be unique");
+
+ assert_equals(mediaElement.videoTracks.length, 1, "videoTracks.length");
+ assert_equals(mediaElement.videoTracks[0], sourceBuffer.videoTracks[0], "mediaElement.videoTrack == sourceBuffer.videoTrack");
+
+ assert_equals(mediaElement.audioTracks.length, 1, "audioTracks.length");
+ assert_equals(mediaElement.audioTracks[0], sourceBuffer.audioTracks[0], "mediaElement.audioTrack == sourceBuffer.audioTrack");
+
+ successCallback();
+ });
+ }
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var expectedAudioTrackInfo = { kind: "main", label: "", language: "" };
+ var expectedVideoTrackInfo = { kind: "main", label: "", language: "" };
+
+ loadMediaAndVerifyAddedTracks(test, mediaElement, segmentInfo, sourceBuffer, mediaData, expectedAudioTrackInfo, expectedVideoTrackInfo, test.step_func(function ()
+ {
+ // Now append the same exact init segment again. This should succeed, but no new tracks should
+ // be added to the SourceBuffer or MediaElement.
+ test.failOnEvent(sourceBuffer.audioTracks, "addtrack", "Unexpected addtrack event on sourceBuffer.audioTracks for second init segment");
+ test.failOnEvent(sourceBuffer.videoTracks, "addtrack", "Unexpected addtrack event on sourceBuffer.videoTracks for second init segment");
+ test.failOnEvent(mediaElement.audioTracks, "addtrack", "Unexpected addtrack event on mediaElement.audioTracks for second init segment");
+ test.failOnEvent(mediaElement.videoTracks, "addtrack", "Unexpected addtrack event on mediaElement.videoTracks for second init segment");
+
+ test.expectEvent(sourceBuffer, "updateend", "InitSegment append ended.");
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ sourceBuffer.appendBuffer(initSegment);
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaElement.audioTracks.length, 1, "mediaElement.audioTracks.length");
+ assert_equals(mediaElement.videoTracks.length, 1, "mediaElement.videoTracks.length");
+ assert_equals(sourceBuffer.audioTracks.length, 1, "sourceBuffer.audioTracks.length");
+ assert_equals(sourceBuffer.videoTracks.length, 1, "sourceBuffer.videoTracks.length");
+ test.done();
+ });
+ }));
+ }, "Same init segment appended twice");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var originalTrackDefaults = [
+ new TrackDefault("audio", "audio-language", "audio-label", ["main"], "2"),
+ new TrackDefault("video", "video-language", "video-label", ["main"], "1")
+ ];
+ var trackDefaultList = new TrackDefaultList(originalTrackDefaults.slice());
+ sourceBuffer.trackDefaults = trackDefaultList;
+
+ var expectedAudioTrackInfo = { kind: "main", label: "audio-label", language: "audio-language" };
+ var expectedVideoTrackInfo = { kind: "main", label: "video-label", language: "video-language" };
+
+ loadMediaAndVerifyAddedTracks(test, mediaElement, segmentInfo, sourceBuffer, mediaData, expectedAudioTrackInfo, expectedVideoTrackInfo, test.step_func_done());
+ }, "Track defaults processing in the init segment algorithm (explicit bytestream ids)");
+
+ mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ var originalTrackDefaults = [
+ new TrackDefault("audio", "audio-language", "audio-label", ["main"], ""),
+ new TrackDefault("video", "video-language", "video-label", ["main"], "")
+ ];
+ var trackDefaultList = new TrackDefaultList(originalTrackDefaults.slice());
+ sourceBuffer.trackDefaults = trackDefaultList;
+
+ var expectedAudioTrackInfo = { kind: "main", label: "audio-label", language: "audio-language" };
+ var expectedVideoTrackInfo = { kind: "main", label: "video-label", language: "video-language" };
+
+ loadMediaAndVerifyAddedTracks(test, mediaElement, segmentInfo, sourceBuffer, mediaData, expectedAudioTrackInfo, expectedVideoTrackInfo, test.step_func_done());
+ }, "Track defaults processing in the init segment algorithm (no bytestream ids)");
+
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698