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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.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@ second round of comments 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 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() { 28 async_test(function(test) {
29 const recorderOnDataAvailable = this.step_func(function(event) { 29 const recorderOnDataAvailable = this.step_func(function(event) {
30 if (event) { 30 if (event) {
31 assert_greater_than(event.data.size, 0, 31 assert_greater_than(event.data.size, 0,
32 'Recorded data size should be > 0'); 32 'Recorded data size should be > 0');
33 assert_equals(recorder.state, "recording"); 33 assert_equals(recorder.state, "recording");
34 } else { 34 } else {
35 assert_equals(recorder.state, "inactive"); 35 assert_equals(recorder.state, "inactive");
36 } 36 }
37 37
38 // TODO(mcasas): Let the test record for a while. 38 // TODO(mcasas): Let the test record for a while.
39 // TODO(mcasas): Consider storing recorded data and playing it back. 39 // TODO(mcasas): Consider storing recorded data and playing it back.
40 40
41 recorder.onstop = recorderOnStopExpected; 41 recorder.onstop = recorderOnStopExpected;
42 recorder.stop(); 42 recorder.stop();
43 }); 43 });
44 44
45 const recorderOnStopExpected = this.step_func_done(); 45 const recorderOnStopExpected = this.step_func_done();
46 46
47 const recorderOnStopUnexpected = this.step_func(function() { 47 const recorderOnStopUnexpected = test.unreached_func('Recording stopped. ');
48 assert_unreached('Recording stopped.'); 48 const recorderOnError = test.unreached_func('Recording error.');
49 });
50
51 const recorderOnError = this.step_func(function() {
52 assert_unreached('Recording error.');
53 });
54 49
55 const gotStream = this.step_func_done(function(stream) { 50 const gotStream = this.step_func_done(function(stream) {
56 checkStreamTracks(stream, value['video'], value['audio']); 51 checkStreamTracks(stream, value['video'], value['audio']);
57 52
58 try { 53 recorder = new MediaRecorder(stream);
59 recorder = new MediaRecorder(stream);
60 } catch (e) {
61 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
62 }
63 54
64 assert_equals(recorder.state, "inactive"); 55 assert_equals(recorder.state, "inactive");
65 recorder.ondataavailable = recorderOnDataAvailable; 56 recorder.ondataavailable = recorderOnDataAvailable;
66 recorder.onstop = recorderOnStopUnexpected; 57 recorder.onstop = recorderOnStopUnexpected;
67 recorder.onerror = recorderOnError; 58 recorder.onerror = recorderOnError;
68 recorder.start(); 59 recorder.start();
69 60
70 assert_equals(recorder.state, "recording"); 61 assert_equals(recorder.state, "recording");
71 }); 62 });
72 63
73 const onError = this.step_func(function() { 64 const onError = test.unreached_func('Error creating MediaStream.');
74 assert_unreached('Error creating MediaRecorder.'); 65 navigator.webkitGetUserMedia(value, gotStream, onError);
75 });
76
77 try {
78 navigator.webkitGetUserMedia(value, gotStream, onError);
79 } catch(e) {
80 assert_unreached('Exception launching getUserMedia(): ' + e);
81 }
82 }); 66 });
83 }; 67 };
84 68
85 generate_tests(makeAsyncTest, 69 generate_tests(makeAsyncTest,
86 [["video-only", {video: true, audio: false}], 70 [["video-only", {video: true, audio: false}],
87 ["audio-only", {video: false, audio: true}], 71 ["audio-only", {video: false, audio: true}],
88 ["audio-video", {video: true, audio: true}]]); 72 ["audio-video", {video: true, audio: true}]]);
89 73
90 </script> 74 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698