| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src=../../resources/testharness.js></script> | 2 <script src=../../resources/testharness.js></script> |
| 3 <script src=../../resources/testharnessreport.js></script> | 3 <script src=../../resources/testharnessreport.js></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 // This test attempts to save and verify MediaStream data in the | 6 // This test attempts to save and verify MediaStream data in the |
| 7 // ondataavailable event handler of MediaRecorder. | 7 // ondataavailable event handler of MediaRecorder. |
| 8 | 8 |
| 9 var checkStreamTracks = function(stream, has_video, has_audio) { | 9 var checkStreamTracks = function(stream, has_video, has_audio) { |
| 10 if (has_video) { | 10 if (has_video) { |
| 11 assert_equals(stream.getVideoTracks().length, 1); | 11 assert_equals(stream.getVideoTracks().length, 1); |
| 12 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); | 12 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); |
| 13 } else { | 13 } else { |
| 14 assert_equals(stream.getVideoTracks().length, 0); | 14 assert_equals(stream.getVideoTracks().length, 0); |
| 15 } | 15 } |
| 16 | 16 |
| 17 if (has_audio) { | 17 if (has_audio) { |
| 18 assert_equals(stream.getAudioTracks().length, 1); | 18 assert_equals(stream.getAudioTracks().length, 1); |
| 19 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); | 19 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); |
| 20 } else { | 20 } else { |
| 21 assert_equals(stream.getAudioTracks().length, 0); | 21 assert_equals(stream.getAudioTracks().length, 0); |
| 22 } | 22 } |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 var makeAsyncTest = function(value, expected) { | 25 var makeAsyncTest = function(value, expected) { |
| 26 var recorder; | 26 var recorder; |
| 27 | 27 |
| 28 async_test(function(test) { | 28 async_test(function(test) { |
| 29 var lastTimestamp = NaN; |
| 29 const recorderOnDataAvailable = this.step_func(function(event) { | 30 const recorderOnDataAvailable = this.step_func(function(event) { |
| 30 // TODO(mcasas): Let the test record for a while. | 31 // TODO(mcasas): Let the test record for a while. |
| 31 // TODO(mcasas): Consider storing recorded data and playing it back. | 32 // TODO(mcasas): Consider storing recorded data and playing it back. |
| 33 if (!isNaN(lastTimestamp)) { |
| 34 assert_greater_than(event.timecode, lastTimestamp, |
| 35 "timecode must be increasing"); |
| 36 } |
| 37 lastTimestamp = event.timecode; |
| 32 | 38 |
| 33 if (recorder.state == "recording") { | 39 if (recorder.state == "recording") { |
| 34 recorder.onstop = recorderOnStopExpected; | 40 recorder.onstop = recorderOnStopExpected; |
| 35 recorder.stop(); | 41 recorder.stop(); |
| 36 } | 42 } |
| 37 }); | 43 }); |
| 38 | 44 |
| 39 const recorderOnStopExpected = this.step_func_done(); | 45 const recorderOnStopExpected = this.step_func_done(); |
| 40 | 46 |
| 41 const recorderOnStopUnexpected = test.unreached_func('Recording stopped.
'); | 47 const recorderOnStopUnexpected = test.unreached_func('Recording stopped.
'); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 navigator.webkitGetUserMedia(value, gotStream, onError); | 66 navigator.webkitGetUserMedia(value, gotStream, onError); |
| 61 }); | 67 }); |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 generate_tests(makeAsyncTest, | 70 generate_tests(makeAsyncTest, |
| 65 [["video-only", {video: true, audio: false}], | 71 [["video-only", {video: true, audio: false}], |
| 66 ["audio-only", {video: false, audio: true}], | 72 ["audio-only", {video: false, audio: true}], |
| 67 ["audio-video", {video: true, audio: true}]]); | 73 ["audio-video", {video: true, audio: true}]]); |
| 68 | 74 |
| 69 </script> | 75 </script> |
| OLD | NEW |