Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.html b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1e616fb8bdc6ae1e87b88de7f51d99a603b761cb |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.html |
| @@ -0,0 +1,90 @@ |
| +<!DOCTYPE html> |
| +<script src=../../resources/testharness.js></script> |
| +<script src=../../resources/testharnessreport.js></script> |
| +<script> |
| + |
|
Peter Beverloo
2015/11/20 14:05:02
nit: I realize you're mostly copying this, but cou
ajose
2015/11/20 21:37:06
Done.
|
| +var checkStreamTracks = function(stream, has_video, has_audio) { |
| + if (has_video) { |
| + assert_equals(stream.getVideoTracks().length, 1); |
| + assert_equals(stream.getVideoTracks()[0].readyState, 'live'); |
| + } else { |
| + assert_equals(stream.getVideoTracks().length, 0); |
| + } |
| + |
| + if (has_audio) { |
| + assert_equals(stream.getAudioTracks().length, 1); |
| + assert_equals(stream.getAudioTracks()[0].readyState, 'live'); |
| + } else { |
| + assert_equals(stream.getAudioTracks().length, 0); |
| + } |
| +}; |
| + |
| +var makeAsyncTest = function(value, expected) { |
| + var recorder; |
| + var has_video = value['video'] || false; |
| + var has_audio = value['audio'] || false; |
| + |
| + async_test(function() { |
| + recorderOnDataAvailable = this.step_func(function(event) { |
|
Peter Beverloo
2015/11/20 14:05:02
nit: const recorderOnDataAvailable = ...
(Same fo
ajose
2015/11/20 21:37:06
Neat! I'll have to read more about 'const' and 'le
|
| + if (event) { |
| + assert_greater_than(event.data.size, 0, |
| + 'Recorded data size should be > 0'); |
| + assert_equals(recorder.state, "recording"); |
| + } else { |
| + assert_equals(recorder.state, "inactive"); |
| + } |
| + |
| + // TODO(mcasas): Let the test record for a while. |
| + // TODO(mcasas): Consider storing recorded data and playing it back. |
| + |
| + recorder.onstop = recorderOnStopExpected; |
| + recorder.stop(); |
| + }); |
| + |
| + recorderOnStopExpected = this.step_func_done(); |
| + |
| + recorderOnStopUnexpected = this.step_func(function() { |
| + assert_unreached('Recording stopped.'); |
| + }); |
| + |
| + recorderOnError = this.step_func(function() { |
| + assert_unreached('Recording error.'); |
| + }); |
| + |
| + gotStream = this.step_func_done(function(stream) { |
| + checkStreamTracks(stream, has_video, has_audio) |
| + |
| + try { |
| + recorder = new MediaRecorder(stream); |
| + } catch (e) { |
| + assert_unreached('Exception while creating MediaRecorder: ' |
|
Peter Beverloo
2015/11/20 14:05:02
nit: your preference, but there's no line length l
ajose
2015/11/20 21:37:06
Awesome.
|
| + + e); |
| + } |
| + |
| + assert_equals(recorder.state, "inactive"); |
| + recorder.ondataavailable = recorderOnDataAvailable; |
| + recorder.onstop = recorderOnStopUnexpected; |
| + recorder.onerror = recorderOnError; |
| + recorder.start(); |
| + |
| + assert_equals(recorder.state, "recording"); |
| + }); |
| + |
| + onError = this.step_func(function() { |
| + assert_unreached('Error creating MediaRecorder.'); |
| + }); |
| + |
| + try { |
| + navigator.webkitGetUserMedia(value, gotStream, onError); |
| + } catch(e) { |
| + assert_unreached('Exception launching getUserMedia(): ' + e); |
| + } |
| + }); |
| +}; |
| + |
| +generate_tests(makeAsyncTest, |
| + [["video-only", {video:true}], |
|
Peter Beverloo
2015/11/20 14:05:01
nit: I'd prefer these to be explicit, rather than
ajose
2015/11/20 21:37:06
Done.
|
| + ["audio-only", {audio:true}], |
| + ["audio-video", {video:true, audio:true}]]); |
| + |
| +</script> |