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

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

Issue 1448203002: Add layout tests for the audio component of MediaStream Recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter@'s comments Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var test = async_test('checks requestData() for video-only MediaRecorder API.'); 6 // This test verifies we can successfully create a MediaRecorder and
7 var recorder; 7 // get data from a MediaStream with it.
8 8
9 recorderOnDataAvailable = test.step_func(function(event) { 9 var checkStreamTracks = function(stream, has_video, has_audio) {
10 assert_equals(event.data.size, 0, 'Recorded data size should be == 0'); 10 if (has_video) {
11 test.done(); 11 assert_equals(stream.getVideoTracks().length, 1);
12 }); 12 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
13 13 } else {
14 recorderOnStop = test.step_func(function() { 14 assert_equals(stream.getVideoTracks().length, 0);
15 assert_unreached('Recording stopped.');
16 });
17
18 recorderOnError = test.step_func(function() {
19 assert_unreached('Recording error.');
20 });
21
22 gotStream = test.step_func(function(stream) {
23 assert_equals(stream.getAudioTracks().length, 0);
24 assert_equals(stream.getVideoTracks().length, 1);
25 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
26
27 try {
28 recorder = new MediaRecorder(stream);
29 } catch (e) {
30 assert_unreached('Exception while creating MediaRecorder: ' + e);
31 }
32 assert_equals(recorder.state, "inactive");
33
34 try {
35 recorder.requestData();
36 assert_unreached();
37 } catch (e) {
38 assert_equals(e.name, "InvalidStateError");
39 } 15 }
40 16
41 recorder.ondataavailable = recorderOnDataAvailable; 17 if (has_audio) {
42 recorder.onstop = recorderOnStop; 18 assert_equals(stream.getAudioTracks().length, 1);
43 recorder.onerror = recorderOnError; 19 assert_equals(stream.getAudioTracks()[0].readyState, 'live');
44 recorder.start(); 20 } else {
21 assert_equals(stream.getAudioTracks().length, 0);
22 }
23 };
45 24
46 assert_equals(recorder.state, "recording"); 25 var makeAsyncTest = function(value, expected) {
47 recorder.requestData(); 26 var recorder;
48 });
49 27
50 onError = test.step_func(function() { 28 async_test(function() {
51 assert_unreached('Error creating MediaRecorder.'); 29 const recorderOnDataAvailable = this.step_func_done(function(event) {
52 }); 30 assert_equals(event.data.size, 0,
31 'Recorded data size should be == 0');
32 });
53 33
54 try { 34 const recorderOnStop = this.step_func(function() {
55 navigator.webkitGetUserMedia({video:true}, gotStream, onError); 35 assert_unreached('Recording stopped.');
56 } catch(e) { 36 });
57 assert_unreached('Exception launching getUserMedia(): ' + e); 37
58 } 38 const recorderOnError = this.step_func(function() {
39 assert_unreached('Recording error.');
40 });
41
42 const gotStream = this.step_func_done(function(stream) {
43 checkStreamTracks(stream, value['video'], value['audio']);
44
45 try {
46 recorder = new MediaRecorder(stream);
47 } catch (e) {
48 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
49 }
50
51 try {
52 recorder.requestData();
53 assert_unreached();
54 } catch (e) {
55 assert_equals(e.name, "InvalidStateError");
56 }
57
58 recorder.ondataavailable = recorderOnDataAvailable;
59 recorder.onstop = recorderOnStop;
60 recorder.onerror = recorderOnError;
61 recorder.start();
62
63 assert_equals(recorder.state, "recording");
64 recorder.requestData();
65 });
66
67 const onError = this.step_func(function() {
68 assert_unreached('Error creating MediaRecorder.');
69 });
70
71 try {
72 navigator.webkitGetUserMedia(value, gotStream, onError);
73 } catch(e) {
74 assert_unreached('Exception launching getUserMedia(): ' + e);
75 }
76 });
77 };
78
79 generate_tests(makeAsyncTest,
80 [["video-only", {video: true, audio: false}],
81 ["audio-only", {video: false, audio: true}],
82 ["audio-video", {video: true, audio: true}]]);
59 83
60 </script> 84 </script>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698