Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / audiobuffersource-playbackrate-zero.html
blob9f08039264fe3c5e807025d887808da555a9c729
1 <!DOCTYPE html>
2 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script>
8 </head>
10 <body>
11 <script>
12 description('AudioBufferSourceNode: test the "zero" playbackRate.');
13 window.jsTestIsAsync = true;
15 // Sample rate should be power of 128 to observe the change of AudioParam at
16 // the beginning of rendering quantum. (playbackRate is k-rate) This is the
17 // minimum sample rate in the valid sample rate range.
18 var sampleRate = 4096;
20 // The render duration in seconds, and the length in samples.
21 var renderDuration = 1.0;
22 var renderLength = renderDuration * sampleRate;
24 var context = new OfflineAudioContext(1, renderLength, sampleRate);
25 var audit = Audit.createTaskRunner();
28 // Task: Render the actual buffer and compare with the reference.
29 audit.defineTask('synthesize-verify', function (done) {
30 var ramp = context.createBufferSource();
31 var rampBuffer = createLinearRampBuffer(context, renderLength);
32 ramp.buffer = rampBuffer;
34 ramp.connect(context.destination);
35 ramp.start();
37 // Leave the playbackRate as 1 for the first half, then change it
38 // to zero at the exact half. The zero playback rate should hold the
39 // sample value of the buffer index at the moment. (sample-and-hold)
40 ramp.playbackRate.setValueAtTime(1.0, 0.0);
41 ramp.playbackRate.setValueAtTime(0.0, renderDuration / 2);
43 context.startRendering().then(function (renderedBuffer) {
44 var data = renderedBuffer.getChannelData(0);
45 var rampData = rampBuffer.getChannelData(0);
46 var half = rampData.length / 2;
47 var passed = true;
49 for (var i = 1; i < rampData.length; i++) {
50 if (i < half) {
51 // Before the half position, the actual should match with the
52 // original ramp data.
53 if (data[i] !== rampData[i]) {
54 passed = false;
55 break;
57 } else {
58 // From the half position, the actual value should not change.
59 if (data[i] !== rampData[half]) {
60 passed = false;
61 break;
66 if (passed) {
67 testPassed('The zero playbackRate held the sample value correctly.');
68 } else {
69 testFailed('The zero playbackRate should hold the sample value. ' +
70 'Expected ' + rampData[half] + ' but got ' + data[i] + ' at the index ' +
71 i + '.');
73 }).then(done);
74 });
76 audit.defineTask('finish', function (done) {
77 finishJSTest();
78 done();
79 });
81 audit.runTasks(
82 'synthesize-verify',
83 'finish'
86 successfullyParsed = true;
87 </script>
88 </body>
90 </html>