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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-creation.html

Issue 1652373004: MediaRecorder: add and wire read {video,audio}BitsPerSecond props (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: philipj@ nits Created 4 years, 10 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 <!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 // This test verifies that MediaRecorder can be created with different Media 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 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. Note that recording is 7 // a Media Stream with both a Video and an Audio Track. Note that recording is
8 // _not_ started in this test, see MediaRecorder-basic-video.html for it. 8 // _not_ started in this test, see MediaRecorder-basic-video.html for it.
9 9
10 function makeAsyncTest(constraints, verifyStream, message) { 10 function makeAsyncTest(constraints, verifyStream, message) {
11 return async_test(function(test) { 11 async_test(function(test) {
12 12
13 var gotStream = test.step_func(function(stream) { 13 const gotStream = test.step_func(function(stream) {
14 verifyStream(stream); 14 verifyStream(stream);
15 15
16 try { 16 var recorder = new MediaRecorder(stream);
17 recorder = new MediaRecorder(stream);
18 } catch (e) {
19 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
20 }
21 assert_equals(recorder.state, "inactive"); 17 assert_equals(recorder.state, "inactive");
18 assert_equals(recorder.videoBitsPerSecond, 0);
19 assert_equals(recorder.audioBitsPerSecond, 0);
22 test.done(); 20 test.done();
23 }); 21 });
24 22
25 var onError = test.step_func(function() { 23 const onError = test.unreached_func('Error creating MediaStream.');
26 assert_unreached('Error creating MediaRecorder.'); 24 navigator.webkitGetUserMedia(constraints, gotStream, onError);
27 });
28
29 try {
30 navigator.webkitGetUserMedia(constraints, gotStream, onError);
31 } catch(e) {
32 assert_unreached('Exception launching getUserMedia(): ' + e);
33 }
34 }, message); 25 }, message);
35 } 26 }
36 27
37 function verifyVideoOnlyStream(stream) { 28 function verifyVideoOnlyStream(stream) {
38 assert_equals(stream.getAudioTracks().length, 0); 29 assert_equals(stream.getAudioTracks().length, 0);
39 assert_equals(stream.getVideoTracks().length, 1); 30 assert_equals(stream.getVideoTracks().length, 1);
40 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); 31 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
41 } 32 }
42 function verifyAudioOnlyStream(stream) { 33 function verifyAudioOnlyStream(stream) {
43 assert_equals(stream.getAudioTracks().length, 1); 34 assert_equals(stream.getAudioTracks().length, 1);
44 assert_equals(stream.getVideoTracks().length, 0); 35 assert_equals(stream.getVideoTracks().length, 0);
45 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); 36 assert_equals(stream.getAudioTracks()[0].readyState, 'live');
46 } 37 }
47 function verifyAudioVideoStream(stream) { 38 function verifyAudioVideoStream(stream) {
48 assert_equals(stream.getAudioTracks().length, 1); 39 assert_equals(stream.getAudioTracks().length, 1);
49 assert_equals(stream.getVideoTracks().length, 1); 40 assert_equals(stream.getVideoTracks().length, 1);
50 assert_equals(stream.getVideoTracks()[0].readyState, 'live'); 41 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
51 assert_equals(stream.getAudioTracks()[0].readyState, 'live'); 42 assert_equals(stream.getAudioTracks()[0].readyState, 'live');
52 } 43 }
53 44
54 // Note: webkitGetUserMedia() must be called with at least video or audio true. 45 // Note: webkitGetUserMedia() must be called with at least video or audio true.
55 makeAsyncTest({video:true}, verifyVideoOnlyStream, 'Video only MediaRecorder'); 46 makeAsyncTest({video:true}, verifyVideoOnlyStream, 'Video only MediaRecorder');
56 makeAsyncTest({audio:true}, verifyAudioOnlyStream, 'Audio only MediaRecorder'); 47 makeAsyncTest({audio:true}, verifyAudioOnlyStream, 'Audio only MediaRecorder');
57 makeAsyncTest({audio:true, video:true}, verifyAudioVideoStream, 'Video and Audio MediaRecorder'); 48 makeAsyncTest({audio:true, video:true}, verifyAudioVideoStream, 'Video and Audio MediaRecorder');
58 49
59 </script> 50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698