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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src="mediasource-util.js"></script>
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 function mediasource_sequencemode_test(testFunction, description, opti ons)
13 {
14 return mediasource_testafterdataloaded(function(test, mediaElement , mediaSource, segmentInfo, sourceBuffer, mediaData)
15 {
16 assert_greater_than(segmentInfo.media.length, 3, 'at least 3 m edia segments for supported type');
17 test.failOnEvent(mediaElement, 'error');
18 sourceBuffer.mode = 'sequence';
19 assert_equals(sourceBuffer.mode, 'sequence', 'mode after setti ng it to \'sequence\'');
20
21 var initSegment = MediaSourceUtil.extractSegmentData(mediaData , segmentInfo.init);
22 test.expectEvent(sourceBuffer, 'updatestart', 'initSegment app end started.');
23 test.expectEvent(sourceBuffer, 'update', 'initSegment append s uccess.');
24 test.expectEvent(sourceBuffer, 'updateend', 'initSegment appen d ended.');
25 sourceBuffer.appendBuffer(initSegment);
26 test.waitForExpectedEvents(function()
27 {
28 assert_equals(sourceBuffer.timestampOffset, 0, 'timestampO ffset initially 0');
29 testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData);
30 });
31 }, description, options);
32 }
33
34 function append_segment(test, sourceBuffer, mediaData, info, callback)
35 {
36 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, i nfo);
37 test.expectEvent(sourceBuffer, 'updatestart', 'media segment appen d started.');
38 test.expectEvent(sourceBuffer, 'update', 'media segment append suc cess.');
39 test.expectEvent(sourceBuffer, 'updateend', 'media segment append ended.');
40 sourceBuffer.appendBuffer(mediaSegment);
41 test.waitForExpectedEvents(function() { callback(); });
42 }
43
44 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
45 {
46 assert_equals(segmentInfo.media[0].timecode, 0, 'segment starts at time 0');
47 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[0] , function()
48 {
49 assert_equals(sourceBuffer.timestampOffset, 0, 'timestampOffse t remains 0');
50 assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.b uffered has 1 range');
51 assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBuffer .buffered range begins at time 0');
52 assert_less_than_equal(sourceBuffer.buffered.end(0), segmentIn fo.media[1].timecode, 'sourceBuffer.buffered range ends at or before next segmen t timecode')
53 test.done();
54 });
55 }, 'Test sequence AppendMode appendBuffer(first media segment)');
56
57 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
58 {
59 assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment sta rts after time 0');
60 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1] , function()
61 {
62 // Muxed stream processing causes the offset to not always mat ch expectation based on
63 // segment timecodes, hence allowance of up to 10% deviation f rom 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.
64 assert_approx_equals(sourceBuffer.timestampOffset,
65 -segmentInfo.media[1].timecode,
66 segmentInfo.media[1].timecode / 10,
67 'timestampOffset near -(segment timecode) ');
68 assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.b uffered has 1 range');
69 assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBuffer .buffered range begins at time 0');
70 assert_less_than_equal(sourceBuffer.buffered.end(0),
71 segmentInfo.media[2].timecode - segment Info.media[1].timecode,
72 'sourceBuffer.buffered range ends at or before duration appended');
73 test.done();
74 });
75 }, 'Test sequence AppendMode appendBuffer(second media segment)');
76
77 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
78 {
79 assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment sta rts after time 0');
80
81 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1] , function()
82 {
83 assert_equals(segmentInfo.media[0].timecode, 0, 'segment start s at time 0');
84 append_segment(test, sourceBuffer, mediaData, segmentInfo.medi a[0], function()
85 {
86 // timestampOffset should now have been re-adjusted to put media[0] immediately after media[1].
87 // Muxed stream processing causes the offset to not always exactly match expectation based on
88 // segment timecodes, hence allowance of up to 10% deviati on 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.
89 var expected_offset = segmentInfo.media[2].timecode - segm entInfo.media[1].timecode;
90 assert_greater_than(expected_offset, 0, 'media[2] timecode is after media[1] timecode');
91 assert_approx_equals(sourceBuffer.timestampOffset,
92 expected_offset,
93 expected_offset / 10,
94 'timestampOffset adjusted again');
95
96 assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuff er.buffered has 1 range');
97 assert_equals(sourceBuffer.buffered.start(0), 0, 'sourceBu ffer.buffered range begins at time 0');
98
99 // Similarly allow for small variation in resulting length of buffered media.
100 assert_approx_equals(sourceBuffer.buffered.end(0),
101 segmentInfo.media[2].timecode,
102 expected_offset / 10,
acolwell GONE FROM CHROMIUM 2014/05/12 14:00:09 ditto.
wolenetz 2014/05/19 21:20:43 Done.
103 'sourceBuffer.buffered range ends nea r sum of appended segment durations');
104 assert_greater_than(sourceBuffer.buffered.end(0),
105 segmentInfo.media[2].timecode - segmen tInfo.media[1].timecode,
106 'sourceBuffer.buffered range is larger than the duration of the first appended segment');
107 test.done();
108 })
109 });
110 }, 'Test sequence AppendMode appendBuffer(second media segment, then f irst media segment)');
111 </script>
112 </body>
113 </html>
OLDNEW
« 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