Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/audiocontextoptions.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/audiocontextoptions.html b/third_party/WebKit/LayoutTests/webaudio/audiocontextoptions.html |
| index fe5e714bec6aa3949121c1b519bbaaa3264209ae..3d44da1bb6544a34895b747eb2c11a450db27ba5 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/audiocontextoptions.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/audiocontextoptions.html |
| @@ -11,45 +11,77 @@ |
| <script> |
| var context; |
| var audit = Audit.createTaskRunner(); |
| + var defaultLatency; |
| + var interactiveLatency; |
| + var balancedLatency; |
| + var playbackLatency; |
| // Task: test AudioContextOptions (1). |
| audit.defineTask('test-audiocontextoptions-1', function (done) { |
| - |
| // Verify that an AudioContext can be created with default options. |
| Should("context = new AudioContext()", function () { |
| context = new AudioContext(); |
| }).notThrow(); |
| - var defaultLatency = context.baseLatency; |
| + defaultLatency = context.baseLatency; |
| Should("default baseLatency", defaultLatency).beGreaterThan(0); |
| - // Verify that any double can be passed and that it results in interactive latency |
| - Should("context = new AudioContext({'latencyHint': 0.05})", function () { |
| - context = new AudioContext({'latencyHint': 0.05}); |
| - }).notThrow(); |
| - Should("double-constructor baseLatency", context.baseLatency).beEqualTo(defaultLatency); |
| - |
| // Verify that an AudioContext can be created with the expected latency types. |
| Should("context = new AudioContext({'latencyHint': 'interactive'})", function () { |
| context = new AudioContext({'latencyHint': 'interactive'}); |
| }).notThrow(); |
| - var interactiveLatency = context.baseLatency; |
| + interactiveLatency = context.baseLatency; |
| Should("interactive baseLatency", interactiveLatency).beEqualTo(defaultLatency); |
| + context.close(); |
| Should("context = new AudioContext({'latencyHint': 'balanced'})", function () { |
| context = new AudioContext({'latencyHint': 'balanced'}); |
| }).notThrow(); |
| - var balancedLatency = context.baseLatency; |
| + balancedLatency = context.baseLatency; |
| Should("balanced baseLatency", balancedLatency).beGreaterThanOrEqualTo(interactiveLatency); |
| + context.close(); |
| Should("context = new AudioContext({'latencyHint': 'playback'})", function () { |
| context = new AudioContext({'latencyHint': 'playback'}); |
| }).notThrow(); |
| - var playbackLatency = context.baseLatency; |
| + playbackLatency = context.baseLatency; |
| Should("playback baseLatency", playbackLatency).beGreaterThanOrEqualTo(balancedLatency); |
| + context.close(); |
| + |
| + done(); |
| + }); |
| + |
| + // Task: test AudioContextOptions (2). |
|
hongchan
2017/04/11 17:27:37
Nit: please wrap by 80 column. I suggest to apply
Andrew MacPherson
2017/04/12 12:43:41
Neat, I didn't realize that clang-format could be
|
| + audit.defineTask('test-audiocontextoptions-2', function (done) { |
| + // Verify too small exact latency clamped to 'interactive' |
| + Should("context = new AudioContext({'latencyHint': interactiveLatency/2})", function () { |
| + context = new AudioContext({'latencyHint': interactiveLatency/2}); |
|
hongchan
2017/04/11 17:27:37
The try bots do not have an actual audio hardware.
Andrew MacPherson
2017/04/12 12:43:40
I assumed that the layout_test_content_renderer_cl
|
| + }).notThrow(); |
| + Should("double-constructor baseLatency small", context.baseLatency).beEqualTo(interactiveLatency); |
| + context.close(); |
| + |
| + // Verify that exact latency in range works as expected |
| + var validLatency = (interactiveLatency + playbackLatency) / 2; |
| + Should("context = new AudioContext({'latencyHint': validLatency})", function () { |
| + context = new AudioContext({'latencyHint': validLatency}); |
| + }).notThrow(); |
| + Should("double-constructor baseLatency inrange 1", context.baseLatency).beGreaterThanOrEqualTo(interactiveLatency); |
| + Should("double-constructor baseLatency inrange 2", context.baseLatency).beLessThanOrEqualTo(playbackLatency); |
| + context.close(); |
| + |
| + // Verify too big exact latency clamped to some value |
| + var context1; |
| + var context2; |
| + Should("creating two high latency contexts", function () { |
| + context1 = new AudioContext({'latencyHint': playbackLatency*10}); |
| + context2 = new AudioContext({'latencyHint': playbackLatency*20}); |
| + }).notThrow(); |
| + Should("high latency context baseLatency", context1.baseLatency).beEqualTo(context2.baseLatency); |
| + context1.close(); |
| + context2.close(); |
| // Verify that invalid latencyHint values are rejected. |
| Should("context = new AudioContext({'latencyHint': 'foo'})", function () { |