Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html |
| index 4fe68e375be9d5fe3a7f937ec0e86e6ac6bbc3ae..a0fc5510617879a2f9c9fa8a74c7fb5dfae84211 100644 |
| --- a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html |
| +++ b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html |
| @@ -2,14 +2,16 @@ |
| <script src=../../resources/testharness.js></script> |
| <script src=../../resources/testharnessreport.js></script> |
| <script> |
| + |
| // This test verifies that MediaRecorder can be created or not with different |
| -// bitrates for video, audio and for both [1]. |
| -// TODO(mcasas): test also the expected allocated values once [2] is closed. |
| +// bitrates for video, audio and for both [1]. The first bunch of tests checks |
| +// that an off-the-limit bitrate causes an exception thrown. The following bunch |
| +// of tests checks a few numerical bitrate allocations, asserting that |
| +// individual bit rates are honored or clamped as expected, and how the overall |
| +// bitsPerSecond is divided into video and audio bitrates. |
| // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#MediaRecorderOptions |
| -// [2] https://github.com/w3c/mediacapture-record/issues/43 |
| - |
| -function makeAsyncTest(options, message) { |
| +function makeTooLargeBitrateAsyncTest(options, message) { |
| return async_test(function(test) { |
| const constraints = {video: true, audio: false}; |
| @@ -35,8 +37,89 @@ function makeAsyncTest(options, message) { |
| }, message); |
| }; |
| -makeAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large'); |
| -makeAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large'); |
| -makeAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large'); |
| +makeTooLargeBitrateAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large'); |
| +makeTooLargeBitrateAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large'); |
| +makeTooLargeBitrateAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large'); |
| + |
| + |
| +function makeExpectedBitrateAsyncTest(options, message, expectedVideoBps, expectedAudioBps) { |
|
philipj_slow
2016/02/03 03:31:04
s/message/name/ or testName (in existing test too)
philipj_slow
2016/02/03 03:31:05
How about making expected a dictionary too, so tha
mcasas
2016/02/03 23:50:26
Done.
mcasas
2016/02/03 23:50:27
Done.
|
| + return async_test(function(test) { |
|
philipj_slow
2016/02/03 03:31:05
No reason to return the test, it'll run anyway.
mcasas
2016/02/03 23:50:26
Done.
|
| + const constraints = {video: true, audio: true}; |
|
philipj_slow
2016/02/03 03:31:04
No tests for when either audio or video are not wa
|
| + |
| + const gotStream = test.step_func(function(stream) { |
| + var recorder; |
| + try { |
| + recorder = new MediaRecorder(stream, options); |
| + } catch (e) { |
| + assert_unreached('Exception while creating MediaRecorder: ' + e); |
|
philipj_slow
2016/02/03 03:31:05
Don't really need this, any exception thrown will
mcasas
2016/02/03 23:50:26
Done.
|
| + } |
| + assert_equals(recorder.videoBitsPerSecond, expectedVideoBps); |
| + assert_equals(recorder.audioBitsPerSecond, expectedAudioBps); |
| + |
| + test.done(); |
| + }); |
| + |
| + const onError = this.step_func(function() { |
|
philipj_slow
2016/02/03 03:31:04
can be simplified to test.unreached_func('Error cr
mcasas
2016/02/03 23:50:26
Nice! Done.
|
| + assert_unreached('Error creating MediaStream.'); |
| + }); |
| + |
| + try { |
| + navigator.webkitGetUserMedia(constraints, gotStream, onError); |
| + } |
| + catch (e) { |
| + assert_unreached('Exception launching getUserMedia(): ' + e); |
|
philipj_slow
2016/02/03 03:31:04
Dito, can drop try catch
mcasas
2016/02/03 23:50:26
More succint, done.
Took the chance and cleaned u
|
| + } |
| + }, message); |
| +}; |
| + |
| +const kTooSmallBps = 1000; |
| +const kTooLargeBps = 1000000000; |
| + |
| +const kOkVideoBps = 500000; |
| +const kMinVideoBps = 100000; |
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps }, |
| + 'Video bitrate OK', |
| + kOkVideoBps, 0); |
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kTooSmallBps }, |
| + 'Video bitrate clamped to minimum', |
| + kMinVideoBps, 0); |
| + |
| +const kOkAudioBps = 10000; |
| +const kMinAudioBps = 6000; // https://www.opus-codec.org/ |
| +const kMaxAudioBps = 128000; |
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps }, |
| + 'Audio bitrate OK', |
| + 0, kOkAudioBps); |
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooSmallBps }, |
| + 'Audio bitrate clamped to minimum', |
| + 0, kMinAudioBps); |
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooLargeBps }, |
| + 'Audio bitrate clamped to maximum', |
| + 0, kMaxAudioBps); |
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, audioBitsPerSecond : kOkAudioBps }, |
| + 'Video and audio bitrates OK', |
| + kOkVideoBps, kOkAudioBps); |
| + |
| +const kOkOverallBps = 120000; |
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : kOkOverallBps }, |
| + 'Overall bitrate OK (divided 90/10 video/audio)', |
| + kOkOverallBps * 0.9, kOkOverallBps * 0.1); |
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, bitsPerSecond : kOkOverallBps }, |
| + 'Overall bitrate OK, w/ explicit video bitrate ignored', |
| + kOkOverallBps * 0.9, kOkOverallBps * 0.1); |
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps, bitsPerSecond : kOkOverallBps }, |
| + 'Overall bitrate OK, w/ explicit audio bitrate ignored', |
| + kOkOverallBps * 0.9, kOkOverallBps * 0.1); |
| + |
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : 10E6 }, |
| + 'Overall bitrate leads to audio clamped to its maximum', |
| + 10E6 - kMaxAudioBps, kMaxAudioBps); |
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : (kMinVideoBps - 1E3) }, |
| + 'Overall bitrate leads to video clamped to its minimum', |
| + kMinVideoBps, (kMinVideoBps - 1E3) * 0.1); |
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : kTooSmallBps }, |
| + 'Overall bitrate leads to both audio and video clamped to min', |
| + kMinVideoBps, kMinAudioBps); |
| + |
| </script> |