Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src=../../resources/testharness.js></script> | |
| 3 <script src=../../resources/testharnessreport.js></script> | |
| 4 <script> | |
| 5 // This test verifies that MediaRecorder can be created with different Media | |
| 6 // Stream Track combinations: 1 Video Track only, 1 Audio Track only and finally | |
| 7 // a Media Stream with both a Video and an Audio Track. | |
| 8 // Note that recording is _not_ started, for that we would need Mock sources. | |
|
Peter Beverloo
2015/09/16 15:09:01
Is there a bug you could refer to, to clarify that
mcasas
2015/09/16 18:04:15
Hmm the wording was unfortunate. The point I wante
| |
| 9 | |
| 10 function makeAsyncTest(constraints, verifyStream, message) { | |
| 11 return async_test(function(test) { | |
| 12 | |
| 13 gotStream = test.step_func(function(stream) { | |
|
Peter Beverloo
2015/09/16 15:09:01
use "var gotStream" to not place these variables o
mcasas
2015/09/16 18:04:15
Done.
| |
| 14 verifyStream(stream); | |
| 15 | |
| 16 try { | |
| 17 recorder = new MediaRecorder(stream); | |
| 18 } catch (e) { | |
| 19 assert_unreached('Exception while creating MediaRecorder: ' + e) ; | |
| 20 } | |
| 21 assert_equals(recorder.state, "inactive"); | |
| 22 test.done(); | |
| 23 }); | |
| 24 | |
| 25 onError = test.step_func(function() { | |
| 26 assert_unreached('Error creating MediaRecorder.'); | |
| 27 }); | |
| 28 | |
| 29 try { | |
| 30 navigator.webkitGetUserMedia(constraints, gotStream, onError); | |
| 31 } catch(e) { | |
| 32 assert_unreached('Exception launching getUserMedia(): ' + e); | |
| 33 } | |
| 34 }, message); | |
| 35 } | |
| 36 | |
| 37 function verifyVideoOnlyStream(stream) { | |
| 38 assert_equals(stream.getAudioTracks().length, 0); | |
| 39 assert_equals(stream.getVideoTracks().length, 1); | |
| 40 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); | |
| 41 } | |
| 42 function verifyAudioOnlyStream(stream) { | |
| 43 assert_equals(stream.getAudioTracks().length, 1); | |
| 44 assert_equals(stream.getVideoTracks().length, 0); | |
| 45 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); | |
| 46 } | |
| 47 function verifyAudioVideoStream(stream) { | |
| 48 assert_equals(stream.getAudioTracks().length, 1); | |
| 49 assert_equals(stream.getVideoTracks().length, 1); | |
| 50 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); | |
| 51 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); | |
| 52 } | |
| 53 | |
| 54 // Note: webkitGetUserMedia() must be called with at least video or audio true. | |
| 55 makeAsyncTest({video:true}, verifyVideoOnlyStream, 'Video only MediaRecorder'); | |
| 56 makeAsyncTest({audio:true}, verifyAudioOnlyStream, 'Audio only MediaRecorder'); | |
| 57 makeAsyncTest({audio:true, video:true}, verifyAudioVideoStream, 'Video and Audio MediaRecorder'); | |
| 58 | |
| 59 </script> | |
| OLD | NEW |