Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html

Issue 2780433005: Convert AudioParam tests to new Audit (Closed)
Patch Set: Address review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html
index e86926956b4baa16f9c3f3f7bd51b1dd2d2980a3..b0a172ae935217f164d43b14f99c2d8d29240cbd 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-method-chaining.html
@@ -5,7 +5,7 @@
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
- <script src="../resources/audio-testing.js"></script>
+ <script src="../resources/audit.js"></script>
<script src="../resources/audioparam-testing.js"></script>
</head>
@@ -27,32 +27,26 @@
{ name: 'cancelScheduledValues', args: [6.0] }
];
- function verifyReturnedParam(config) {
- Should('The return value of ' + config.desc + ' matches the source AudioParam',
- config.source === config.returned)
- .beEqualTo(true);
- }
-
var audit = Audit.createTaskRunner();
// Task: testing entries from the dictionary.
- audit.defineTask('from-dictionary', function (done) {
+ audit.define('from-dictionary', (task, should) => {
var context = new AudioContext();
methodDictionary.forEach(function (method) {
var sourceParam = context.createGain().gain;
- verifyReturnedParam({
- source: sourceParam,
- returned: sourceParam[method.name](...method.args),
- desc: sourceParam.constructor.name + '.' + method.name + '()'
- });
+ should(sourceParam === sourceParam[method.name](...method.args),
+ 'The return value of ' + sourceParam.constructor.name + '.' +
+ method.name + '()' + ' matches the source AudioParam')
+ .beEqualTo(true);
+
});
- done();
+ task.done();
});
// Task: test method chaining with invalid operation.
- audit.defineTask('invalid-operation', function (done) {
+ audit.define('invalid-operation', (task, should) => {
var context = new OfflineAudioContext(1, sampleRate, sampleRate);
var osc = context.createOscillator();
var amp1 = context.createGain();
@@ -66,33 +60,37 @@
// The first operation fails with an exception, thus the second one
// should not have effect on the parameter value. Instead, it should
// maintain the default value of 1.0.
- Should('Calling setValueAtTime() with a negative end time', function () {
- amp1.gain
- .setValueAtTime(0.25, -1.0)
- .linearRampToValueAtTime(2.0, 1.0);
- }).throw('InvalidAccessError');
+ should(function () {
+ amp1.gain
+ .setValueAtTime(0.25, -1.0)
+ .linearRampToValueAtTime(2.0, 1.0);
+ },
+ 'Calling setValueAtTime() with a negative end time')
+ .throw('InvalidAccessError');
// The first operation succeeds but the second fails due to zero target
// value for the exponential ramp. Thus only the first should have effect
// on the parameter value, setting the value to 0.5.
- Should('Calling exponentialRampToValueAtTime() with a zero target value', function () {
- amp2.gain
- .setValueAtTime(0.5, 0.0)
- .exponentialRampToValueAtTime(0.0, 1.0);
- }).throw('InvalidAccessError');
+ should(function () {
+ amp2.gain
+ .setValueAtTime(0.5, 0.0)
+ .exponentialRampToValueAtTime(0.0, 1.0);
+ },
+ 'Calling exponentialRampToValueAtTime() with a zero target value')
+ .throw('InvalidAccessError');
osc.start();
osc.stop(1.0);
context.startRendering().then(function (buffer) {
- Should('The gain value of the first gain node', amp1.gain.value).beEqualTo(1.0);
- Should('The gain value of the second gain node', amp2.gain.value).beEqualTo(0.5);
- }).then(done);
+ should(amp1.gain.value, 'The gain value of the first gain node').beEqualTo(1.0);
+ should(amp2.gain.value, 'The gain value of the second gain node').beEqualTo(0.5);
+ }).then(() => task.done());
});
// Task: verify if the method chaining actually works. Create an arbitrary
// envelope and compare the result with the expected one created by JS code.
- audit.defineTask('verification', function (done) {
+ audit.define('verification', (task, should) => {
var context = new OfflineAudioContext(1, sampleRate * 4, sampleRate);
var constantBuffer = createConstantBuffer(context, 1, 1.0);
@@ -122,19 +120,12 @@
// envelope and the internal implementation. (i.e. double/float and
// rounding up) The error threshold is adjusted empirically through
// the local testing.
- Should('The rendered envelope', buffer.getChannelData(0), {
- numberOfArrayLog: 5
- }).beCloseToArray(expectedEnvelope, 4.0532e-6);
- }).then(done);
+ should(buffer.getChannelData(0), 'The rendered envelope')
+ .beCloseToArray(expectedEnvelope, {absoluteThreshold: 4.0532e-6});
+ }).then(() => task.done());
});
- audit.defineTask('finish', function (done) {
- done();
- });
-
- audit.runTasks();
-
- successfullyParsed = true;
+ audit.run();
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698