Changeset 267253 in webkit
- Timestamp:
- Sep 18, 2020 12:18:42 PM (4 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 60 added
- 6 edited
- 1 copied
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r267252 r267253 1 2020-09-18 Chris Dumez <cdumez@apple.com> 2 3 Import AudioContext / AudioListener / AudioNode / AudioParam layout tests from Blink 4 https://bugs.webkit.org/show_bug.cgi?id=216706 5 6 Reviewed by Eric Carlson. 7 8 Import AudioContext / AudioListener / AudioNode / AudioParam layout tests from Blink. 9 10 * webaudio/AudioContext/audiocontext-close-basic-expected.txt: Added. 11 * webaudio/AudioContext/audiocontext-close-basic.html: Added. 12 * webaudio/AudioContext/audiocontext-listener-should-not-crash-expected.txt: Added. 13 * webaudio/AudioContext/audiocontext-listener-should-not-crash.html: Added. 14 * webaudio/AudioListener/audiolistener-automation-position-expected.txt: Added. 15 * webaudio/AudioListener/audiolistener-automation-position.html: Added. 16 * webaudio/AudioListener/audiolistener-set-position-expected.txt: Added. 17 * webaudio/AudioListener/audiolistener-set-position.html: Added. 18 * webaudio/AudioNode/tail-connections-expected.txt: Added. 19 * webaudio/AudioNode/tail-connections.html: Added. 20 * webaudio/AudioNode/tail-processing-expected.txt: Added. 21 * webaudio/AudioNode/tail-processing.html: Added. 22 * webaudio/AudioParam/audioparam-automation-clamping-expected.txt: Added. 23 * webaudio/AudioParam/audioparam-automation-clamping.html: Added. 24 * webaudio/AudioParam/audioparam-cancel-and-hold-expected.txt: Renamed from LayoutTests/webaudio/audioparam-cancel-and-hold-expected.txt. 25 * webaudio/AudioParam/audioparam-cancel-and-hold.html: Renamed from LayoutTests/webaudio/audioparam-cancel-and-hold.html. 26 * webaudio/AudioParam/audioparam-clamp-time-to-current-time-expected.txt: Added. 27 * webaudio/AudioParam/audioparam-clamp-time-to-current-time.html: Added. 28 * webaudio/AudioParam/audioparam-initial-event-expected.txt: Added. 29 * webaudio/AudioParam/audioparam-initial-event.html: Added. 30 * webaudio/AudioParam/audioparam-k-rate-expected.txt: Added. 31 * webaudio/AudioParam/audioparam-k-rate.html: Added. 32 * webaudio/AudioParam/audioparam-linearRamp-value-attribute-expected.txt: Added. 33 * webaudio/AudioParam/audioparam-linearRamp-value-attribute.html: Added. 34 * webaudio/AudioParam/audioparam-negative-exponentialRamp-expected.txt: Added. 35 * webaudio/AudioParam/audioparam-negative-exponentialRamp.html: Added. 36 * webaudio/AudioParam/audioparam-nominal-range-expected.txt: Renamed from LayoutTests/webaudio/audioparam-nominal-range-expected.txt. 37 * webaudio/AudioParam/audioparam-nominal-range.html: Renamed from LayoutTests/webaudio/audioparam-nominal-range.html. 38 * webaudio/AudioParam/audioparam-processing-expected.txt: Added. 39 * webaudio/AudioParam/audioparam-processing.html: Added. 40 * webaudio/AudioParam/audioparam-sampling-expected.txt: Added. 41 * webaudio/AudioParam/audioparam-sampling.html: Added. 42 * webaudio/AudioParam/audioparam-setTarget-timeConstant-0-expected.txt: Added. 43 * webaudio/AudioParam/audioparam-setTarget-timeConstant-0.html: Added. 44 * webaudio/AudioParam/audioparam-setTargetAtTime-continuous-expected.txt: Added. 45 * webaudio/AudioParam/audioparam-setTargetAtTime-continuous.html: Added. 46 * webaudio/AudioParam/audioparam-setTargetAtTime-limit-expected.txt: Added. 47 * webaudio/AudioParam/audioparam-setTargetAtTime-limit.html: Added. 48 * webaudio/AudioParam/audioparam-setTargetAtTime-sampling-expected.txt: Added. 49 * webaudio/AudioParam/audioparam-setTargetAtTime-sampling.html: Added. 50 * webaudio/AudioParam/audioparam-setValueCurve-copy-expected.txt: Added. 51 * webaudio/AudioParam/audioparam-setValueCurve-copy.html: Added. 52 * webaudio/AudioParam/audioparam-setValueCurve-duration-expected.txt: Added. 53 * webaudio/AudioParam/audioparam-setValueCurve-duration.html: Added. 54 * webaudio/AudioParam/audioparam-setValueCurve-end-expected.txt: Added. 55 * webaudio/AudioParam/audioparam-setValueCurve-end.html: Added. 56 * webaudio/AudioParam/audioparam-setValueCurve-exceptions-expected.txt: Added. 57 * webaudio/AudioParam/audioparam-setValueCurveAtTime-interpolation-expected.txt: Added. 58 * webaudio/AudioParam/audioparam-setValueCurveAtTime-interpolation.html: Added. 59 * webaudio/AudioParam/audioparam-update-value-attribute-expected.txt: Added. 60 * webaudio/AudioParam/audioparam-update-value-attribute.html: Added. 61 * webaudio/AudioParam/audioparam-value-setter-error-expected.txt: Added. 62 * webaudio/AudioParam/audioparam-value-setter-error.html: Added. 63 * webaudio/AudioParam/cancel-values-crash-913217-expected.txt: Added. 64 * webaudio/AudioParam/cancel-values-crash-913217.html: Added. 65 * webaudio/AudioParam/value-setter-warnings-expected.txt: Added. 66 * webaudio/AudioParam/value-setter-warnings.html: Added. 67 * webaudio/AudioParam/worklet-warnings-expected.txt: Added. 68 * webaudio/AudioParam/worklet-warnings.html: Added. 69 * webaudio/audioparam-exponentialRampToValueAtTime.html: 70 * webaudio/audioparam-linearRampToValueAtTime.html: 71 * webaudio/audioparam-setValueAtTime.html: 72 * webaudio/resources/audioparam-testing-legacy.js: Copied from LayoutTests/webaudio/resources/audioparam-testing.js. 73 (renderLength): 74 (createConstantBuffer): 75 (createConstantArray): 76 (createLinearRampArray): 77 (createExponentialRampArray): 78 (discreteTimeConstantForSampleRate): 79 (createExponentialApproachArray): 80 (createSineWaveArray): 81 (endValueDelta): 82 (valueUpdate): 83 (comparePartialSignals): 84 (verifyDiscontinuities): 85 (compareSignals): 86 (checkResultFunction): 87 (doAutomation): 88 (createAudioGraphAndTest): 89 * webaudio/resources/audioparam-testing.js: 90 (renderLength): 91 (createConstantArray): 92 (getStartEndFrames): 93 (createLinearRampArray): 94 (createExponentialRampArray): 95 (discreteTimeConstantForSampleRate): 96 (createExponentialApproachArray): 97 (createReferenceSineArray): 98 (createSineWaveArray): 99 (endValueDelta): 100 (relativeErrorMetric): 101 (differenceErrorMetric): 102 (valueUpdate): 103 (comparePartialSignals): 104 (verifyDiscontinuities): 105 (compareSignals): 106 (checkResultFunction): 107 (doAutomation): 108 (createAudioGraphAndTest): 109 * webaudio/resources/set-position-vs-curve-test.js: Added. 110 (testPositionSetterVsCurve): 111 1 112 2020-09-18 Chris Dumez <cdumez@apple.com> 2 113 -
trunk/LayoutTests/TestExpectations
r267245 r267253 338 338 # This WebAudio test is crashing in debug since its import from Blink. 339 339 [ Debug ] webaudio/AudioBufferSource/audiobuffersource-playbackrate.html [ Crash ] 340 [ Debug ] webaudio/AudioParam/audioparam-setTarget-timeConstant-0.html [ Crash ] 340 341 341 342 webkit.org/b/176929 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay-with-slow-text-tracks.html [ Pass Failure ] -
trunk/LayoutTests/webaudio/AudioParam/audioparam-cancel-and-hold-expected.txt
r267252 r267253 19 19 PASS Audit report 20 20 PASS > [linear] Cancel linearRampToValueAtTime 21 PASS linearRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 21 FAIL X linearRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 22 Index Actual Expected AbsError RelError Test threshold 23 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 24 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 25 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 26 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 27 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 28 ...and 1140 more errors. 29 Max AbsError of 5.9604644775390625e-8 at index of 715. 30 Max RelError of 1.1671811990452458e-7 at index of 11989. 31 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 32 assert_true: expected true got false 22 33 PASS Cancelling linearRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 23 34 PASS Expected value for cancelling linearRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 24 PASS < [linear] All assertions passed. (total 3 assertions) 35 FAIL < [linear] 1 out of 3 assertions were failed. assert_true: expected true got false 25 36 PASS > [exponential] Cancel exponentialRampAtTime 26 37 PASS exponentialRampToValue(0.001, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":5.9605e-8,"relativeThreshold":0}. … … 29 40 PASS < [exponential] All assertions passed. (total 3 assertions) 30 41 PASS > [setTarget] Cancel setTargetAtTime 31 PASS setTargetAtTime(0, 0.01, 0.05) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold": 4.5267e-7,"relativeThreshold":0}.42 PASS setTargetAtTime(0, 0.01, 0.05) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 32 43 PASS Cancelling setTargetAtTime(0, 0.01, 0.05) at time 0.25 contains only the constant 0.008229751139879227. 33 44 PASS Expected value for cancelling setTargetAtTime(0, 0.01, 0.05) at time 0.25 is 0.008229747414588928 within an error of 4.5267e-7. … … 44 55 PASS < [setValueCurve after end] All assertions passed. (total 3 assertions) 45 56 PASS > [initial setTarget] Cancel with initial setTargetAtTime 46 PASS setTargetAtTime(0, 0.01, 0.1) up to time 0.25 equals [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1...] with an element-wise tolerance of {"absoluteThreshold":0 .000001232,"relativeThreshold":0}.57 PASS setTargetAtTime(0, 0.01, 0.1) up to time 0.25 equals [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 47 58 PASS Cancelling setTargetAtTime(0, 0.01, 0.1) at time 0.25 contains only the constant 0.0907178446650505. 48 59 PASS Expected value for cancelling setTargetAtTime(0, 0.01, 0.1) at time 0.25 is 0.09071795642375946 within an error of 0.000001232. 49 60 PASS < [initial setTarget] All assertions passed. (total 3 assertions) 50 61 PASS > [post cancel: Linear] LinearRamp after cancelling 51 PASS Post cancellation linearRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 62 FAIL X Post cancellation linearRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 63 Index Actual Expected AbsError RelError Test threshold 64 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 65 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 66 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 67 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 68 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 69 ...and 1140 more errors. 70 Max AbsError of 5.9604644775390625e-8 at index of 715. 71 Max RelError of 1.1671811990452458e-7 at index of 11989. 72 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 73 assert_true: expected true got false 52 74 PASS Cancelling Post cancellation linearRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 53 75 PASS Expected value for cancelling Post cancellation linearRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 54 76 PASS Post linearRamp(2, 0.375) equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 55 PASS < [post cancel: Linear] All assertions passed. (total 4 assertions) 77 FAIL < [post cancel: Linear] 1 out of 4 assertions were failed. assert_true: expected true got false 56 78 PASS > [post cancel: Exponential] ExponentialRamp after cancelling 57 PASS Post cancel exponentialRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 79 FAIL X Post cancel exponentialRampToValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 80 Index Actual Expected AbsError RelError Test threshold 81 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 82 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 83 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 84 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 85 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 86 ...and 1140 more errors. 87 Max AbsError of 5.9604644775390625e-8 at index of 715. 88 Max RelError of 1.1671811990452458e-7 at index of 11989. 89 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 90 assert_true: expected true got false 58 91 PASS Cancelling Post cancel exponentialRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 59 92 PASS Expected value for cancelling Post cancel exponentialRampToValueAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 60 93 PASS Post exponentialRamp(2, 0.375) equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 61 PASS < [post cancel: Exponential] All assertions passed. (total 4 assertions) 94 FAIL < [post cancel: Exponential] 1 out of 4 assertions were failed. assert_true: expected true got false 62 95 PASS > [post cancel: ValueCurve] 63 PASS Post cancel setValueCurveAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 96 FAIL X Post cancel setValueCurveAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 97 Index Actual Expected AbsError RelError Test threshold 98 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 99 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 100 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 101 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 102 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 103 ...and 1140 more errors. 104 Max AbsError of 5.9604644775390625e-8 at index of 715. 105 Max RelError of 1.1671811990452458e-7 at index of 11989. 106 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 107 assert_true: expected true got false 64 108 PASS Cancelling Post cancel setValueCurveAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 65 109 PASS Expected value for cancelling Post cancel setValueCurveAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 66 110 PASS Post setValueCurve([0.125,2], 0.375, 0.125) equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 67 PASS < [post cancel: ValueCurve] All assertions passed. (total 4 assertions) 111 FAIL < [post cancel: ValueCurve] 1 out of 4 assertions were failed. assert_true: expected true got false 68 112 PASS > [post cancel: setTarget] 69 PASS Post cancel setTargetAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 113 FAIL X Post cancel setTargetAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 114 Index Actual Expected AbsError RelError Test threshold 115 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 116 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 117 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 118 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 119 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 120 ...and 1140 more errors. 121 Max AbsError of 5.9604644775390625e-8 at index of 715. 122 Max RelError of 1.1671811990452458e-7 at index of 11989. 123 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 124 assert_true: expected true got false 70 125 PASS Cancelling Post cancel setTargetAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 71 126 PASS Expected value for cancelling Post cancel setTargetAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 72 127 PASS Post setTargetAtTime(0.125, 0.375, 0.1) equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000084037,"relativeThreshold":0}. 73 PASS < [post cancel: setTarget] All assertions passed. (total 4 assertions) 128 FAIL < [post cancel: setTarget] 1 out of 4 assertions were failed. assert_true: expected true got false 74 129 PASS > [post cancel: setValue] 75 PASS Post cancel setValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0.000083998,"relativeThreshold":0}. 130 FAIL X Post cancel setValueAtTime: linearRampToValue(0, 0.5) up to time 0.25 does not equal [0,0.0020833334419876337,0.004166666883975267,0.0062500000931322575,0.008333333767950535,0.010416666977107525,0.012500000186264515,0.014583333395421505,0.01666666753590107,0.01875000074505806,0.02083333395421505,0.02291666716337204,0.02500000037252903,0.02708333358168602,0.02916666679084301,0.03125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 131 Index Actual Expected AbsError RelError Test threshold 132 [715] 9.9000853300094604e-1 9.9000847339630127e-1 5.9604644775390625e-8 6.0206196590330427e-8 0.0000000000000000e+0 133 [816] 9.8571431636810303e-1 9.8571425676345825e-1 5.9604644775390625e-8 6.0468481982901817e-8 0.0000000000000000e+0 134 [879] 9.8303568363189697e-1 9.8303574323654175e-1 5.9604644775390625e-8 6.0633242672487782e-8 0.0000000000000000e+0 135 [1264] 9.6666663885116577e-1 9.6666669845581055e-1 5.9604644775390625e-8 6.1659975326144279e-8 0.0000000000000000e+0 136 [1368] 9.6224492788314819e-1 9.6224486827850342e-1 5.9604644775390625e-8 6.1943323098231583e-8 0.0000000000000000e+0 137 ...and 1140 more errors. 138 Max AbsError of 5.9604644775390625e-8 at index of 715. 139 Max RelError of 1.1671811990452458e-7 at index of 11989. 140 [11989] 5.1067179441452026e-1 5.1067173480987549e-1 5.9604644775390625e-8 1.1671811990452458e-7 0.0000000000000000e+0 141 assert_true: expected true got false 76 142 PASS Cancelling Post cancel setValueAtTime: linearRampToValue(0, 0.5) at time 0.25 contains only the constant 0.5102040767669678. 77 143 PASS Expected value for cancelling Post cancel setValueAtTime: linearRampToValue(0, 0.5) at time 0.25 is 0.5102040767669678 within an error of 0.000083998. 78 144 PASS Post setValueAtTime(0.125, 0.375) equals [0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125,0.125...] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 79 PASS < [post cancel: setValue] All assertions passed. (total 4 assertions) 145 FAIL < [post cancel: setValue] 1 out of 4 assertions were failed. assert_true: expected true got false 80 146 PASS > [cancel future setTarget] 81 147 PASS After cancelling future setTarget event, output contains only the constant 0.5. … … 110 176 PASS 3rd linearRamp(0, 0.5) equals [expected array] with an element-wise tolerance of {"absoluteThreshold":0,"relativeThreshold":0}. 111 177 FAIL < [linear, cancel, linear, cancel, linear] 1 out of 7 assertions were failed. assert_true: expected true got false 112 FAIL # AUDIT TASK RUNNER FINISHED: 1out of 16 tasks were failed. assert_true: expected true got false178 FAIL # AUDIT TASK RUNNER FINISHED: 7 out of 16 tasks were failed. assert_true: expected true got false 113 179 -
trunk/LayoutTests/webaudio/AudioParam/audioparam-cancel-and-hold.html
r267252 r267253 5 5 Test CancelValuesAndHoldAtTime 6 6 </title> 7 <script src="../ imported/w3c/web-platform-tests/resources/testharness.js"></script>8 <script src="../ resources/testharnessreport.js"></script>9 <script src=" resources/audio-param.js"></script>10 <script src=" resources/audit-util.js"></script>11 <script src=" resources/audit.js"></script>7 <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script> 8 <script src="../../resources/testharnessreport.js"></script> 9 <script src="../resources/audio-param.js"></script> 10 <script src="../resources/audit-util.js"></script> 11 <script src="../resources/audit.js"></script> 12 12 </head> 13 13 <body> … … 28 28 cancelTest(should, linearRampTest('linearRampToValueAtTime'), { 29 29 valueThreshold: 8.3998e-5, 30 curveThreshold: 8.3998e-530 curveThreshold: 0 31 31 }).then(task.done.bind(task)); 32 32 }); … … 97 97 }, { 98 98 valueThreshold: 4.5267e-7, // 1.1317e-7, 99 curveThreshold: 4.5267e-799 curveThreshold: 0 100 100 }).then(task.done.bind(task)); 101 101 }); … … 217 217 }, { 218 218 valueThreshold: 1.2320e-6, 219 curveThreshold: 1.2320e-6219 curveThreshold: 0 220 220 }).then(task.done.bind(task)); 221 221 }); … … 238 238 should, 239 239 linearRampTest('Post cancellation linearRampToValueAtTime'), 240 {valueThreshold: 8.3998e-5, curveThreshold: 8.3998e-5},240 {valueThreshold: 8.3998e-5, curveThreshold: 0}, 241 241 function(g, cancelTime, expectedConstant) { 242 242 // Schedule the linear ramp on g[0], and do the same for g[2], … … 267 267 should, 268 268 linearRampTest('Post cancel exponentialRampToValueAtTime'), 269 {valueThreshold: 8.3998e-5, curveThreshold: 8.3998e-5},269 {valueThreshold: 8.3998e-5, curveThreshold: 0}, 270 270 function(g, cancelTime, expectedConstant) { 271 271 // Schedule the exponential ramp on g[0], and do the same for … … 289 289 cancelTest( 290 290 should, linearRampTest('Post cancel setValueCurveAtTime'), 291 {valueThreshold: 8.3998e-5, curveThreshold: 8.3998e-5},291 {valueThreshold: 8.3998e-5, curveThreshold: 0}, 292 292 function(g, cancelTime, expectedConstant) { 293 293 // Schedule the exponential ramp on g[0], and do the same for … … 314 314 cancelTest( 315 315 should, linearRampTest('Post cancel setTargetAtTime'), 316 {valueThreshold: 8.3998e-5, curveThreshold: 8.3998e-5},316 {valueThreshold: 8.3998e-5, curveThreshold: 0}, 317 317 function(g, cancelTime, expectedConstant) { 318 318 // Schedule the exponential ramp on g[0], and do the same for … … 339 339 cancelTest( 340 340 should, linearRampTest('Post cancel setValueAtTime'), 341 {valueThreshold: 8.3998e-5, curveThreshold: 8.3998e-5},341 {valueThreshold: 8.3998e-5, curveThreshold: 0}, 342 342 function(g, cancelTime, expectedConstant) { 343 343 // Schedule the exponential ramp on g[0], and do the same for -
trunk/LayoutTests/webaudio/AudioParam/audioparam-nominal-range.html
r267252 r267253 5 5 Test AudioParam Nominal Range Values 6 6 </title> 7 <script src="../ imported/w3c/web-platform-tests/resources/testharness.js"></script>8 <script src="../ resources/testharnessreport.js"></script>9 <script src=" resources/audit-util.js"></script>10 <script src=" resources/audit.js"></script>7 <script src="../../imported/w3c/web-platform-tests/resources/testharness.js"></script> 8 <script src="../../resources/testharnessreport.js"></script> 9 <script src="../resources/audit-util.js"></script> 10 <script src="../resources/audit.js"></script> 11 11 </head> 12 12 <body> -
trunk/LayoutTests/webaudio/audioparam-exponentialRampToValueAtTime.html
r155286 r267253 3 3 <head> 4 4 <script src="resources/audio-testing.js"></script> 5 <script src="resources/audioparam-testing .js"></script>5 <script src="resources/audioparam-testing-legacy.js"></script> 6 6 <script src="../resources/js-test-pre.js"></script> 7 7 </head> -
trunk/LayoutTests/webaudio/audioparam-linearRampToValueAtTime.html
r155286 r267253 3 3 <head> 4 4 <script src="resources/audio-testing.js"></script> 5 <script src="resources/audioparam-testing .js"></script>5 <script src="resources/audioparam-testing-legacy.js"></script> 6 6 <script src="../resources/js-test-pre.js"></script> 7 7 </head> -
trunk/LayoutTests/webaudio/audioparam-setValueAtTime.html
r155286 r267253 3 3 <head> 4 4 <script src="resources/audio-testing.js"></script> 5 <script src="resources/audioparam-testing .js"></script>5 <script src="resources/audioparam-testing-legacy.js"></script> 6 6 <script src="../resources/js-test-pre.js"></script> 7 7 </head> -
trunk/LayoutTests/webaudio/resources/audioparam-testing.js
r205065 r267253 1 var sampleRate = 44100; 2 3 // Information about the starting/ending times and starting/ending values for each time interval. 4 var timeValueInfo; 5 6 // The difference between starting values between each time interval. 7 var startingValueDelta; 8 9 // For any automation function that has an end or target value, the end value is based the starting 10 // value of the time interval. The starting value will be increased or decreased by 11 // |startEndValueChange|. We choose half of |startingValueDelta| so that the ending value will be 12 // distinct from the starting value for next time interval. This allows us to detect where the ramp 13 // begins and ends. 14 var startEndValueChange; 15 16 // Default threshold to use for detecting discontinuities that should appear at each time interval. 17 var discontinuityThreshold; 18 19 // Time interval between value changes. It is best if 1 / numberOfTests is not close to timeInterval. 20 var timeInterval = .03; 21 22 // Some suitable time constant so that we can see a significant change over a timeInterval. This is 23 // only needed by setTargetAtTime() which needs a time constant. 24 var timeConstant = timeInterval / 3; 25 26 var gainNode; 27 28 var context; 29 30 // Make sure we render long enough to capture all of our test data. 31 function renderLength(numberOfTests) 32 { 1 (function(global) { 2 3 // Information about the starting/ending times and starting/ending values for 4 // each time interval. 5 let timeValueInfo; 6 7 // The difference between starting values between each time interval. 8 let startingValueDelta; 9 10 // For any automation function that has an end or target value, the end value 11 // is based the starting value of the time interval. The starting value will 12 // be increased or decreased by |startEndValueChange|. We choose half of 13 // |startingValueDelta| so that the ending value will be distinct from the 14 // starting value for next time interval. This allows us to detect where the 15 // ramp begins and ends. 16 let startEndValueChange; 17 18 // Default threshold to use for detecting discontinuities that should appear 19 // at each time interval. 20 let discontinuityThreshold; 21 22 // Time interval between value changes. It is best if 1 / numberOfTests is 23 // not close to timeInterval. 24 let timeIntervalInternal = .03; 25 26 let context; 27 28 // Make sure we render long enough to capture all of our test data. 29 function renderLength(numberOfTests) { 33 30 return timeToSampleFrame((numberOfTests + 1) * timeInterval, sampleRate); 34 } 35 36 // Create a buffer containing the same constant value. 37 function createConstantBuffer(context, constant, length) { 38 var buffer = context.createBuffer(1, length, context.sampleRate); 39 var n = buffer.length; 40 var data = buffer.getChannelData(0); 41 42 for (var k = 0; k < n; ++k) { 43 data[k] = constant; 44 } 45 46 return buffer; 47 } 48 49 // Create a constant reference signal with the given |value|. Basically the same as 50 // |createConstantBuffer|, but with the parameters to match the other create functions. The 51 // |endValue| is ignored. 52 function createConstantArray(startTime, endTime, value, endValue, sampleRate) 53 { 54 var startFrame = timeToSampleFrame(startTime, sampleRate); 55 var endFrame = timeToSampleFrame(endTime, sampleRate); 56 var length = endFrame - startFrame; 57 58 var buffer = createConstantBuffer(context, value, length); 31 } 32 33 // Create a constant reference signal with the given |value|. Basically the 34 // same as |createConstantBuffer|, but with the parameters to match the other 35 // create functions. The |endValue| is ignored. 36 function createConstantArray( 37 startTime, endTime, value, endValue, sampleRate) { 38 let startFrame = timeToSampleFrame(startTime, sampleRate); 39 let endFrame = timeToSampleFrame(endTime, sampleRate); 40 let length = endFrame - startFrame; 41 42 let buffer = createConstantBuffer(context, length, value); 59 43 60 44 return buffer.getChannelData(0); 61 } 62 63 // Create a linear ramp starting at |startValue| and ending at |endValue|. The ramp starts at time 64 // |startTime| and ends at |endTime|. (The start and end times are only used to compute how many 65 // samples to return.) 66 function createLinearRampArray(startTime, endTime, startValue, endValue, sampleRate) 67 { 68 var startFrame = timeToSampleFrame(startTime, sampleRate); 69 var endFrame = timeToSampleFrame(endTime, sampleRate); 70 var length = endFrame - startFrame; 71 var array = new Array(length); 72 73 var step = (endValue - startValue) / length; 74 45 } 46 47 function getStartEndFrames(startTime, endTime, sampleRate) { 48 // Start frame is the ceiling of the start time because the ramp starts at 49 // or after the sample frame. End frame is the ceiling because it's the 50 // exclusive ending frame of the automation. 51 let startFrame = Math.ceil(startTime * sampleRate); 52 let endFrame = Math.ceil(endTime * sampleRate); 53 54 return {startFrame: startFrame, endFrame: endFrame}; 55 } 56 57 // Create a linear ramp starting at |startValue| and ending at |endValue|. The 58 // ramp starts at time |startTime| and ends at |endTime|. (The start and end 59 // times are only used to compute how many samples to return.) 60 function createLinearRampArray( 61 startTime, endTime, startValue, endValue, sampleRate) { 62 let frameInfo = getStartEndFrames(startTime, endTime, sampleRate); 63 let startFrame = frameInfo.startFrame; 64 let endFrame = frameInfo.endFrame; 65 let length = endFrame - startFrame; 66 let array = new Array(length); 67 68 let step = Math.fround( 69 (endValue - startValue) / (endTime - startTime) / sampleRate); 70 let start = Math.fround( 71 startValue + 72 (endValue - startValue) * (startFrame / sampleRate - startTime) / 73 (endTime - startTime)); 74 75 let slope = (endValue - startValue) / (endTime - startTime); 76 77 // v(t) = v0 + (v1 - v0)*(t-t0)/(t1-t0) 75 78 for (k = 0; k < length; ++k) { 76 array[k] = startValue + k * step; 79 // array[k] = Math.fround(start + k * step); 80 let t = (startFrame + k) / sampleRate; 81 array[k] = startValue + slope * (t - startTime); 77 82 } 78 83 79 84 return array; 80 } 81 82 // Create an exponential ramp starting at |startValue| and ending at |endValue|. The ramp starts at 83 // time |startTime| and ends at |endTime|. (The start and end times are only used to compute how 84 // many samples to return.) 85 function createExponentialRampArray(startTime, endTime, startValue, endValue, sampleRate) 86 { 87 var startFrame = timeToSampleFrame(startTime, sampleRate); 88 var endFrame = timeToSampleFrame(endTime, sampleRate); 89 var length = endFrame - startFrame; 90 var array = new Array(length); 91 92 var multiplier = Math.pow(endValue / startValue, 1 / length); 93 94 for (var k = 0; k < length; ++k) { 95 array[k] = startValue * Math.pow(multiplier, k); 85 } 86 87 // Create an exponential ramp starting at |startValue| and ending at 88 // |endValue|. The ramp starts at time |startTime| and ends at |endTime|. 89 // (The start and end times are only used to compute how many samples to 90 // return.) 91 function createExponentialRampArray( 92 startTime, endTime, startValue, endValue, sampleRate) { 93 let deltaTime = endTime - startTime; 94 95 let frameInfo = getStartEndFrames(startTime, endTime, sampleRate); 96 let startFrame = frameInfo.startFrame; 97 let endFrame = frameInfo.endFrame; 98 let length = endFrame - startFrame; 99 let array = new Array(length); 100 101 let ratio = endValue / startValue; 102 103 // v(t) = v0*(v1/v0)^((t-t0)/(t1-t0)) 104 for (let k = 0; k < length; ++k) { 105 let t = Math.fround((startFrame + k) / sampleRate); 106 array[k] = Math.fround( 107 startValue * Math.pow(ratio, (t - startTime) / deltaTime)); 96 108 } 97 109 98 110 return array; 99 } 100 101 function discreteTimeConstantForSampleRate(timeConstant, sampleRate) 102 { 111 } 112 113 function discreteTimeConstantForSampleRate(timeConstant, sampleRate) { 103 114 return 1 - Math.exp(-1 / (sampleRate * timeConstant)); 104 } 105 106 // Create a signal that starts at |startValue| and exponentially approaches the target value of 107 // |targetValue|, using a time constant of |timeConstant|. The ramp starts at time |startTime| and 108 // ends at |endTime|. (The start and end times are only used to compute how many samples to 109 // return.) 110 function createExponentialApproachArray(startTime, endTime, startValue, targetValue, sampleRate, timeConstant) 111 { 112 var startFrame = timeToSampleFrame(startTime, sampleRate); 113 var endFrame = timeToSampleFrame(endTime, sampleRate); 114 var length = endFrame - startFrame; 115 var array = new Array(length); 116 var c = discreteTimeConstantForSampleRate(timeConstant, sampleRate); 117 118 var value = startValue; 119 120 for (var k = 0; k < length; ++k) { 121 array[k] = value; 122 value += (targetValue - value) * c; 115 } 116 117 // Create a signal that starts at |startValue| and exponentially approaches 118 // the target value of |targetValue|, using a time constant of |timeConstant|. 119 // The ramp starts at time |startTime| and ends at |endTime|. (The start and 120 // end times are only used to compute how many samples to return.) 121 function createExponentialApproachArray( 122 startTime, endTime, startValue, targetValue, sampleRate, timeConstant) { 123 let startFrameFloat = startTime * sampleRate; 124 let frameInfo = getStartEndFrames(startTime, endTime, sampleRate); 125 let startFrame = frameInfo.startFrame; 126 let endFrame = frameInfo.endFrame; 127 let length = Math.floor(endFrame - startFrame); 128 let array = new Array(length); 129 let c = discreteTimeConstantForSampleRate(timeConstant, sampleRate); 130 131 let delta = startValue - targetValue; 132 133 // v(t) = v1 + (v0 - v1) * exp(-(t-t0)/tau) 134 for (let k = 0; k < length; ++k) { 135 let t = (startFrame + k) / sampleRate; 136 let value = 137 targetValue + delta * Math.exp(-(t - startTime) / timeConstant); 138 array[k] = value; 123 139 } 124 140 125 141 return array; 126 } 127 128 // Create a sine wave of the given frequency and amplitude. The sine wave is offset by half the 129 // amplitude so that result is always positive. 130 function createSineWaveArray(durationSeconds, freqHz, amplitude, sampleRate) 131 { 132 var length = timeToSampleFrame(durationSeconds, sampleRate); 133 var signal = new Float32Array(length); 134 var omega = 2 * Math.PI * freqHz / sampleRate; 135 var halfAmplitude = amplitude / 2; 136 137 for (var k = 0; k < length; ++k) { 138 signal[k] = halfAmplitude + halfAmplitude * Math.sin(omega * k); 142 } 143 144 // Create a sine wave of the specified duration. 145 function createReferenceSineArray( 146 startTime, endTime, startValue, endValue, sampleRate) { 147 // Ignore |startValue| and |endValue| for the sine wave. 148 let curve = createSineWaveArray( 149 endTime - startTime, freqHz, sineAmplitude, sampleRate); 150 // Sample the curve appropriately. 151 let frameInfo = getStartEndFrames(startTime, endTime, sampleRate); 152 let startFrame = frameInfo.startFrame; 153 let endFrame = frameInfo.endFrame; 154 let length = Math.floor(endFrame - startFrame); 155 let array = new Array(length); 156 157 // v(t) = linearly interpolate between V[k] and V[k + 1] where k = 158 // floor((N-1)/duration*(t - t0)) 159 let f = (length - 1) / (endTime - startTime); 160 161 for (let k = 0; k < length; ++k) { 162 let t = (startFrame + k) / sampleRate; 163 let indexFloat = f * (t - startTime); 164 let index = Math.floor(indexFloat); 165 if (index + 1 < length) { 166 let v0 = curve[index]; 167 let v1 = curve[index + 1]; 168 array[k] = v0 + (v1 - v0) * (indexFloat - index); 169 } else { 170 array[k] = curve[length - 1]; 171 } 172 } 173 174 return array; 175 } 176 177 // Create a sine wave of the given frequency and amplitude. The sine wave is 178 // offset by half the amplitude so that result is always positive. 179 function createSineWaveArray(durationSeconds, freqHz, amplitude, sampleRate) { 180 let length = timeToSampleFrame(durationSeconds, sampleRate); 181 let signal = new Float32Array(length); 182 let omega = 2 * Math.PI * freqHz / sampleRate; 183 let halfAmplitude = amplitude / 2; 184 185 for (let k = 0; k < length; ++k) { 186 signal[k] = halfAmplitude + halfAmplitude * Math.sin(omega * k); 139 187 } 140 188 141 189 return signal; 142 } 143 144 // Return the difference between the starting value and the ending value for time interval 145 // |timeIntervalIndex|. We alternate between an end value that is above or below the starting 146 // value. 147 function endValueDelta(timeIntervalIndex) 148 { 190 } 191 192 // Return the difference between the starting value and the ending value for 193 // time interval |timeIntervalIndex|. We alternate between an end value that 194 // is above or below the starting value. 195 function endValueDelta(timeIntervalIndex) { 149 196 if (timeIntervalIndex & 1) { 150 197 return -startEndValueChange; 151 198 } else { 152 return startEndValueChange; 153 } 154 } 155 156 // Return the difference between the starting value at |timeIntervalIndex| and the starting value at 157 // the next time interval. Since we started at a large initial value, we decrease the value at each 158 // time interval. 159 function valueUpdate(timeIntervalIndex) 160 { 199 return startEndValueChange; 200 } 201 } 202 203 // Relative error metric 204 function relativeErrorMetric(actual, expected) { 205 return (actual - expected) / Math.abs(expected); 206 } 207 208 // Difference metric 209 function differenceErrorMetric(actual, expected) { 210 return actual - expected; 211 } 212 213 // Return the difference between the starting value at |timeIntervalIndex| and 214 // the starting value at the next time interval. Since we started at a large 215 // initial value, we decrease the value at each time interval. 216 function valueUpdate(timeIntervalIndex) { 161 217 return -startingValueDelta; 162 } 163 164 // Compare a section of the rendered data against our expected signal. 165 function comparePartialSignals(rendered, expectedFunction, startTime, endTime, valueInfo, sampleRate) 166 { 167 var startSample = timeToSampleFrame(startTime, sampleRate); 168 var expected = expectedFunction(startTime, endTime, valueInfo.startValue, valueInfo.endValue, sampleRate, timeConstant); 169 170 var n = expected.length; 171 var maxError = -1; 172 var maxErrorIndex = -1; 173 174 for (var k = 0; k < n; ++k) { 175 // Make sure we don't pass these tests because a NaN has been generated in either the 176 // rendered data or the reference data. 177 if (!isValidNumber(rendered[startSample + k])) { 178 maxError = Infinity; 179 maxErrorIndex = startSample + k; 180 testFailed("NaN or infinity for rendered data at " + maxErrorIndex); 181 break; 182 } 183 if (!isValidNumber(expected[k])) { 184 maxError = Infinity; 185 maxErrorIndex = startSample + k; 186 testFailed("Nan or infinity for reference data at " + maxErrorIndex); 187 break; 188 } 189 var error = Math.abs(rendered[startSample + k] - expected[k]); 190 if (error > maxError) { 191 maxError = error; 192 maxErrorIndex = k; 193 } 194 } 195 196 return {maxError : maxError, index : maxErrorIndex}; 197 } 198 199 // Find the discontinuities in the data and compare the locations of the discontinuities with the 200 // times that define the time intervals. There is a discontinuity if the difference between 201 // successive samples exceeds the threshold. 202 function verifyDiscontinuities(values, times, threshold) 203 { 204 var n = values.length; 205 var success = true; 206 var badLocations = 0; 207 var breaks = []; 218 } 219 220 // Compare a section of the rendered data against our expected signal. 221 function comparePartialSignals( 222 should, rendered, expectedFunction, startTime, endTime, valueInfo, 223 sampleRate, errorMetric) { 224 let startSample = timeToSampleFrame(startTime, sampleRate); 225 let expected = expectedFunction( 226 startTime, endTime, valueInfo.startValue, valueInfo.endValue, 227 sampleRate, timeConstant); 228 229 let n = expected.length; 230 let maxError = -1; 231 let maxErrorIndex = -1; 232 233 for (let k = 0; k < n; ++k) { 234 // Make sure we don't pass these tests because a NaN has been generated in 235 // either the 236 // rendered data or the reference data. 237 if (!isValidNumber(rendered[startSample + k])) { 238 maxError = Infinity; 239 maxErrorIndex = startSample + k; 240 should( 241 isValidNumber(rendered[startSample + k]), 242 'NaN or infinity for rendered data at ' + maxErrorIndex) 243 .beTrue(); 244 break; 245 } 246 if (!isValidNumber(expected[k])) { 247 maxError = Infinity; 248 maxErrorIndex = startSample + k; 249 should( 250 isValidNumber(expected[k]), 251 'NaN or infinity for rendered data at ' + maxErrorIndex) 252 .beTrue(); 253 break; 254 } 255 let error = Math.abs(errorMetric(rendered[startSample + k], expected[k])); 256 if (error > maxError) { 257 maxError = error; 258 maxErrorIndex = k; 259 } 260 } 261 262 return {maxError: maxError, index: maxErrorIndex, expected: expected}; 263 } 264 265 // Find the discontinuities in the data and compare the locations of the 266 // discontinuities with the times that define the time intervals. There is a 267 // discontinuity if the difference between successive samples exceeds the 268 // threshold. 269 function verifyDiscontinuities(should, values, times, threshold) { 270 let n = values.length; 271 let success = true; 272 let badLocations = 0; 273 let breaks = []; 208 274 209 275 // Find discontinuities. 210 for (var k = 1; k < n; ++k) { 211 if (Math.abs(values[k] - values[k - 1]) > threshold) { 212 breaks.push(k); 213 } 214 } 215 216 var testCount; 217 218 // If there are numberOfTests intervals, there are only numberOfTests - 1 internal interval 219 // boundaries. Hence the maximum number of discontinuties we expect to find is numberOfTests - 220 // 1. If we find more than that, we have no reference to compare against. We also assume that 221 // the actual discontinuities are close to the expected ones. 276 for (let k = 1; k < n; ++k) { 277 if (Math.abs(values[k] - values[k - 1]) > threshold) { 278 breaks.push(k); 279 } 280 } 281 282 let testCount; 283 284 // If there are numberOfTests intervals, there are only numberOfTests - 1 285 // internal interval boundaries. Hence the maximum number of discontinuties 286 // we expect to find is numberOfTests - 1. If we find more than that, we 287 // have no reference to compare against. We also assume that the actual 288 // discontinuities are close to the expected ones. 222 289 // 223 // This is just a sanity check when something goes really wrong. For example, if the threshold 224 // is too low, every sample frame looks like a discontinuity. 290 // This is just a sanity check when something goes really wrong. For 291 // example, if the threshold is too low, every sample frame looks like a 292 // discontinuity. 225 293 if (breaks.length >= numberOfTests) { 226 testCount = numberOfTests - 1; 227 testFailed("Found more discontinuities (" + breaks.length + ") than expected. Only comparing first " + testCount + "discontinuities."); 294 testCount = numberOfTests - 1; 295 should(breaks.length, 'Number of discontinuities') 296 .beLessThan(numberOfTests); 297 success = false; 298 } else { 299 testCount = breaks.length; 300 } 301 302 // Compare the location of each discontinuity with the end time of each 303 // interval. (There is no discontinuity at the start of the signal.) 304 for (let k = 0; k < testCount; ++k) { 305 let expectedSampleFrame = timeToSampleFrame(times[k + 1], sampleRate); 306 if (breaks[k] != expectedSampleFrame) { 228 307 success = false; 308 ++badLocations; 309 should(breaks[k], 'Discontinuity at index') 310 .beEqualTo(expectedSampleFrame); 311 } 312 } 313 314 if (badLocations) { 315 should(badLocations, 'Number of discontinuites at incorrect locations') 316 .beEqualTo(0); 317 success = false; 229 318 } else { 230 testCount = breaks.length; 231 } 232 233 // Compare the location of each discontinuity with the end time of each interval. (There is no 234 // discontinuity at the start of the signal.) 235 for (var k = 0; k < testCount; ++k) { 236 var expectedSampleFrame = timeToSampleFrame(times[k + 1], sampleRate); 237 if (breaks[k] != expectedSampleFrame) { 238 success = false; 239 ++badLocations; 240 testFailed("Expected discontinuity at " + expectedSampleFrame + " but got " + breaks[k]); 241 } 242 } 243 244 if (badLocations) { 245 testFailed(badLocations + " discontinuities at incorrect locations"); 246 success = false; 247 } else { 248 if (breaks.length == numberOfTests - 1) { 249 testPassed("All " + numberOfTests + " tests started and ended at the correct time."); 250 } else { 251 testFailed("Found " + breaks.length + " discontinuities but expected " + (numberOfTests - 1)); 252 success = false; 253 } 254 } 255 319 should( 320 breaks.length + 1, 321 'Number of tests started and ended at the correct time') 322 .beEqualTo(numberOfTests); 323 } 324 256 325 return success; 257 } 258 259 // Compare the rendered data with the expected data. 260 // 261 // testName - string describing the test 262 // 263 // maxError - maximum allowed difference between the rendered data and the expected data 264 // 265 // rendererdData - array containing the rendered (actual) data 266 // 267 // expectedFunction - function to compute the expected data 268 // 269 // timeValueInfo - array containing information about the start and end times and the start and end 270 // values of each interval. 271 // 272 // breakThreshold - threshold to use for determining discontinuities. 273 function compareSignals(testName, maxError, renderedData, expectedFunction, timeValueInfo, breakThreshold) 274 { 275 var success = true; 276 var failedTestCount = 0; 277 var times = timeValueInfo.times; 278 var values = timeValueInfo.values; 279 var n = values.length; 280 281 success = verifyDiscontinuities(renderedData, times, breakThreshold); 282 283 for (var k = 0; k < n; ++k) { 284 var result = comparePartialSignals(renderedData, expectedFunction, times[k], times[k + 1], values[k], sampleRate); 285 286 if (result.maxError > maxError) { 287 testFailed("Incorrect value for test " + k + ". Max error = " + result.maxError + " at offset " + (result.index + timeToSampleFrame(times[k], sampleRate))); 288 ++failedTestCount; 289 } 290 } 291 292 if (failedTestCount) { 293 testFailed(failedTestCount + " tests failed out of " + n); 294 success = false; 295 } else { 296 testPassed("All " + n + " tests passed within an acceptable tolerance."); 297 } 298 299 if (success) { 300 testPassed("AudioParam " + testName + " test passed."); 301 } else { 302 testFailed("AudioParam " + testName + " test failed."); 303 } 304 } 305 306 // Create a function to test the rendered data with the reference data. 307 // 308 // testName - string describing the test 309 // 310 // error - max allowed error between rendered data and the reference data. 311 // 312 // referenceFunction - function that generates the reference data to be compared with the rendered 313 // data. 314 // 315 // jumpThreshold - optional parameter that specifies the threshold to use for detecting 316 // discontinuities. If not specified, defaults to discontinuityThreshold. 317 // 318 function checkResultFunction(testName, error, referenceFunction, jumpThreshold) 319 { 326 } 327 328 // Compare the rendered data with the expected data. 329 // 330 // testName - string describing the test 331 // 332 // maxError - maximum allowed difference between the rendered data and the 333 // expected data 334 // 335 // rendererdData - array containing the rendered (actual) data 336 // 337 // expectedFunction - function to compute the expected data 338 // 339 // timeValueInfo - array containing information about the start and end times 340 // and the start and end values of each interval. 341 // 342 // breakThreshold - threshold to use for determining discontinuities. 343 function compareSignals( 344 should, testName, maxError, renderedData, expectedFunction, timeValueInfo, 345 breakThreshold, errorMetric) { 346 let success = true; 347 let failedTestCount = 0; 348 let times = timeValueInfo.times; 349 let values = timeValueInfo.values; 350 let n = values.length; 351 let expectedSignal = []; 352 353 success = 354 verifyDiscontinuities(should, renderedData, times, breakThreshold); 355 356 for (let k = 0; k < n; ++k) { 357 let result = comparePartialSignals( 358 should, renderedData, expectedFunction, times[k], times[k + 1], 359 values[k], sampleRate, errorMetric); 360 361 expectedSignal = 362 expectedSignal.concat(Array.prototype.slice.call(result.expected)); 363 364 should( 365 result.maxError, 366 'Max error for test ' + k + ' at offset ' + 367 (result.index + timeToSampleFrame(times[k], sampleRate))) 368 .beLessThanOrEqualTo(maxError); 369 } 370 371 should( 372 failedTestCount, 373 'Number of failed tests with an acceptable relative tolerance of ' + 374 maxError) 375 .beEqualTo(0); 376 } 377 378 // Create a function to test the rendered data with the reference data. 379 // 380 // testName - string describing the test 381 // 382 // error - max allowed error between rendered data and the reference data. 383 // 384 // referenceFunction - function that generates the reference data to be 385 // compared with the rendered data. 386 // 387 // jumpThreshold - optional parameter that specifies the threshold to use for 388 // detecting discontinuities. If not specified, defaults to 389 // discontinuityThreshold. 390 // 391 function checkResultFunction( 392 task, should, testName, error, referenceFunction, jumpThreshold, 393 errorMetric) { 320 394 return function(event) { 321 var buffer = event.renderedBuffer; 322 renderedData = buffer.getChannelData(0); 323 324 var threshold; 325 326 if (!jumpThreshold) { 327 threshold = discontinuityThreshold; 328 } else { 329 threshold = jumpThreshold; 330 } 331 332 compareSignals(testName, error, renderedData, referenceFunction, timeValueInfo, threshold); 333 334 finishJSTest(); 335 } 336 } 337 338 // Run all the automation tests. 339 // 340 // numberOfTests - number of tests (time intervals) to run. 341 // 342 // initialValue - The initial value of the first time interval. 343 // 344 // setValueFunction - function that sets the specified value at the start of a time interval. 345 // 346 // automationFunction - function that sets the end value for the time interval. It specifies how 347 // the value approaches the end value. 348 // 349 // An object is returned containing an array of start times for each time interval, and an array 350 // giving the start and end values for the interval. 351 function doAutomation(numberOfTests, initialValue, setValueFunction, automationFunction) 352 { 353 var timeInfo = [0]; 354 var valueInfo = []; 355 var value = initialValue; 356 357 for (var k = 0; k < numberOfTests; ++k) { 358 var startTime = k * timeInterval; 359 var endTime = (k + 1) * timeInterval; 360 var endValue = value + endValueDelta(k); 361 362 // Set the value at the start of the time interval. 363 setValueFunction(value, startTime); 364 365 // Specify the end or target value, and how we should approach it. 366 automationFunction(endValue, startTime, endTime); 367 368 // Keep track of the start times, and the start and end values for each time interval. 369 timeInfo.push(endTime); 370 valueInfo.push({startValue: value, endValue : endValue}); 371 372 value += valueUpdate(k); 373 } 374 375 return {times : timeInfo, values : valueInfo}; 376 } 377 378 // Create the audio graph for the test and then run the test. 379 // 380 // numberOfTests - number of time intervals (tests) to run. 381 // 382 // initialValue - the initial value of the gain at time 0. 383 // 384 // setValueFunction - function to set the value at the beginning of each time interval. 385 // 386 // automationFunction - the AudioParamTimeline automation function 387 // 388 // testName - string indicating the test that is being run. 389 // 390 // maxError - maximum allowed error between the rendered data and the reference data 391 // 392 // referenceFunction - function that generates the reference data to be compared against the 393 // rendered data. 394 // 395 // jumpThreshold - optional parameter that specifies the threshold to use for detecting 396 // discontinuities. If not specified, defaults to discontinuityThreshold. 397 // 398 function createAudioGraphAndTest(numberOfTests, initialValue, setValueFunction, automationFunction, testName, maxError, referenceFunction, jumpThreshold) 399 { 400 if (window.testRunner) { 401 testRunner.dumpAsText(); 402 testRunner.waitUntilDone(); 403 } 404 405 window.jsTestIsAsync = true; 406 395 let buffer = event.renderedBuffer; 396 renderedData = buffer.getChannelData(0); 397 398 let threshold; 399 400 if (!jumpThreshold) { 401 threshold = discontinuityThreshold; 402 } else { 403 threshold = jumpThreshold; 404 } 405 406 compareSignals( 407 should, testName, error, renderedData, referenceFunction, 408 timeValueInfo, threshold, errorMetric); 409 task.done(); 410 } 411 } 412 413 // Run all the automation tests. 414 // 415 // numberOfTests - number of tests (time intervals) to run. 416 // 417 // initialValue - The initial value of the first time interval. 418 // 419 // setValueFunction - function that sets the specified value at the start of a 420 // time interval. 421 // 422 // automationFunction - function that sets the end value for the time 423 // interval. It specifies how the value approaches the end value. 424 // 425 // An object is returned containing an array of start times for each time 426 // interval, and an array giving the start and end values for the interval. 427 function doAutomation( 428 numberOfTests, initialValue, setValueFunction, automationFunction) { 429 let timeInfo = [0]; 430 let valueInfo = []; 431 let value = initialValue; 432 433 for (let k = 0; k < numberOfTests; ++k) { 434 let startTime = k * timeInterval; 435 let endTime = (k + 1) * timeInterval; 436 let endValue = value + endValueDelta(k); 437 438 // Set the value at the start of the time interval. 439 setValueFunction(value, startTime); 440 441 // Specify the end or target value, and how we should approach it. 442 automationFunction(endValue, startTime, endTime); 443 444 // Keep track of the start times, and the start and end values for each 445 // time interval. 446 timeInfo.push(endTime); 447 valueInfo.push({startValue: value, endValue: endValue}); 448 449 value += valueUpdate(k); 450 } 451 452 return {times: timeInfo, values: valueInfo}; 453 } 454 455 // Create the audio graph for the test and then run the test. 456 // 457 // numberOfTests - number of time intervals (tests) to run. 458 // 459 // initialValue - the initial value of the gain at time 0. 460 // 461 // setValueFunction - function to set the value at the beginning of each time 462 // interval. 463 // 464 // automationFunction - the AudioParamTimeline automation function 465 // 466 // testName - string indicating the test that is being run. 467 // 468 // maxError - maximum allowed error between the rendered data and the 469 // reference data 470 // 471 // referenceFunction - function that generates the reference data to be 472 // compared against the rendered data. 473 // 474 // jumpThreshold - optional parameter that specifies the threshold to use for 475 // detecting discontinuities. If not specified, defaults to 476 // discontinuityThreshold. 477 // 478 function createAudioGraphAndTest( 479 task, should, numberOfTests, initialValue, setValueFunction, 480 automationFunction, testName, maxError, referenceFunction, jumpThreshold, 481 errorMetric) { 407 482 // Create offline audio context. 408 context = new webkitOfflineAudioContext(2, renderLength(numberOfTests), sampleRate); 409 var constantBuffer = createConstantBuffer(context, 1, renderLength(numberOfTests)); 410 411 // We use an AudioGainNode here simply as a convenient way to test the AudioParam 412 // automation, since it's easy to pass a constant value through the node, automate the 413 // .gain attribute and observe the resulting values. 483 context = 484 new OfflineAudioContext(2, renderLength(numberOfTests), sampleRate); 485 let constantBuffer = 486 createConstantBuffer(context, renderLength(numberOfTests), 1); 487 488 // We use an AudioGainNode here simply as a convenient way to test the 489 // AudioParam automation, since it's easy to pass a constant value through 490 // the node, automate the .gain attribute and observe the resulting values. 414 491 415 492 gainNode = context.createGain(); 416 493 417 varbufferSource = context.createBufferSource();494 let bufferSource = context.createBufferSource(); 418 495 bufferSource.buffer = constantBuffer; 419 496 bufferSource.connect(gainNode); 420 497 gainNode.connect(context.destination); 421 498 422 // Set up default values for the parameters that control how the automation test values progress423 // for each time interval.499 // Set up default values for the parameters that control how the automation 500 // test values progress for each time interval. 424 501 startingValueDelta = initialValue / numberOfTests; 425 502 startEndValueChange = startingValueDelta / 2; … … 427 504 428 505 // Run the automation tests. 429 timeValueInfo = doAutomation(numberOfTests, 430 initialValue, 431 setValueFunction, 432 automationFunction); 506 timeValueInfo = doAutomation( 507 numberOfTests, initialValue, setValueFunction, automationFunction); 433 508 bufferSource.start(0); 434 435 context.oncomplete = checkResultFunction(testName, 436 maxError, 437 referenceFunction, 438 jumpThreshold); 509 510 context.oncomplete = checkResultFunction( 511 task, should, testName, maxError, referenceFunction, jumpThreshold, 512 errorMetric || relativeErrorMetric); 439 513 context.startRendering(); 440 } 514 } 515 516 // Export local references to global scope. All the new objects in this file 517 // must be exported through this if it is to be used in the actual test HTML 518 // page. 519 let exports = { 520 'sampleRate': 44100, 521 'gainNode': null, 522 'timeInterval': timeIntervalInternal, 523 524 // Some suitable time constant so that we can see a significant change over 525 // a timeInterval. This is only needed by setTargetAtTime() which needs a 526 // time constant. 527 'timeConstant': timeIntervalInternal / 3, 528 529 'renderLength': renderLength, 530 'createConstantArray': createConstantArray, 531 'getStartEndFrames': getStartEndFrames, 532 'createLinearRampArray': createLinearRampArray, 533 'createExponentialRampArray': createExponentialRampArray, 534 'discreteTimeConstantForSampleRate': discreteTimeConstantForSampleRate, 535 'createExponentialApproachArray': createExponentialApproachArray, 536 'createReferenceSineArray': createReferenceSineArray, 537 'createSineWaveArray': createSineWaveArray, 538 'endValueDelta': endValueDelta, 539 'relativeErrorMetric': relativeErrorMetric, 540 'differenceErrorMetric': differenceErrorMetric, 541 'valueUpdate': valueUpdate, 542 'comparePartialSignals': comparePartialSignals, 543 'verifyDiscontinuities': verifyDiscontinuities, 544 'compareSignals': compareSignals, 545 'checkResultFunction': checkResultFunction, 546 'doAutomation': doAutomation, 547 'createAudioGraphAndTest': createAudioGraphAndTest 548 }; 549 550 for (let reference in exports) { 551 global[reference] = exports[reference]; 552 } 553 554 })(window);
Note: See TracChangeset
for help on using the changeset viewer.