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

Side by Side 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 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
(Empty)
1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script>
4 <script>
5
6 // This test attempts to save and verify MediaStream data in the
7 // ondataavailable event handler of MediaRecorder.
8
9 var checkStreamTracks = function(stream, has_video, has_audio) {
10 if (has_video) {
11 assert_equals(stream.getVideoTracks().length, 1);
12 assert_equals(stream.getVideoTracks()[0].readyState, 'live');
13 } else {
14 assert_equals(stream.getVideoTracks().length, 0);
15 }
16
17 if (has_audio) {
18 assert_equals(stream.getAudioTracks().length, 1);
19 assert_equals(stream.getAudioTracks()[0].readyState, 'live');
20 } else {
21 assert_equals(stream.getAudioTracks().length, 0);
22 }
23 };
24
25 var makeAsyncTest = function(value, expected) {
26 var recorder;
27
28 async_test(function() {
29 const recorderOnDataAvailable = this.step_func(function(event) {
30 if (event) {
31 assert_greater_than(event.data.size, 0,
32 'Recorded data size should be > 0');
33 assert_equals(recorder.state, "recording");
34 } else {
35 assert_equals(recorder.state, "inactive");
36 }
37
38 // TODO(mcasas): Let the test record for a while.
39 // TODO(mcasas): Consider storing recorded data and playing it back.
40
41 recorder.onstop = recorderOnStopExpected;
42 recorder.stop();
43 });
44
45 const recorderOnStopExpected = this.step_func_done();
46
47 const recorderOnStopUnexpected = this.step_func(function() {
48 assert_unreached('Recording stopped.');
49 });
50
51 const recorderOnError = this.step_func(function() {
52 assert_unreached('Recording error.');
53 });
54
55 const gotStream = this.step_func_done(function(stream) {
56 checkStreamTracks(stream, value['video'], value['audio']);
57
58 try {
59 recorder = new MediaRecorder(stream);
60 } catch (e) {
61 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
62 }
63
64 assert_equals(recorder.state, "inactive");
65 recorder.ondataavailable = recorderOnDataAvailable;
66 recorder.onstop = recorderOnStopUnexpected;
67 recorder.onerror = recorderOnError;
68 recorder.start();
69
70 assert_equals(recorder.state, "recording");
71 });
72
73 const onError = this.step_func(function() {
74 assert_unreached('Error creating MediaRecorder.');
75 });
76
77 try {
78 navigator.webkitGetUserMedia(value, gotStream, onError);
79 } catch(e) {
80 assert_unreached('Exception launching getUserMedia(): ' + e);
81 }
82 });
83 };
84
85 generate_tests(makeAsyncTest,
86 [["video-only", {video: true, audio: false}],
87 ["audio-only", {video: false, audio: true}],
88 ["audio-video", {video: true, audio: true}]]);
89
90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698