| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 7 <script src="../resources/audit.js"></script> |
| 8 <title>Test CancelValuesAndHoldAtTime</title> | 8 <title>Test CancelValuesAndHoldAtTime</title> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 autoMessage: "setTargetAtTime(" + v1 + ", " + t0 + ", " + | 202 autoMessage: "setTargetAtTime(" + v1 + ", " + t0 + ", " + |
| 203 timeConstant + ")", | 203 timeConstant + ")", |
| 204 summary: "Initial setTargetAtTime", | 204 summary: "Initial setTargetAtTime", |
| 205 }; | 205 }; |
| 206 }, { | 206 }, { |
| 207 valueThreshold: 1.2320e-6, | 207 valueThreshold: 1.2320e-6, |
| 208 curveThreshold: 0 | 208 curveThreshold: 0 |
| 209 }).then(task.done.bind(task)); | 209 }).then(task.done.bind(task)); |
| 210 }); | 210 }); |
| 211 | 211 |
| 212 // Test automations scheduled after the call to cancelValuesAndHoldAtTime. | 212 // Test automations scheduled after the call to cancelAndHoldAtTime. |
| 213 // Very similar to the above tests, but we also schedule an event after | 213 // Very similar to the above tests, but we also schedule an event after |
| 214 // cancelValuesAndHoldAtTime and verify that curve after cancellation has | 214 // cancelAndHoldAtTime and verify that curve after cancellation has |
| 215 // the correct values. | 215 // the correct values. |
| 216 | 216 |
| 217 audit.define("post cancel: Linear", function (task, should) { | 217 audit.define("post cancel: Linear", function (task, should) { |
| 218 // Run the cancel test using a linearRamp as the event to be cancelled. | 218 // Run the cancel test using a linearRamp as the event to be cancelled. |
| 219 // Then schedule another linear ramp after the cancellation. | 219 // Then schedule another linear ramp after the cancellation. |
| 220 task.describe("LinearRamp after cancelling"); | 220 task.describe("LinearRamp after cancelling"); |
| 221 cancelTest(should, linearRampTest( | 221 cancelTest(should, linearRampTest( |
| 222 "Post cancellation linearRampToValueAtTime"), { | 222 "Post cancellation linearRampToValueAtTime"), { |
| 223 valueThreshold: 8.3998e-5, | 223 valueThreshold: 8.3998e-5, |
| 224 curveThreshold: 0 | 224 curveThreshold: 0 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // cancellation point. | 397 // cancellation point. |
| 398 let context = new OfflineAudioContext(3, renderDuration * sampleRate, | 398 let context = new OfflineAudioContext(3, renderDuration * sampleRate, |
| 399 sampleRate); | 399 sampleRate); |
| 400 | 400 |
| 401 // Test source is a constant signal | 401 // Test source is a constant signal |
| 402 let src = context.createBufferSource(); | 402 let src = context.createBufferSource(); |
| 403 src.buffer = createConstantBuffer(context, 1, 1); | 403 src.buffer = createConstantBuffer(context, 1, 1); |
| 404 src.loop = true; | 404 src.loop = true; |
| 405 | 405 |
| 406 // We'll do the automation tests with three gain nodes. One (g0) will | 406 // We'll do the automation tests with three gain nodes. One (g0) will |
| 407 // have cancelValuesAndHoldAtTime and the other (g1) will not. g1 is | 407 // have cancelAndHoldAtTime and the other (g1) will not. g1 is |
| 408 // used as the expected result for that automation up to the | 408 // used as the expected result for that automation up to the |
| 409 // cancellation point. They should be the same. The third node (g2) is | 409 // cancellation point. They should be the same. The third node (g2) is |
| 410 // used for testing automations inserted after the cancellation point, | 410 // used for testing automations inserted after the cancellation point, |
| 411 // if any. g2 is the expected result from the cancellation point to the | 411 // if any. g2 is the expected result from the cancellation point to the |
| 412 // end of the test. | 412 // end of the test. |
| 413 | 413 |
| 414 let g0 = context.createGain(); | 414 let g0 = context.createGain(); |
| 415 let g1 = context.createGain(); | 415 let g1 = context.createGain(); |
| 416 let g2 = context.createGain(); | 416 let g2 = context.createGain(); |
| 417 let v0 = 1; | 417 let v0 = 1; |
| 418 let t0 = 0.01; | 418 let t0 = 0.01; |
| 419 | 419 |
| 420 let cancelTime = renderDuration / 2; | 420 let cancelTime = renderDuration / 2; |
| 421 | 421 |
| 422 // Test automation here. The tester function is responsible for setting | 422 // Test automation here. The tester function is responsible for setting |
| 423 // up the gain nodes with the desired automation for testing. | 423 // up the gain nodes with the desired automation for testing. |
| 424 autoResult = testerFunction([g0, g1, g2], v0, t0, cancelTime); | 424 autoResult = testerFunction([g0, g1, g2], v0, t0, cancelTime); |
| 425 let expectedConstant = autoResult.expectedConstant; | 425 let expectedConstant = autoResult.expectedConstant; |
| 426 let autoMessage = autoResult.autoMessage; | 426 let autoMessage = autoResult.autoMessage; |
| 427 let summaryMessage = autoResult.summary; | 427 let summaryMessage = autoResult.summary; |
| 428 | 428 |
| 429 // Cancel scheduled events somewhere in the middle of the test | 429 // Cancel scheduled events somewhere in the middle of the test |
| 430 // automation. | 430 // automation. |
| 431 g0.gain.cancelValuesAndHoldAtTime(cancelTime); | 431 g0.gain.cancelAndHoldAtTime(cancelTime); |
| 432 | 432 |
| 433 let constantEndTime; | 433 let constantEndTime; |
| 434 if (postCancelTest) { | 434 if (postCancelTest) { |
| 435 postResult = postCancelTest([g0, g1, g2], cancelTime, | 435 postResult = postCancelTest([g0, g1, g2], cancelTime, |
| 436 expectedConstant); | 436 expectedConstant); |
| 437 constantEndTime = postResult.constantEndTime; | 437 constantEndTime = postResult.constantEndTime; |
| 438 } | 438 } |
| 439 | 439 |
| 440 // Connect everything together (with a merger to make a two-channel | 440 // Connect everything together (with a merger to make a two-channel |
| 441 // result). Channel 0 is the test (with cancelValuesAndHoldAtTime) and | 441 // result). Channel 0 is the test (with cancelAndHoldAtTime) and |
| 442 // channel 1 is the reference (without cancelValuesAndHoldAtTime). | 442 // channel 1 is the reference (without cancelAndHoldAtTime). |
| 443 // Channel 1 is used to verify that everything up to the cancellation | 443 // Channel 1 is used to verify that everything up to the cancellation |
| 444 // has the correct values. | 444 // has the correct values. |
| 445 src.connect(g0); | 445 src.connect(g0); |
| 446 src.connect(g1); | 446 src.connect(g1); |
| 447 src.connect(g2); | 447 src.connect(g2); |
| 448 let merger = context.createChannelMerger(3); | 448 let merger = context.createChannelMerger(3); |
| 449 g0.connect(merger, 0, 0); | 449 g0.connect(merger, 0, 0); |
| 450 g1.connect(merger, 0, 1); | 450 g1.connect(merger, 0, 1); |
| 451 g2.connect(merger, 0, 2); | 451 g2.connect(merger, 0, 2); |
| 452 merger.connect(context.destination); | 452 merger.connect(context.destination); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 should(actual.slice(constantEndFrame), postResult.message) | 507 should(actual.slice(constantEndFrame), postResult.message) |
| 508 .beCloseToArray(c2.slice(constantEndFrame), { | 508 .beCloseToArray(c2.slice(constantEndFrame), { |
| 509 absoluteThreshold: postResult.errorThreshold || 0 | 509 absoluteThreshold: postResult.errorThreshold || 0 |
| 510 }); | 510 }); |
| 511 } | 511 } |
| 512 }); | 512 }); |
| 513 } | 513 } |
| 514 </script> | 514 </script> |
| 515 </body> | 515 </body> |
| 516 </html> | 516 </html> |
| OLD | NEW |