Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
| index 1979c0413379ec0984a031b41e672f8bf8c1c93d..2e28c8cee4fb889c46680e3ab2cfc459359c6efa 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
| +++ b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
| @@ -5,7 +5,8 @@ |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../resources/audit-util.js"></script> |
| - <script src="../resources/audio-testing.js"></script> |
| + <script src="../resources/audit.js"></script> |
| + <script src="new-audionodeoptions.js"></script> |
| </head> |
| <body> |
| @@ -14,228 +15,174 @@ |
| var audit = Audit.createTaskRunner(); |
| - audit.defineTask("initialize", function (taskDone) { |
| - Should("context = new OfflineAudioContext(...)", function () { |
| - context = new OfflineAudioContext(1, 1, 48000); |
| - }).notThrow(); |
| - |
| - taskDone(); |
| + audit.define('initialize', (task, should) => { |
| + context = initializeContext(should); |
| + task.done(); |
| }); |
| - audit.defineTask("invalid constructor", function (taskDone) { |
| - var node; |
| - var args; |
| - var success = true; |
| - |
| - args = []; |
| - success = Should("new AudioBuffer()", function () { |
| - node = new AudioBuffer(); |
| - }).throw("TypeError"); |
| - success = Should("new AudioBuffer(1)", function () { |
| - node = new AudioBuffer(1) && success; |
| - }).throw("TypeError"); |
| - success = Should("new AudioBuffer(Date, 42)", function () { |
| - node = new AudioBuffer(Date, 42) && success; |
| - }).throw("TypeError"); |
| - |
| - Should("Invalid constructors", success) |
| - .summarize( |
| - "correctly threw errors", |
| - "did not throw errors in all cases"); |
| - |
| - taskDone(); |
| + audit.define('invalid constructor', (task, should) => { |
| + should(() => { |
| + new AudioBuffer(); |
| + }, 'new AudioBuffer()').throw('TypeError'); |
| + should(() => { |
| + new AudioBuffer(1); |
| + }, 'new AudioBuffer(1)').throw('TypeError'); |
| + should(() => { |
| + new AudioBuffer(Date, 42); |
| + }, 'new AudioBuffer(Date, 42)').throw('TypeError'); |
| + |
| + task.done(); |
| }); |
| - audit.defineTask("required options", function (taskDone) { |
| - var success = true; |
| - |
| + audit.define('required options', (task, should) => { |
| var buffer; |
| // The length and sampleRate attributes are required; all others are |
| // optional. |
| - success = Should("buffer = new AudioBuffer({})", function () { |
| - var buffer = new AudioBuffer({}); |
| - }).throw("TypeError"); |
| - |
| - success = Should("buffer = new AudioBuffer({length: 1})", function () { |
| - new AudioBuffer({ |
| - length: 1 |
| - }); |
| - }).throw("TypeError") && success; |
| - |
| - success = Should("buffer = new AudioBuffer({sampleRate: 48000})", |
| - function () { |
| - new AudioBuffer({ |
| - sampleRate: 48000 |
| - }); |
| - }).throw("TypeError") && success; |
| + should(() => { |
| + new AudioBuffer({}); |
| + }, 'buffer = new AudioBuffer({})').throw('TypeError'); |
| - success = Should("buffer = new AudioBuffer({numberOfChannels: 1}", |
| - function () { |
| - buffer = new AudioBuffer({ |
| - numberOfChannels: 1 |
| - }); |
| - }).throw("TypeError") && success; |
| + should(() => { |
| + new AudioBuffer({length: 1}); |
| + }, 'buffer = new AudioBuffer({length: 1})').throw('TypeError'); |
| + |
| + should(() => { |
| + new AudioBuffer({sampleRate: 48000}); |
| + }, 'buffer = new AudioBuffer({sampleRate: 48000})').throw('TypeError'); |
| + |
| + should(() => { |
| + buffer = new AudioBuffer({numberOfChannels: 1}); |
| + }, 'buffer = new AudioBuffer({numberOfChannels: 1}').throw('TypeError'); |
| // Length and sampleRate are required, but others are optional. |
| - success = Should( |
| - "buffer = new AudioBuffer({length: 21, sampleRate: 48000}", |
| - function () { |
| - buffer = new AudioBuffer({ |
| - length: 21, |
| - sampleRate: context.sampleRate |
| - }); |
| - }).notThrow() && success; |
| + should( |
| + () => { |
| + buffer = |
| + new AudioBuffer({length: 21, sampleRate: context.sampleRate}); |
| + }, |
| + 'buffer0 = new AudioBuffer({length: 21, sampleRate: ' + |
| + context.sampleRate + '}') |
| + .notThrow(); |
| // Verify the buffer has the correct values. |
| - success = Should("buffer.numberOfChannels", buffer.numberOfChannels) |
| - .beEqualTo(1) && success; |
| - success = Should("buffer.length", buffer.length) |
| - .beEqualTo(21) && success; |
| - success = Should("buffer.sampleRate", buffer.sampleRate) |
| - .beEqualTo(context.sampleRate) && success; |
| - |
| - success = Should( |
| - "buffer = new AudioBuffer({numberOfChannels: 1, length: 1, sampleRate: 48000}", |
| - function () { |
| - buffer = new AudioBuffer({ |
| - numberOfChannels: 1, |
| - length: 1, |
| - sampleRate: 48000 |
| - }); |
| - }).notThrow() && success; |
| - |
| - Should("Missing option values handled", success) |
| - .summarize("correctly", "incorrectly"); |
| + should(buffer.numberOfChannels, 'buffer0.numberOfChannels').beEqualTo(1); |
| + should(buffer.length, 'buffer0.length').beEqualTo(21); |
| + should(buffer.sampleRate, 'buffer0.sampleRate') |
| + .beEqualTo(context.sampleRate); |
| + |
| + should( |
| + () => { |
| + buffer = new AudioBuffer( |
| + {numberOfChannels: 3, length: 1, sampleRate: 48000}); |
| + }, |
| + 'buffer1 = new AudioBuffer({numberOfChannels: 3, length: 1, sampleRate: 48000}') |
|
hongchan
2017/04/21 20:52:38
Is this clang-formatted?
Raymond Toy
2017/04/21 21:02:04
It was, and I ran it again. No change here.
|
| + .notThrow(); |
| + // Verify the buffer has the correct values. |
| + should(buffer.numberOfChannels, 'buffer1.numberOfChannels').beEqualTo(3); |
| + should(buffer.length, 'buffer1.length').beEqualTo(1); |
| + should(buffer.sampleRate, 'buffer1.sampleRate').beEqualTo(48000); |
| - taskDone(); |
| + task.done(); |
| }); |
| - audit.defineTask("invalid option values", function (taskDone) { |
| - var success = true; |
| - |
| - var options = { |
| - numberOfChannels: 0, |
| - length: 1, |
| - sampleRate: 16000 |
| - }; |
| - success = Should("new AudioBuffer(" + JSON.stringify(options) + ")", function () { |
| - var buffer = new AudioBuffer(options); |
| - }).throw("NotSupportedError"); |
| - |
| - options = { |
| - numberOfChannels: 99, |
| - length: 0, |
| - sampleRate: 16000 |
| - }; |
| - success = Should("new AudioBuffer(" + JSON.stringify(options) + ")", function () { |
| - var buffer = new AudioBuffer(options); |
| - }).throw("NotSupportedError") && success; |
| - |
| - options = { |
| - numberOfChannels: 1, |
| - length: 0, |
| - sampleRate: 16000 |
| - }; |
| - success = Should("new AudioBuffer(" + JSON.stringify(options) + ")", function () { |
| - var buffer = new AudioBuffer(options); |
| - }).throw("NotSupportedError") && success; |
| - |
| - options = { |
| - numberOfChannels: 1, |
| - length: 1, |
| - sampleRate: 100 |
| - }; |
| - success = Should("new AudioBuffer(" + JSON.stringify(options) + ")", function () { |
| - var buffer = new AudioBuffer(options); |
| - }).throw("NotSupportedError") && success; |
| - |
| - Should("Invalid option values handled", success) |
| - .summarize("correctly", "incorrectly"); |
| - |
| - taskDone(); |
| + audit.define('invalid option values', (task, should) => { |
| + var options = {numberOfChannels: 0, length: 1, sampleRate: 16000}; |
| + should( |
| + () => { |
| + var buffer = new AudioBuffer(options); |
| + }, |
| + 'new AudioBuffer(' + JSON.stringify(options) + ')') |
| + .throw('NotSupportedError'); |
| + |
| + options = {numberOfChannels: 99, length: 0, sampleRate: 16000}; |
| + should( |
| + () => { |
| + var buffer = new AudioBuffer(options); |
| + }, |
| + 'new AudioBuffer(' + JSON.stringify(options) + ')') |
| + .throw('NotSupportedError'); |
| + |
| + options = {numberOfChannels: 1, length: 0, sampleRate: 16000}; |
| + should( |
| + () => { |
| + var buffer = new AudioBuffer(options); |
| + }, |
| + 'new AudioBuffer(' + JSON.stringify(options) + ')') |
| + .throw('NotSupportedError'); |
| + |
| + options = {numberOfChannels: 1, length: 1, sampleRate: 100}; |
| + should( |
| + () => { |
| + var buffer = new AudioBuffer(options); |
| + }, |
| + 'new AudioBuffer(' + JSON.stringify(options) + ')') |
| + .throw('NotSupportedError'); |
| + |
| + task.done(); |
| }); |
| - audit.defineTask("default constructor", function (taskDone) { |
| + audit.define('default constructor', (task, should) => { |
| var buffer; |
| - var success = true; |
| - |
| - var options = { |
| - numberOfChannels: 5, |
| - length: 17, |
| - sampleRate: 16000 |
| - }; |
| - success = Should( |
| - "buffer = new AudioBuffer(" + JSON.stringify(options) + ")", |
| - function () { |
| - buffer = new AudioBuffer(options); |
| - }).notThrow(); |
| - |
| - success = Should("buffer.numberOfChannels", buffer.numberOfChannels) |
| - .beEqualTo(options.numberOfChannels) && success; |
| - success = Should("buffer.length", buffer.length) |
| - .beEqualTo(options.length) && success; |
| - success = Should("buffer.sampleRate", buffer.sampleRate) |
| - .beEqualTo(16000) && success; |
| - |
| - Should("Default constructor values set", success) |
| - .summarize("correctly", "incorrectly"); |
| - |
| - taskDone(); |
| + |
| + var options = {numberOfChannels: 5, length: 17, sampleRate: 16000}; |
| + should( |
| + () => { |
| + buffer = new AudioBuffer(options); |
| + }, |
| + 'buffer = new AudioBuffer(' + JSON.stringify(options) + ')') |
| + .notThrow(); |
| + |
| + should(buffer.numberOfChannels, 'buffer.numberOfChannels') |
| + .beEqualTo(options.numberOfChannels); |
| + should(buffer.length, 'buffer.length').beEqualTo(options.length); |
| + should(buffer.sampleRate, 'buffer.sampleRate').beEqualTo(16000); |
| + |
| + task.done(); |
| }); |
| - audit.defineTask("valid constructor", function (taskDone) { |
| + audit.define('valid constructor', (task, should) => { |
| var buffer; |
| - var success = true; |
| - var options = { |
| - numberOfChannels: 3, |
| - length: 42, |
| - sampleRate: 54321 |
| - }; |
| + var options = {numberOfChannels: 3, length: 42, sampleRate: 54321}; |
| - var message = "new AudioBuffer(" + JSON.stringify(options) + ")"; |
| - success = Should(message, function () { |
| + var message = 'new AudioBuffer(' + JSON.stringify(options) + ')'; |
| + should(() => { |
| buffer = new AudioBuffer(options); |
| - }).notThrow(); |
| + }, message).notThrow(); |
| - success = Should("buffer.numberOfChannels", buffer.numberOfChannels) |
| - .beEqualTo(options.numberOfChannels) && success; |
| + should(buffer.numberOfChannels, 'buffer.numberOfChannels') |
| + .beEqualTo(options.numberOfChannels); |
| - success = Should("buffer.length", buffer.length) |
| - .beEqualTo(options.length) && success; |
| + should(buffer.length, 'buffer.length').beEqualTo(options.length); |
| - success = Should("buffer.sampleRate", buffer.sampleRate) |
| - .beEqualTo(options.sampleRate) && success; |
| + should(buffer.sampleRate, 'buffer.sampleRate') |
| + .beEqualTo(options.sampleRate); |
| // Verify that we actually got the right number of channels |
| for (var k = 0; k < options.numberOfChannels; ++k) { |
| var data; |
| - var message = "buffer.getChannelData(" + k + ")"; |
| - success = Should(message, function () { |
| + var message = 'buffer.getChannelData(' + k + ')'; |
| + should(() => { |
| data = buffer.getChannelData(k); |
| - }).notThrow() && success; |
| + }, message).notThrow(); |
| - success = Should(message + " length", data.length) |
| - .beEqualTo(options.length) && success; |
| + should(data.length, message + ' length').beEqualTo(options.length); |
| } |
| - Should("buffer.getChannelData(" + options.numberOfChannels + ")", |
| - function () { |
| - buffer.getChannelData(options.numberOfChannels); |
| - }).throw("IndexSizeError") && success; |
| - |
| - Should("AudioBuffer constructed", success) |
| - .summarize("correctly", "incorrectly"); |
| + should( |
| + () => { |
| + buffer.getChannelData(options.numberOfChannels); |
| + }, |
| + 'buffer.getChannelData(' + options.numberOfChannels + ')') |
| + .throw('IndexSizeError'); |
| - taskDone(); |
| + task.done(); |
| }); |
| - audit.defineTask("multiple contexts", function (taskDone) { |
| + audit.define('multiple contexts', (task, should) => { |
| // Test that an AudioBuffer can be used for different contexts. |
| - var buffer = new AudioBuffer({ |
| - length: 128, |
| - sampleRate: context.sampleRate |
| - }); |
| + var buffer = |
| + new AudioBuffer({length: 128, sampleRate: context.sampleRate}); |
| var data = buffer.getChannelData(0); |
| for (var k = 0; k < data.length; ++k) |
| @@ -245,12 +192,8 @@ |
| var c2 = new OfflineAudioContext(1, 128, context.sampleRate); |
| - var s1 = new AudioBufferSourceNode(c1, { |
| - buffer: buffer |
| - }); |
| - var s2 = new AudioBufferSourceNode(c2, { |
| - buffer: buffer |
| - }); |
| + var s1 = new AudioBufferSourceNode(c1, {buffer: buffer}); |
| + var s2 = new AudioBufferSourceNode(c2, {buffer: buffer}); |
| s1.connect(c1.destination); |
| s2.connect(c2.destination); |
| @@ -261,25 +204,27 @@ |
| var c1Success = false; |
| var c2Success = false; |
| - Promise.all([ |
| - c1.startRendering().then(function (resultBuffer) { |
| - c1Success = Should("c1 result", resultBuffer.getChannelData(0)) |
| - .beEqualToArray(data); |
| - }), |
| - c2.startRendering().then(function (resultBuffer) { |
| - c2Success = Should("c2 result", resultBuffer.getChannelData(0)) |
| - .beEqualToArray(data); |
| - }), |
| - ]) |
| - .then(function () { |
| - Should("AudioBuffer shared between two different contexts", |
| - c1Success && c2Success) |
| - .summarize("correctly", "incorrectly"); |
| - taskDone(); |
| - }); |
| + Promise |
| + .all([ |
| + c1.startRendering().then(function(resultBuffer) { |
| + c1Success = should(resultBuffer.getChannelData(0), 'c1 result') |
| + .beEqualToArray(data); |
|
hongchan
2017/04/21 20:52:38
Return the return value of the assertion here.
Raymond Toy
2017/04/21 21:02:04
Done.
|
| + }), |
| + c2.startRendering().then(function(resultBuffer) { |
| + c2Success = should(resultBuffer.getChannelData(0), 'c2 result') |
| + .beEqualToArray(data); |
| + }), |
| + ]) |
| + .then(() => { |
|
hongchan
2017/04/21 20:52:39
(returnValues => {
should(returnValues[1] && ret
Raymond Toy
2017/04/21 21:02:04
Done.
|
| + should( |
| + c1Success && c2Success, |
| + 'AudioBuffer shared between two different contexts') |
| + .message('correctly', 'incorrectly'); |
| + task.done(); |
| + }); |
| }); |
| - audit.runTasks(); |
| + audit.run(); |
| </script> |
| </body> |
| </html> |