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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html

Issue 2862413003: Convert ScriptProcessorNode tests to us new Audit (Closed)
Patch Set: Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-0-output-channels.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html b/third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html
index fae4932a6f4d0603a8a5ebe4c8deec7d19c715f9..f9c4d4716b3bccfe65065f230d151a09b341c729 100644
--- a/third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html
+++ b/third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessor-offlineaudiocontext.html
@@ -5,91 +5,89 @@
<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>
</head>
<body>
<script>
- var audit = Audit.createTaskRunner();
+ var audit = Audit.createTaskRunner();
- // Fill the output of script processor with a constant value.
- audit.defineTask('simple-output', function (taskDone) {
- var sampleRate = 44100;
- var scriptBufferSize = 256;
- var renderLength = 1;
- var PI = Math.fround(Math.PI);
+ // Fill the output of script processor with a constant value.
+ audit.define('simple-output', (task, should) => {
+ var sampleRate = 44100;
+ var scriptBufferSize = 256;
+ var renderLength = 1;
+ var PI = Math.fround(Math.PI);
- var context = new OfflineAudioContext(
- 1, renderLength * sampleRate, sampleRate);
+ var context =
+ new OfflineAudioContext(1, renderLength * sampleRate, sampleRate);
- var scriptNode = context.createScriptProcessor(scriptBufferSize, 1, 1);
- scriptNode.onaudioprocess = function (event) {
- var outputChannel = event.outputBuffer.getChannelData(0);
- outputChannel.fill(PI);
- };
- scriptNode.connect(context.destination);
+ var scriptNode = context.createScriptProcessor(scriptBufferSize, 1, 1);
+ scriptNode.onaudioprocess = function(event) {
+ var outputChannel = event.outputBuffer.getChannelData(0);
+ outputChannel.fill(PI);
+ };
+ scriptNode.connect(context.destination);
- context.startRendering().then(function (buffer) {
- var channel = buffer.getChannelData(0);
- var initialDelay = channel.subarray(0, 2 * scriptBufferSize);
- var actualContent = channel.subarray(2 * scriptBufferSize);
+ context.startRendering().then(function(buffer) {
+ var channel = buffer.getChannelData(0);
+ var initialDelay = channel.subarray(0, 2 * scriptBufferSize);
+ var actualContent = channel.subarray(2 * scriptBufferSize);
- // There is the initial delay (2 x buffer size) which is silent.
- Should('The initial delay contains zeros.', initialDelay)
- .beConstantValueOf(0);
+ // There is the initial delay (2 x buffer size) which is silent.
+ should(initialDelay, 'The initial delay contains zeros.')
+ .beConstantValueOf(0);
- // After the initial delay, we must get |PI|.
- Should('The actual content contains ' + PI, actualContent)
- .beConstantValueOf(PI);
+ // After the initial delay, we must get |PI|.
+ should(actualContent, 'The actual content contains ' + PI)
+ .beConstantValueOf(PI);
- taskDone();
+ task.done();
+ });
});
- });
-
-
- // Pass through an oscillator via a script processor. Sum with the
- // phase-inverted oscillator with the delayed start time. Verify the
- // rendered buffer is completely silent.
- audit.defineTask('oscillator-output', function (taskDone) {
- var sampleRate = 44100;
- var scriptBufferSize = 256;
- var renderLength = 1;
-
- var context = new OfflineAudioContext(
- 1, renderLength * sampleRate, sampleRate);
-
- var osc1 = context.createOscillator();
- var osc2 = context.createOscillator();
- var inverter = context.createGain();
- var scriptNode = context.createScriptProcessor(scriptBufferSize, 1, 1);
- scriptNode.onaudioprocess = function (event) {
- var inputChannel = event.inputBuffer.getChannelData(0);
- var outputChannel = event.outputBuffer.getChannelData(0);
- outputChannel.set(inputChannel);
- };
-
- inverter.gain.value = -1;
-
- osc1.connect(inverter).connect(context.destination);
- osc2.connect(scriptNode).connect(context.destination);
-
- // The delayed start for |osc1|.
- osc1.start((2 * scriptBufferSize) / sampleRate);
- osc2.start();
-
- context.startRendering().then(function (buffer) {
- var channel = buffer.getChannelData(0);
-
- // The rendered buffer must be silent.
- Should('The rendered buffer', channel)
- .beConstantValueOf(0);
-
- taskDone();
- });
- });
- audit.runTasks();
+ // Pass through an oscillator via a script processor. Sum with the
+ // phase-inverted oscillator with the delayed start time. Verify the
+ // rendered buffer is completely silent.
+ audit.define('oscillator-output', (task, should) => {
+ var sampleRate = 44100;
+ var scriptBufferSize = 256;
+ var renderLength = 1;
+
+ var context =
+ new OfflineAudioContext(1, renderLength * sampleRate, sampleRate);
+
+ var osc1 = context.createOscillator();
+ var osc2 = context.createOscillator();
+ var inverter = context.createGain();
+ var scriptNode = context.createScriptProcessor(scriptBufferSize, 1, 1);
+ scriptNode.onaudioprocess = function(event) {
+ var inputChannel = event.inputBuffer.getChannelData(0);
+ var outputChannel = event.outputBuffer.getChannelData(0);
+ outputChannel.set(inputChannel);
+ };
+
+ inverter.gain.value = -1;
+
+ osc1.connect(inverter).connect(context.destination);
+ osc2.connect(scriptNode).connect(context.destination);
+
+ // The delayed start for |osc1|.
+ osc1.start((2 * scriptBufferSize) / sampleRate);
+ osc2.start();
+
+ context.startRendering().then(function(buffer) {
+ var channel = buffer.getChannelData(0);
+
+ // The rendered buffer must be silent.
+ should(channel, 'The rendered buffer').beConstantValueOf(0);
+
+ task.done();
+ });
+ });
+
+ audit.run();
</script>
</body>
</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-0-output-channels.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698