| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 6 <script src="../resources/audio-testing.js"></script> | 7 <script src="../resources/audio-testing.js"></script> |
| 7 <script src="../resources/audio-param.js"></script> | 8 <script src="../resources/audio-param.js"></script> |
| 8 <title>Updating of Value Attribute from Timeline</title> | 9 <title>Updating of Value Attribute from Timeline</title> |
| 9 </head> | 10 </head> |
| 10 | 11 |
| 11 <body> | 12 <body> |
| 12 <script> | 13 <script> |
| 13 description("Test Updating of Value Attribute from Timeline"); | |
| 14 window.jsTestIsAsync = true; | |
| 15 | 14 |
| 16 // This should be a power of two so that all time computations have no rou
nd-off errors. | 15 // This should be a power of two so that all time computations have no rou
nd-off errors. |
| 17 var sampleRate = 32768; | 16 var sampleRate = 32768; |
| 18 var renderQuantumSize = 128; | 17 var renderQuantumSize = 128; |
| 19 // How many tests to run. | 18 // How many tests to run. |
| 20 var renderLoops = 20; | 19 var renderLoops = 20; |
| 21 var renderFrames = renderLoops * renderQuantumSize; | 20 var renderFrames = renderLoops * renderQuantumSize; |
| 22 var renderDuration = renderFrames / sampleRate; | 21 var renderDuration = renderFrames / sampleRate; |
| 23 | 22 |
| 24 var audit = Audit.createTaskRunner(); | 23 var audit = Audit.createTaskRunner(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 expectedValue: function (testTime) { | 76 expectedValue: function (testTime) { |
| 78 return audioParamSetValueCurve(testTime, curve, t0, duration); | 77 return audioParamSetValueCurve(testTime, curve, t0, duration); |
| 79 }, | 78 }, |
| 80 message: "setValueCurveAtTime([" + curve + "], " + t0 + ", " + durat
ion + ")", | 79 message: "setValueCurveAtTime([" + curve + "], " + t0 + ", " + durat
ion + ")", |
| 81 errorThreshold: 7.9577e-8 | 80 errorThreshold: 7.9577e-8 |
| 82 }; | 81 }; |
| 83 }).then(done); | 82 }).then(done); |
| 84 }); | 83 }); |
| 85 | 84 |
| 86 audit.defineTask("finish", function (done) { | 85 audit.defineTask("finish", function (done) { |
| 87 finishJSTest(); | |
| 88 done(); | 86 done(); |
| 89 }); | 87 }); |
| 90 | 88 |
| 91 audit.runTasks(); | 89 audit.runTasks(); |
| 92 | 90 |
| 93 // Test that the .value getter has the correct value when a timeline is ru
nning. | 91 // Test that the .value getter has the correct value when a timeline is ru
nning. |
| 94 // The |testFunction| is the underlying test to be run. | 92 // The |testFunction| is the underlying test to be run. |
| 95 function runTest(testFunction) { | 93 function runTest(testFunction) { |
| 96 // Create a simple graph consisting of a constant source and a gain node
where the | 94 // Create a simple graph consisting of a constant source and a gain node
where the |
| 97 // automations are run. A setValueAtTime event starts things off. | 95 // automations are run. A setValueAtTime event starts things off. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 | 115 |
| 118 // Run the desired automation test. The test function returns a diction
ary consisting of | 116 // Run the desired automation test. The test function returns a diction
ary consisting of |
| 119 // the following properties: | 117 // the following properties: |
| 120 // | 118 // |
| 121 // |message| an informative message about the automation being te
sted. | 119 // |message| an informative message about the automation being te
sted. |
| 122 // |errorThreshold| error threshold to determine if the test passes or n
ot. | 120 // |errorThreshold| error threshold to determine if the test passes or n
ot. |
| 123 // |expectedValue| a function that compute the expected value at time |
t|. | 121 // |expectedValue| a function that compute the expected value at time |
t|. |
| 124 var test = testFunction(gain, v0, t0, v1, t1); | 122 var test = testFunction(gain, v0, t0, v1, t1); |
| 125 | 123 |
| 126 // Print an informative message about the test being run. | 124 // Print an informative message about the test being run. |
| 127 testPassed("Initialize " + test.message + " with setValueAtTime(" + v0 +
", " + t0 + ")."); | 125 //testPassed("Initialize " + test.message + " with setValueAtTime(" + v0
+ ", " + t0 + ")."); |
| 128 | 126 Should("Initialize", true) |
| 127 .summarize(test.message + " with setValueAtTime(" + v0 + ", " + t0 + "
)", |
| 128 ""); |
| 129 |
| 129 var success = true; | 130 var success = true; |
| 130 | 131 |
| 131 // Max relative error found for this test. This is printed if the test f
ails so that setting | 132 // Max relative error found for this test. This is printed if the test f
ails so that setting |
| 132 // the thresholds is easier. | 133 // the thresholds is easier. |
| 133 var maxError = 0; | 134 var maxError = 0; |
| 134 | 135 |
| 135 // For every rendering quantum (except the first), suspend the context s
o the we can inspect | 136 // For every rendering quantum (except the first), suspend the context s
o the we can inspect |
| 136 // the value attribute and compare it with the expected value. | 137 // the value attribute and compare it with the expected value. |
| 137 for (var k = 1; k < renderLoops; ++k) { | 138 for (var k = 1; k < renderLoops; ++k) { |
| 138 var time = k * renderQuantumSize / sampleRate; | 139 var time = k * renderQuantumSize / sampleRate; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 152 precision: 7 | 153 precision: 7 |
| 153 }) | 154 }) |
| 154 .beCloseTo(expected, test.errorThreshold || 0) && success; | 155 .beCloseTo(expected, test.errorThreshold || 0) && success; |
| 155 }).then(context.resume.bind(context)); | 156 }).then(context.resume.bind(context)); |
| 156 } | 157 } |
| 157 | 158 |
| 158 source.start(); | 159 source.start(); |
| 159 | 160 |
| 160 return context.startRendering().then(function (resultBuffer) { | 161 return context.startRendering().then(function (resultBuffer) { |
| 161 // Just print a final pass (or fail) message. | 162 // Just print a final pass (or fail) message. |
| 162 if (success) | 163 Should("Gain .value attribute", success) |
| 163 testPassed("Gain .value attribute correctly updated during automatio
n.\n"); | 164 .summarize("correctly updated during automation", |
| 164 else | 165 "not correctly updated during automation; max error = " +
maxError); |
| 165 testFailed( | |
| 166 "Gain .value attribute not correctly updated during automation; ma
x error = " + | |
| 167 maxError + ".\n"); | |
| 168 }); | 166 }); |
| 169 } | 167 } |
| 170 </script> | 168 </script> |
| 171 </body> | 169 </body> |
| 172 </html> | 170 </html> |
| OLD | NEW |