Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,152 @@
<!DOCTYPE html>
<html class="a">
<head>
<title>GainNode IDL Test</title>
<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script><script src="/resources/idlharness.js"></script><script src="/resources/webidl2/lib/webidl2.js"></script><script src="/webaudio/js/lodash.js"></script><script src="/webaudio/js/vendor-prefixes.js"></script><script src="/webaudio/js/helpers.js"></script><style type="text/css">
#event-target-idl,
#audio-context-idl,
#audio-node-idl,
#audio-param-idl
{ visibility:hidden; height: 0px;}
</style>
</head>
<body class="a">
<pre id="event-target-idl">interface EventTarget {
void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
boolean dispatchEvent(Event event);
};
/*
callback interface EventListener {
void handleEvent(Event event);
};
*/
// Callback interfaces are not supported yet, but that's ok
interface EventListener {};
</pre>
<pre id="audio-context-idl">callback DecodeSuccessCallback = void (AudioBuffer decodedData);
callback DecodeErrorCallback = void ();
[Constructor]
interface AudioContext : EventTarget {
readonly attribute AudioDestinationNode destination;
readonly attribute float sampleRate;
readonly attribute double currentTime;
readonly attribute AudioListener listener;
AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);
void decodeAudioData(ArrayBuffer audioData,
DecodeSuccessCallback successCallback,
optional DecodeErrorCallback errorCallback);
// AudioNode creation
AudioBufferSourceNode createBufferSource();
MediaElementAudioSourceNode createMediaElementSource(HTMLMediaElement mediaElement);
MediaStreamAudioSourceNode createMediaStreamSource(MediaStream mediaStream);
MediaStreamAudioDestinationNode createMediaStreamDestination();
ScriptProcessorNode createScriptProcessor(optional unsigned long bufferSize = 0,
optional unsigned long numberOfInputChannels = 2,
optional unsigned long numberOfOutputChannels = 2);
AnalyserNode createAnalyser();
GainNode createGain();
DelayNode createDelay(optional double maxDelayTime = 1.0);
BiquadFilterNode createBiquadFilter();
WaveShaperNode createWaveShaper();
PannerNode createPanner();
ConvolverNode createConvolver();
ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs = 6);
ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs = 6);
DynamicsCompressorNode createDynamicsCompressor();
OscillatorNode createOscillator();
PeriodicWave createPeriodicWave(Float32Array real, Float32Array imag);
};</pre>
<pre id="audio-node-idl">enum ChannelCountMode {
"max",
"clamped-max",
"explicit"
};
enum ChannelInterpretation {
"speakers",
"discrete"
};
interface AudioNode : EventTarget {
void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
void connect(AudioParam destination, optional unsigned long output = 0);
void disconnect(optional unsigned long output = 0);
readonly attribute AudioContext context;
readonly attribute unsigned long numberOfInputs;
readonly attribute unsigned long numberOfOutputs;
// Channel up-mixing and down-mixing rules for all inputs.
attribute unsigned long channelCount;
attribute ChannelCountMode channelCountMode;
attribute ChannelInterpretation channelInterpretation;
};</pre>
<pre id="audio-param-idl">interface AudioParam {
attribute float value;
readonly attribute float defaultValue;
// Parameter automation.
void setValueAtTime(float value, double startTime);
void linearRampToValueAtTime(float value, double endTime);
void exponentialRampToValueAtTime(float value, double endTime);
// Exponentially approach the target value with a rate having the given time constant.
void setTargetAtTime(float target, double startTime, double timeConstant);
// Sets an array of arbitrary parameter values starting at time for the given duration.
// The number of values will be scaled to fit into the desired duration.
void setValueCurveAtTime(Float32Array values, double startTime, double duration);
// Cancels all scheduled parameter changes with times greater than or equal to startTime.
void cancelScheduledValues(double startTime);
};</pre>
<pre id="gain-node-idl">interface GainNode : AudioNode {
readonly attribute AudioParam gain;
};</pre>
<div id="log"></div>
<script>
(function() {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("event-target-idl").textContent);
idl_array.add_untested_idls(document.getElementById("audio-context-idl").textContent);
idl_array.add_untested_idls(document.getElementById("audio-node-idl").textContent);
idl_array.add_untested_idls(document.getElementById("audio-param-idl").textContent);
idl_array.add_idls(document.getElementById("gain-node-idl").textContent);
gain_node = (new AudioContext).createGain();
idl_array.add_objects({GainNode: ["gain_node"]});
idl_array.test();
})();
</script>
</body>
</html>

View file

@ -0,0 +1,121 @@
<!doctype html>
<!--
Tests that GainNode is properly scaling the gain.
We'll render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1.
The 11th note will be of gain 0.0, so it should be silent (at the end in the rendered output).
Based on a test from the WebKit test suite
(https://github.com/WebKit/webkit/blob/master/LayoutTests/webaudio/gain.html)
-->
<html class="a">
<head>
<title>GainNode interface</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/js/lodash.js"></script>
<script src="/webaudio/js/vendor-prefixes.js"></script>
<script src="/webaudio/js/helpers.js"></script>
<script src="/webaudio/js/buffer-loader.js"></script>
</head>
<body class="a">
<div id="log"></div>
<script>
var gainNodeTest = async_test("GainNode");
var sampleRate = 44100.0;
var bufferDurationSeconds = 0.125;
var numberOfNotes = 11;
var noteSpacing = bufferDurationSeconds + 0.020; // leave 20ms of silence between each "note"
var lengthInSeconds = numberOfNotes * noteSpacing;
var context = 0;
var expectedBuffer = 0;
var actualBuffer = 0;
var sinWaveBuffer = 0;
function createSinWaveBuffer(lengthInSeconds, frequency) {
var audioBuffer = context.createBuffer(2, lengthInSeconds * sampleRate, sampleRate);
var n = audioBuffer.length;
var channelL = audioBuffer.getChannelData(0);
var channelR = audioBuffer.getChannelData(1);
for (var i = 0; i < n; ++i) {
channelL[i] = Math.sin(frequency * 2.0*Math.PI * i / sampleRate);
channelR[i] = channelL[i];
}
return audioBuffer;
}
function playNote(time, gain) {
var source = context.createBufferSource();
source.buffer = sinWaveBuffer;
var gainNode = context.createGain();
gainNode.gain.value = gain;
source.connect(gainNode);
gainNode.connect(context.destination);
source.start(time);
}
function loadExpectedBuffer(event) {
actualBuffer = event.renderedBuffer;
bufferLoader = new BufferLoader(
context,
['/webaudio/the-audio-api/the-gainnode-interface/gain-expected.wav'],
bufferLoadCompleted
);
bufferLoader.load();
};
function bufferLoadCompleted(buffer) {
compareExpectedWithActualBuffer(buffer);
};
setup( function() {
// Create offline audio context.
context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate);
// Create a buffer for a short "note".
sinWaveBuffer = createSinWaveBuffer(bufferDurationSeconds, 880.0);
// Render 11 notes, starting at a gain of 1.0, decreasing in gain by 0.1.
// The last note will be of gain 0.0, so shouldn't be perceptible in the rendered output.
for (var i = 0; i < numberOfNotes; ++i) {
var time = i * noteSpacing;
var gain = 1.0 - i / (numberOfNotes - 1);
playNote(time, gain);
}
context.oncomplete = loadExpectedBuffer;
context.startRendering();
}, {timeout: 10000});
function compareExpectedWithActualBuffer(expected) {
var expectedBuffer = expected[0];
gainNodeTest.step(function() {
assert_array_approx_equals(expectedBuffer.getChannelData(0),
actualBuffer.getChannelData(0),
1e-4,
"comparing expected and rendered buffers (channel 0)");
});
gainNodeTest.step(function() {
assert_array_approx_equals(expectedBuffer.getChannelData(1),
actualBuffer.getChannelData(1),
1e-4,
"comparing expected and rendered buffers (channel 1)");
});
gainNodeTest.done();
};
</script>
</body>
</html>