Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Test AudioContextOptions</title> | |
| 5 <script src="../resources/testharness.js"></script> | |
| 6 <script src="../resources/testharnessreport.js"></script> | |
| 7 <script src="resources/audio-testing.js"></script> | |
| 8 </head> | |
| 9 | |
| 10 <body> | |
| 11 <script> | |
| 12 var context; | |
| 13 var audit = Audit.createTaskRunner(); | |
| 14 | |
| 15 // Task: test AudioContextOptions (1). | |
| 16 audit.defineTask('test-audiocontextoptions-1', function (done) { | |
| 17 | |
| 18 // Verify that an AudioContext can be created with default options. | |
| 19 Should("context = new AudioContext()", function () { | |
| 20 context = new AudioContext(); | |
| 21 }).notThrow(); | |
| 22 | |
| 23 var defaultLatency = context.baseLatency; | |
| 24 Should("default baseLatency", defaultLatency).beGreaterThan(0); | |
| 25 | |
| 26 // Verify that any double can be passed and that it results in interactive latency | |
| 27 Should("context = new AudioContext({'latencyHint': 0.05})", function () { | |
| 28 context = new AudioContext({'latencyHint': 0.05}); | |
| 29 }).notThrow(); | |
| 30 Should("double-constructor baseLatency", context.baseLatency).beEqualTo(de faultLatency); | |
| 31 | |
| 32 // Verify that an AudioContext can be created with the expected latency ty pes. | |
| 33 Should("context = new AudioContext({'latencyHint': 'interactive'})", funct ion () { | |
| 34 context = new AudioContext({'latencyHint': 'interactive'}); | |
| 35 }).notThrow(); | |
| 36 | |
| 37 var interactiveLatency = context.baseLatency; | |
| 38 Should("interactive baseLatency", interactiveLatency).beEqualTo(defaultLat ency); | |
| 39 | |
| 40 Should("context = new AudioContext({'latencyHint': 'balanced'})", function () { | |
| 41 context = new AudioContext({'latencyHint': 'balanced'}); | |
| 42 }).notThrow(); | |
| 43 | |
| 44 var balancedLatency = context.baseLatency; | |
| 45 Should("balanced baseLatency", balancedLatency).beGreaterThanOrEqualTo(int eractiveLatency); | |
| 46 | |
| 47 Should("context = new AudioContext({'latencyHint': 'playback'})", function () { | |
| 48 context = new AudioContext({'latencyHint': 'playback'}); | |
| 49 }).notThrow(); | |
| 50 | |
| 51 var playbackLatency = context.baseLatency; | |
| 52 Should("playback baseLatency", playbackLatency).beGreaterThanOrEqualTo(bal ancedLatency); | |
| 53 | |
| 54 // Verify that invalid latencyHint values are rejected. | |
| 55 Should("context = new AudioContext({'latencyHint': 'foo'})", function () { | |
| 56 context = new AudioContext({'latencyHint': 'foo'}); | |
| 57 }).throw(); | |
|
Raymond Toy
2016/12/08 17:14:38
Include the type of error thrown in "throw()".
Andrew MacPherson
2016/12/09 12:34:14
Done.
| |
| 58 | |
| 59 // Verify that no extra options can be passed into the AudioContextOptions . | |
| 60 Should("context = new AudioContext('latencyHint')", function () { | |
| 61 context = new AudioContext('latencyHint'); | |
| 62 }).throw(); | |
|
Raymond Toy
2016/12/08 17:14:38
Include the type of error thrown.
Andrew MacPherson
2016/12/09 12:34:14
Done.
| |
| 63 | |
| 64 done(); | |
| 65 }); | |
| 66 | |
| 67 audit.runTasks(); | |
| 68 </script> | |
| 69 </body> | |
| 70 </html> | |
| OLD | NEW |