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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (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
Index: third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html b/third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html
index 7a7e39e2a93c5e6e053d03cb784228c8d7ab0106..f4f1c88a7234e23e0a4c296175cfb77f525543d0 100644
--- a/third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html
+++ b/third_party/WebKit/LayoutTests/webaudio/ChannelMerger/audiochannelmerger-disconnect.html
@@ -1,75 +1,81 @@
<!DOCTYPE html>
<html>
+ <head>
+ <title>
+ audiochannelmerger-disconnect.html
+ </title>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ <script src="../resources/audit-util.js"></script>
+ <script src="../resources/audit.js"></script>
+ </head>
+ <body>
+ <script id="layout-test-code">
+ let renderQuantum = 128;
-<head>
- <script src="../../resources/testharness.js"></script>
- <script src="../../resources/testharnessreport.js"></script>
- <script src="../resources/audit-util.js"></script>
- <script src="../resources/audit.js"></script>
-</head>
+ let numberOfChannels = 2;
+ let sampleRate = 44100;
+ let renderDuration = 0.5;
+ let disconnectTime = 0.5 * renderDuration;
-<body>
- <script>
+ let audit = Audit.createTaskRunner();
- var renderQuantum = 128;
+ // Task: Check if the merger outputs a silent channel when an input is
+ // disconnected.
+ audit.define('silent-disconnect', (task, should) => {
+ let context = new OfflineAudioContext(
+ numberOfChannels, renderDuration * sampleRate, sampleRate);
+ let merger = context.createChannelMerger();
+ let source1 = context.createBufferSource();
+ let source2 = context.createBufferSource();
- var numberOfChannels = 2;
- var sampleRate = 44100;
- var renderDuration = 0.5;
- var disconnectTime = 0.5 * renderDuration;
+ // Create and assign a constant buffer.
+ let bufferDCOffset = createConstantBuffer(context, 1, 1);
+ source1.buffer = source2.buffer = bufferDCOffset;
+ source1.loop = source2.loop = true;
- var audit = Audit.createTaskRunner();
+ // Connect the output of source into the 4th input of merger. The merger
+ // should produce 6 channel output.
+ source1.connect(merger, 0, 0);
+ source2.connect(merger, 0, 1);
+ merger.connect(context.destination);
+ source1.start();
+ source2.start();
- // Task: Check if the merger outputs a silent channel when an input is
- // disconnected.
- audit.define('silent-disconnect', (task, should) => {
- var context = new OfflineAudioContext(numberOfChannels, renderDuration * sampleRate, sampleRate);
- var merger = context.createChannelMerger();
- var source1 = context.createBufferSource();
- var source2 = context.createBufferSource();
-
- // Create and assign a constant buffer.
- var bufferDCOffset = createConstantBuffer(context, 1, 1);
- source1.buffer = source2.buffer = bufferDCOffset;
- source1.loop = source2.loop = true;
-
- // Connect the output of source into the 4th input of merger. The merger
- // should produce 6 channel output.
- source1.connect(merger, 0, 0);
- source2.connect(merger, 0, 1);
- merger.connect(context.destination);
- source1.start();
- source2.start();
-
- // Schedule the disconnection of |source2| at the half of render duration.
- context.suspend(disconnectTime).then(function () {
- source2.disconnect();
- context.resume();
- });
-
- context.startRendering().then(function (buffer) {
- // The entire first channel of the output should be 1.
- should(buffer.getChannelData(0), 'Channel #0').beConstantValueOf(1);
-
- // Calculate the first zero index in the second channel.
- var channel1 = buffer.getChannelData(1);
- var disconnectIndex = disconnectTime * sampleRate;
- disconnectIndex -= (disconnectIndex) % renderQuantum;
- var firstZeroIndex = channel1.findIndex(function (element, index) {
- if (element === 0)
- return index;
+ // Schedule the disconnection of |source2| at the half of render
+ // duration.
+ context.suspend(disconnectTime).then(function() {
+ source2.disconnect();
+ context.resume();
});
- // The second channel should contain 1, and 0 after the disconnection.
- should(channel1, 'Channel #1').containValues([1, 0]);
- should(firstZeroIndex, 'The index of first zero in the channel #1')
- .beEqualTo(disconnectIndex);
+ context.startRendering()
+ .then(function(buffer) {
+ // The entire first channel of the output should be 1.
+ should(buffer.getChannelData(0), 'Channel #0')
+ .beConstantValueOf(1);
- }).then(() => task.done());
- });
+ // Calculate the first zero index in the second channel.
+ let channel1 = buffer.getChannelData(1);
+ let disconnectIndex = disconnectTime * sampleRate;
+ disconnectIndex -= (disconnectIndex) % renderQuantum;
+ let firstZeroIndex = channel1.findIndex(function(element, index) {
+ if (element === 0)
+ return index;
+ });
- audit.run();
- </script>
-</body>
+ // The second channel should contain 1, and 0 after the
+ // disconnection.
+ should(channel1, 'Channel #1').containValues([1, 0]);
+ should(
+ firstZeroIndex, 'The index of first zero in the channel #1')
+ .beEqualTo(disconnectIndex);
+
+ })
+ .then(() => task.done());
+ });
+ audit.run();
+ </script>
+ </body>
</html>

Powered by Google App Engine
This is Rietveld 408576698