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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-requestData.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@opera.com 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 verifies we can successfully create a MediaRecorder and 6 // This test verifies we can successfully create a MediaRecorder and
7 // get data from a MediaStream with it. 7 // get data from a MediaStream with it.
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 async_test(function(test) {
philipj_slow 2016/02/04 03:03:10 Using this as you had done is fine too, IMHO, but
mcasas 2016/02/05 02:39:14 Yeah, it was a homogenisation.
27 27 const recorderOnDataAvailable = test.step_func_done(function(event) {
28 async_test(function() {
29 const recorderOnDataAvailable = this.step_func_done(function(event) {
30 assert_equals(event.data.size, 0, 28 assert_equals(event.data.size, 0,
31 'Recorded data size should be == 0'); 29 'Recorded data size should be == 0');
32 }); 30 });
33 31
34 const recorderOnStop = this.step_func(function() { 32 const recorderOnStop = test.step_func(function() {
35 assert_unreached('Recording stopped.'); 33 assert_unreached('Recording stopped.');
36 }); 34 });
37 35
38 const recorderOnError = this.step_func(function() { 36 const recorderOnError = test.step_func(function() {
39 assert_unreached('Recording error.'); 37 assert_unreached('Recording error.');
40 }); 38 });
41 39
42 const gotStream = this.step_func_done(function(stream) { 40 const gotStream = test.step_func_done(function(stream) {
43 checkStreamTracks(stream, value['video'], value['audio']); 41 checkStreamTracks(stream, value['video'], value['audio']);
44 42
45 try { 43 var recorder = new MediaRecorder(stream);
46 recorder = new MediaRecorder(stream);
47 } catch (e) {
48 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
49 }
50 44
51 try { 45 assert_throws("InvalidStateError",
52 recorder.requestData(); 46 function() {
53 assert_unreached(); 47 recorder.requestData();
54 } catch (e) { 48 },
55 assert_equals(e.name, "InvalidStateError"); 49 "recorder throws InvalidStateError if requestData() comes in inv alid state");
philipj_slow 2016/02/04 03:03:10 Maybe s/comes in invalid state/while state is not
mcasas 2016/02/05 02:39:14 Done.
56 }
57 50
58 recorder.ondataavailable = recorderOnDataAvailable; 51 recorder.ondataavailable = recorderOnDataAvailable;
59 recorder.onstop = recorderOnStop; 52 recorder.onstop = recorderOnStop;
60 recorder.onerror = recorderOnError; 53 recorder.onerror = recorderOnError;
61 recorder.start(); 54 recorder.start();
62 55
63 assert_equals(recorder.state, "recording"); 56 assert_equals(recorder.state, "recording");
64 recorder.requestData(); 57 recorder.requestData();
65 }); 58 });
66 59
67 const onError = this.step_func(function() { 60 const onError = test.unreached_func('Error creating MediaStream.');
68 assert_unreached('Error creating MediaRecorder.'); 61 navigator.webkitGetUserMedia(value, gotStream, onError);
69 });
70
71 try {
72 navigator.webkitGetUserMedia(value, gotStream, onError);
73 } catch(e) {
74 assert_unreached('Exception launching getUserMedia(): ' + e);
75 }
76 }); 62 });
77 }; 63 };
78 64
79 generate_tests(makeAsyncTest, 65 generate_tests(makeAsyncTest,
80 [["video-only", {video: true, audio: false}], 66 [["video-only", {video: true, audio: false}],
81 ["audio-only", {video: false, audio: true}], 67 ["audio-only", {video: false, audio: true}],
82 ["audio-video", {video: true, audio: true}]]); 68 ["audio-video", {video: true, audio: true}]]);
83 69
84 </script> 70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698