mediasource-getvideoplaybackquality.html (3546B)
1 <!DOCTYPE html> 2 <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> 3 <html> 4 <head> 5 <title>HTMLVideoElement.getVideoPlaybackQuality() test cases.</title> 6 <meta name="timeout" content="long"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="mediasource-util.js"></script> 10 </head> 11 <body> 12 <div id="log"></div> 13 <script> 14 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) 15 { 16 var previousQuality = mediaElement.getVideoPlaybackQuality(); 17 var timeUpdateCount = 0; 18 mediaElement.addEventListener("timeupdate", test.step_func(function (e) 19 { 20 var videoElement = e.target; 21 var newQuality = videoElement.getVideoPlaybackQuality(); 22 var now = window.performance.now(); 23 24 assert_not_equals(previousQuality, newQuality, 25 "New quality object is different from the previous one"); 26 assert_greater_than(newQuality.creationTime, previousQuality.creationTime, 27 "creationTime increases monotonically"); 28 assert_approx_equals(newQuality.creationTime, now, 100, 29 "creationTime roughly equals current time"); 30 31 assert_greater_than_equal(newQuality.totalVideoFrames, 0, "totalVideoFrames >= 0"); 32 assert_greater_than_equal(newQuality.totalVideoFrames, previousQuality.totalVideoFrames, 33 "totalVideoFrames increases monotonically"); 34 assert_less_than(newQuality.totalVideoFrames, 300, 35 "totalVideoFrames should remain low as duration is less than 10s and framerate less than 30fps"); 36 37 assert_greater_than_equal(newQuality.droppedVideoFrames, 0, "droppedVideoFrames >= 0"); 38 assert_greater_than_equal(newQuality.droppedVideoFrames, previousQuality.droppedVideoFrames, 39 "droppedVideoFrames increases monotonically"); 40 assert_less_than_equal(newQuality.droppedVideoFrames, newQuality.totalVideoFrames, 41 "droppedVideoFrames is only a portion of totalVideoFrames"); 42 43 previousQuality = newQuality; 44 timeUpdateCount++; 45 })); 46 47 mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'")); 48 49 sourceBuffer.appendBuffer(mediaData); 50 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer'); 51 52 test.waitForExpectedEvents(function() 53 { 54 assert_false(sourceBuffer.updating, "updating"); 55 mediaSource.endOfStream(); 56 assert_less_than(mediaSource.duration, 10, "duration"); 57 mediaElement.play().catch(test.unreached_func("Unexpected promise rejection"));; 58 test.expectEvent(mediaElement, 'ended', 'mediaElement'); 59 }); 60 61 test.waitForExpectedEvents(function() 62 { 63 assert_greater_than(timeUpdateCount, 2, "timeUpdateCount"); 64 test.done(); 65 }); 66 }, "Test HTMLVideoElement.getVideoPlaybackQuality() with MediaSource API"); 67 </script> 68 </body> 69 </html>