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

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-util.js

Issue 552943002: MSE: Start letting SourceBuffer begin to do initialization segment received algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. Addressed philipj@'s PS5 comments. Created 6 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 unified diff | Download patch
OLDNEW
1 (function(window) { 1 (function(window) {
2 // Set the testharness.js timeout to 120 seconds so that it is higher than 2 // Set the testharness.js timeout to 120 seconds so that it is higher than
3 // the LayoutTest timeout. This prevents testharness.js from prematurely 3 // the LayoutTest timeout. This prevents testharness.js from prematurely
4 // terminating tests and allows the LayoutTest runner to control when to 4 // terminating tests and allows the LayoutTest runner to control when to
5 // timeout the test. 5 // timeout the test.
6 setup({ explicit_timeout: 120000 }); 6 setup({ explicit_timeout: 120000 });
7 7
8 var SEGMENT_INFO_LIST = [ 8 var SEGMENT_INFO_LIST = [
9 { 9 {
10 url: '/media/resources/media-source/webm/test.webm', 10 url: '/media/resources/media-source/webm/test.webm',
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 test.done = function() 318 test.done = function()
319 { 319 {
320 if (test.status == test.PASS) { 320 if (test.status == test.PASS) {
321 assert_false(test.eventExpectations_.expectingEvents(), "No pend ing event expectations."); 321 assert_false(test.eventExpectations_.expectingEvents(), "No pend ing event expectations.");
322 } 322 }
323 oldTestDone(); 323 oldTestDone();
324 }; 324 };
325 }; 325 };
326 326
327 window['MediaSourceUtil'] = MediaSourceUtil; 327 window['MediaSourceUtil'] = MediaSourceUtil;
328 window['media_test'] = function(testFunction, description, options) 328 window['media_test'] = function(testFunction, description, properties)
329 { 329 {
330 options = options || {}; 330 properties = properties || {};
331 return async_test(function(test) 331 return async_test(function(test)
332 { 332 {
333 addExtraTestMethods(test); 333 addExtraTestMethods(test);
334 testFunction(test); 334 testFunction(test);
335 }, description, options); 335 }, description, properties);
336 }; 336 };
337 window['mediasource_test'] = function(testFunction, description, options) 337 window['mediasource_test'] = function(testFunction, description, properties)
338 { 338 {
339 return media_test(function(test) 339 return media_test(function(test)
340 { 340 {
341 var mediaTag = document.createElement("video"); 341 var mediaTag = document.createElement("video");
342 document.body.appendChild(mediaTag); 342 document.body.appendChild(mediaTag);
343 343
344 // Overload done() so that element added to the document can be remo ved. 344 // Overload done() so that element added to the document can be remo ved.
345 test.removeMediaElement_ = true; 345 test.removeMediaElement_ = true;
346 var oldTestDone = test.done.bind(test); 346 var oldTestDone = test.done.bind(test);
347 test.done = function() 347 test.done = function()
348 { 348 {
349 if (test.removeMediaElement_) { 349 if (test.removeMediaElement_) {
350 document.body.removeChild(mediaTag); 350 document.body.removeChild(mediaTag);
351 test.removeMediaElement_ = false; 351 test.removeMediaElement_ = false;
352 } 352 }
353 oldTestDone(); 353 oldTestDone();
354 }; 354 };
355 355
356 openMediaSource_(test, mediaTag, function(mediaSource) 356 openMediaSource_(test, mediaTag, function(mediaSource)
357 { 357 {
358 testFunction(test, mediaTag, mediaSource); 358 testFunction(test, mediaTag, mediaSource);
359 }); 359 });
360 }, description, options); 360 }, description, properties);
361 }; 361 };
362 362
363 window['mediasource_testafterdataloaded'] = function(testFunction, descripti on, options) 363 // In addition to test harness's async_test() properties parameter, this
364 // function recognizes the property allow_media_element_error.
365 window['mediasource_testafterdataloaded'] = function(testFunction, descripti on, properties)
364 { 366 {
365 mediasource_test(function(test, mediaElement, mediaSource) 367 mediasource_test(function(test, mediaElement, mediaSource)
366 { 368 {
367 var segmentInfo = MediaSourceUtil.SEGMENT_INFO; 369 var segmentInfo = MediaSourceUtil.SEGMENT_INFO;
368 370
369 if (!segmentInfo) { 371 if (!segmentInfo) {
370 assert_unreached("No segment info compatible with this MediaSour ce implementation."); 372 assert_unreached("No segment info compatible with this MediaSour ce implementation.");
371 return; 373 return;
372 } 374 }
373 375
374 test.failOnEvent(mediaElement, 'error'); 376 if (properties == null || properties.allow_media_element_error == nu ll || !properties.allow_media_element_error)
377 test.failOnEvent(mediaElement, 'error');
375 378
376 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); 379 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type);
377 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(media Data) 380 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(media Data)
378 { 381 {
379 testFunction(test, mediaElement, mediaSource, segmentInfo, sourc eBuffer, mediaData); 382 testFunction(test, mediaElement, mediaSource, segmentInfo, sourc eBuffer, mediaData);
380 }); 383 });
381 }, description, options); 384 }, description, properties);
382 } 385 };
383 386
384 function timeRangesToString(ranges) 387 function timeRangesToString(ranges)
385 { 388 {
386 var s = "{"; 389 var s = "{";
387 for (var i = 0; i < ranges.length; ++i) { 390 for (var i = 0; i < ranges.length; ++i) {
388 s += " [" + ranges.start(i).toFixed(3) + ", " + ranges.end(i).toFixe d(3) + ")"; 391 s += " [" + ranges.start(i).toFixed(3) + ", " + ranges.end(i).toFixe d(3) + ")";
389 } 392 }
390 return s + " }"; 393 return s + " }";
391 } 394 }
392 395
393 window['assertBufferedEquals'] = function(obj, expected, description) 396 window['assertBufferedEquals'] = function(obj, expected, description)
394 { 397 {
395 var actual = timeRangesToString(obj.buffered); 398 var actual = timeRangesToString(obj.buffered);
396 assert_equals(actual, expected, description); 399 assert_equals(actual, expected, description);
397 }; 400 };
398 401
399 })(window); 402 })(window);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698