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

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: s/approx_equals/ time bounds, plus some explicit equals where possible 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(); });
acolwell GONE FROM CHROMIUM 2014/05/19 22:12:49 You can just use test.waitForExpectedEvents(callba
wolenetz 2014/05/19 22:23:03 Done.
42 }
43
44 function threeDecimalPlaces(number)
45 {
46 return Number(number.toFixed(3));
acolwell GONE FROM CHROMIUM 2014/05/19 22:12:49 Why do you need the Number()?
wolenetz 2014/05/19 22:23:03 By example: var a = 3.14159265; a.toFixed(3) == "3
47 }
48
49 // Verifies expected times to 3 decimal places before and after mediaS ource.endOfStream(),
50 // and calls |callback| on success.
51 function verify_offset_and_buffered(test, mediaSource, sourceBuffer,
52 expectedTimestampOffset, expectedB ufferedRangeStartTime,
53 expectedBufferedRangeMaxEndTimeBef oreEOS,
54 expectedBufferedRangeEndTimeAfterE OS,
55 callback) {
56 assert_equals(threeDecimalPlaces(sourceBuffer.timestampOffset),
57 threeDecimalPlaces(expectedTimestampOffset),
58 'expectedTimestampOffset');
59
60 // Prior to EOS, the buffered range end time may not have fully re ached the next media
61 // segment's timecode (adjusted by any timestampOffset). It should not exceed it though.
62 // Therefore, an exact assertBufferedEquals() will not work here.
63 assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.buffe red has 1 range before EOS');
64 assert_equals(threeDecimalPlaces(sourceBuffer.buffered.start(0)),
65 threeDecimalPlaces(expectedBufferedRangeStartTime),
66 'sourceBuffer.buffered range begins where expected b efore EOS');
67 assert_less_than_equal(threeDecimalPlaces(sourceBuffer.buffered.en d(0)),
68 threeDecimalPlaces(expectedBufferedRangeMax EndTimeBeforeEOS),
69 'sourceBuffer.buffered range ends at or bef ore expected upper bound before EOS');
70
71 test.expectEvent(mediaSource, 'sourceended', 'mediaSource endOfStr eam');
72 mediaSource.endOfStream();
73 test.waitForExpectedEvents(function()
74 {
75 assertBufferedEquals(sourceBuffer,
76 '{ [' + expectedBufferedRangeStartTime.to Fixed(3) + ', ' + expectedBufferedRangeEndTimeAfterEOS.toFixed(3) + ') }',
77 'sourceBuffer.buffered after EOS');
78 callback();
79 });
80 }
81
82 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
83 {
84 assert_equals(segmentInfo.media[0].timecode, 0, 'segment starts at time 0');
85 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[0] , function()
86 {
87 verify_offset_and_buffered(test, mediaSource, sourceBuffer,
88 0, 0,
89 segmentInfo.media[1].timecode /* + timestampOffset of 0 */,
acolwell GONE FROM CHROMIUM 2014/05/19 22:12:49 nit: Remove the comments. I think they are more co
wolenetz 2014/05/19 22:23:03 Done.
90 segmentInfo.media[0].highest_end_ti me /* + timestampOffset of 0 */,
91 test.done);
92 });
93 }, 'Test sequence AppendMode appendBuffer(first media segment)');
94
95 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
96 {
97 assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment sta rts after time 0');
98 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1] , function()
99 {
100 verify_offset_and_buffered(test, mediaSource, sourceBuffer,
101 -segmentInfo.media[1].timecode, 0,
102 segmentInfo.media[2].timecode + sou rceBuffer.timestampOffset,
103 segmentInfo.media[1].highest_end_ti me + sourceBuffer.timestampOffset,
104 test.done);
105 });
106 }, 'Test sequence AppendMode appendBuffer(second media segment)');
107
108 mediasource_sequencemode_test(function(test, mediaElement, mediaSource , segmentInfo, sourceBuffer, mediaData)
109 {
110 assert_greater_than(segmentInfo.media[1].timecode, 0, 'segment sta rts after time 0');
111 append_segment(test, sourceBuffer, mediaData, segmentInfo.media[1] , function()
112 {
113 assert_equals(segmentInfo.media[0].timecode, 0, 'segment start s at time 0');
114 append_segment(test, sourceBuffer, mediaData, segmentInfo.medi a[0], function()
115 {
116 // Current timestampOffset should reflect offset required to put media[0]
117 // immediately after media[1]'s highest frame end timestam p (as was adjusted
118 // by an earlier timestampOffset).
119 verify_offset_and_buffered(test, mediaSource, sourceBuffer ,
120 segmentInfo.media[1].highest_en d_time - segmentInfo.media[1].timecode, 0,
121 segmentInfo.media[1].timecode + sourceBuffer.timestampOffset,
122 segmentInfo.media[0].highest_en d_time + sourceBuffer.timestampOffset,
123 test.done);
124 })
125 });
126 }, 'Test sequence AppendMode appendBuffer(second media segment, then f irst media segment)');
127 </script>
128 </body>
129 </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