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

Unified Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-audio-video.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 side-by-side diff with in-line comments
Download patch
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..d65727c9da679f684e5b7d08f0a52e102ab152a0
--- /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>
+
+// This test attempts to save and verify MediaStream data in the
+// ondataavailable event handler of MediaRecorder.
+
+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;
+
+ async_test(function() {
+ const recorderOnDataAvailable = this.step_func(function(event) {
+ 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();
+ });
+
+ const recorderOnStopExpected = this.step_func_done();
+
+ const recorderOnStopUnexpected = this.step_func(function() {
+ assert_unreached('Recording stopped.');
+ });
+
+ const recorderOnError = this.step_func(function() {
+ assert_unreached('Recording error.');
+ });
+
+ const gotStream = this.step_func_done(function(stream) {
+ checkStreamTracks(stream, value['video'], value['audio']);
+
+ try {
+ recorder = new MediaRecorder(stream);
+ } catch (e) {
+ assert_unreached('Exception while creating MediaRecorder: ' + e);
+ }
+
+ assert_equals(recorder.state, "inactive");
+ recorder.ondataavailable = recorderOnDataAvailable;
+ recorder.onstop = recorderOnStopUnexpected;
+ recorder.onerror = recorderOnError;
+ recorder.start();
+
+ assert_equals(recorder.state, "recording");
+ });
+
+ const 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, audio: false}],
+ ["audio-only", {video: false, audio: true}],
+ ["audio-video", {video: true, audio: true}]]);
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698