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

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

Issue 273153002: MSE: Add basic sequence AppendMode layout tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Enable all 3 tests; fix the expectations Created 6 years, 7 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-sequencemode-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-sequencemode-append-buffer.html
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-sequencemode-append-buffer.html b/LayoutTests/http/tests/media/media-source/mediasource-sequencemode-append-buffer.html
new file mode 100644
index 0000000000000000000000000000000000000000..baccb3fe44b3b4d45e4aef64c25c4f63ef6fcaa6
--- /dev/null
+++ b/LayoutTests/http/tests/media/media-source/mediasource-sequencemode-append-buffer.html
@@ -0,0 +1,113 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="/w3c/resources/testharness.js"></script>
+ <script src="/w3c/resources/testharnessreport.js"></script>
+ <script src="mediasource-util.js"></script>
+ <link rel='stylesheet' href='/w3c/resources/testharness.css'>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function mediasource_sequencemode_test(testFunction, description, options)
+ {
+ return mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ assert_greater_than(segmentInfo.media.length, 3, 'at least 3 media segments for supported type');
+ test.failOnEvent(mediaElement, 'error');
+ sourceBuffer.mode = 'sequence';
+ assert_equals(sourceBuffer.mode, 'sequence', 'mode after setting it to \'sequence\'');
+
+ var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+ test.expectEvent(sourceBuffer, 'updatestart', 'initSegment append started.');
+ test.expectEvent(sourceBuffer, 'update', 'initSegment append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'initSegment append ended.');
+ sourceBuffer.appendBuffer(initSegment);
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(sourceBuffer.timestampOffset, 0, 'timestampOffset initially 0');
+ testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData);
+ });
+ }, description, options);
+ }
+
+ function append_segment(test, sourceBuffer, mediaData, info, callback)
+ {
+ var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, info);
+ test.expectEvent(sourceBuffer, 'updatestart', 'media segment append started.');
+ test.expectEvent(sourceBuffer, 'update', 'media segment append success.');
+ test.expectEvent(sourceBuffer, 'updateend', 'media segment append ended.');
+ sourceBuffer.appendBuffer(mediaSegment);
+ test.waitForExpectedEvents(function() { callback(); });
+ }
+
+ mediasource_sequencemode_test(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ assert_equals(segmentInfo.media[0].timecode, 0, 'segment starts at time 0');
+ append_segment(test, sourceBuffer, mediaData, segmentInfo.media[0], function()
+ {
+ assert_equals(sourceBuffer.timestampOffset, 0, 'timestampOffset remains 0');
+ assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.buffered has 1 range');
+ assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBuffer.buffered range begins at time 0');
+ assert_less_than_equal(sourceBuffer.buffered.end(0), segmentInfo.media[1].timecode, 'sourceBuffer.buffered range ends at or before next segment timecode')
+ test.done();
+ });
+ }, 'Test sequence AppendMode appendBuffer(first media segment)');
+
+ mediasource_sequencemode_test(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment starts after time 0');
+ append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1], function()
+ {
+ // Muxed stream processing causes the offset to not always match expectation based on
+ // segment timecodes, hence allowance of up to 10% deviation from expectation here.
acolwell GONE FROM CHROMIUM 2014/05/12 14:00:09 What? Why is this the case? If the timecode info i
wolenetz 2014/05/19 21:20:43 Done.
+ assert_approx_equals(sourceBuffer.timestampOffset,
+ -segmentInfo.media[1].timecode,
+ segmentInfo.media[1].timecode / 10,
+ 'timestampOffset near -(segment timecode)');
+ assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.buffered has 1 range');
+ assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBuffer.buffered range begins at time 0');
+ assert_less_than_equal(sourceBuffer.buffered.end(0),
+ segmentInfo.media[2].timecode - segmentInfo.media[1].timecode,
+ 'sourceBuffer.buffered range ends at or before duration appended');
+ test.done();
+ });
+ }, 'Test sequence AppendMode appendBuffer(second media segment)');
+
+ mediasource_sequencemode_test(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+ {
+ assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment starts after time 0');
+
+ append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1], function()
+ {
+ assert_equals(segmentInfo.media[0].timecode, 0, 'segment starts at time 0');
+ append_segment(test, sourceBuffer, mediaData, segmentInfo.media[0], function()
+ {
+ // timestampOffset should now have been re-adjusted to put media[0] immediately after media[1].
+ // Muxed stream processing causes the offset to not always exactly match expectation based on
+ // segment timecodes, hence allowance of up to 10% deviation from expectation here.
acolwell GONE FROM CHROMIUM 2014/05/12 14:00:09 ditto re: time bound instead of percentage
wolenetz 2014/05/19 21:20:43 Done.
+ var expected_offset = segmentInfo.media[2].timecode - segmentInfo.media[1].timecode;
+ assert_greater_than(expected_offset, 0, 'media[2] timecode is after media[1] timecode');
+ assert_approx_equals(sourceBuffer.timestampOffset,
+ expected_offset,
+ expected_offset / 10,
+ 'timestampOffset adjusted again');
+
+ assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.buffered has 1 range');
+ assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBuffer.buffered range begins at time 0');
+
+ // Similarly allow for small variation in resulting length of buffered media.
+ assert_approx_equals(sourceBuffer.buffered.end(0),
+ segmentInfo.media[2].timecode,
+ expected_offset / 10,
acolwell GONE FROM CHROMIUM 2014/05/12 14:00:09 ditto.
wolenetz 2014/05/19 21:20:43 Done.
+ 'sourceBuffer.buffered range ends near sum of appended segment durations');
+ assert_greater_than(sourceBuffer.buffered.end(0),
+ segmentInfo.media[2].timecode - segmentInfo.media[1].timecode,
+ 'sourceBuffer.buffered range is larger than the duration of the first appended segment');
+ test.done();
+ })
+ });
+ }, 'Test sequence AppendMode appendBuffer(second media segment, then first media segment)');
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/media-source/mediasource-sequencemode-append-buffer-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698