all tests run on puppeteer, no need for testing guards

This commit is contained in:
Yotam Mann 2024-05-03 11:50:17 -04:00
parent c6ae01aace
commit 129e20872f
16 changed files with 770 additions and 871 deletions

View file

@ -1,7 +1,6 @@
import { expect } from "chai";
import { BasicTests, warns } from "../../../test/helper/Basic.js";
import { PassAudio } from "../../../test/helper/PassAudio.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Signal } from "../../signal/Signal.js";
import { DCMeter } from "./DCMeter.js";
@ -16,7 +15,6 @@ describe("DCMeter", () => {
});
});
if (ONLINE_TESTING) {
it("can get the rms level of the incoming signal", (done) => {
const meter = new DCMeter();
const osc = new Signal(2).connect(meter);
@ -27,6 +25,5 @@ describe("DCMeter", () => {
done();
}, 400);
});
}
});
});

View file

@ -1,6 +1,5 @@
import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Noise } from "../../source/Noise.js";
import { FFT } from "./FFT.js";
@ -62,7 +61,6 @@ describe("FFT", () => {
}, 300);
});
if (ONLINE_TESTING) {
it("outputs a normal range", (done) => {
const noise = new Noise();
const fft = new FFT({
@ -81,5 +79,4 @@ describe("FFT", () => {
done();
}, 300);
});
}
});

View file

@ -1,7 +1,6 @@
import { expect } from "chai";
import { BasicTests, warns } from "../../../test/helper/Basic.js";
import { PassAudio } from "../../../test/helper/PassAudio.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Signal } from "../../signal/Signal.js";
import { Oscillator } from "../../source/oscillator/Oscillator.js";
import { Meter } from "./Meter.js";
@ -59,7 +58,6 @@ describe("Meter", () => {
});
});
if (ONLINE_TESTING) {
it("can get the rms level of the incoming signal", (done) => {
const meter = new Meter();
const osc = new Oscillator().connect(meter).start();
@ -108,6 +106,5 @@ describe("Meter", () => {
done();
}, 400);
});
}
});
});

View file

@ -1,6 +1,5 @@
import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Noise } from "../../source/Noise.js";
import { Waveform } from "./Waveform.js";
@ -25,7 +24,6 @@ describe("Waveform", () => {
anl.dispose();
});
if (ONLINE_TESTING) {
it("can run waveform analysis", (done) => {
const noise = new Noise();
const anl = new Waveform(256);
@ -43,5 +41,4 @@ describe("Waveform", () => {
done();
}, 300);
});
}
});

View file

@ -1,7 +1,6 @@
import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { atTime, Offline, whenBetween } from "../../../test/helper/Offline.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { noOp } from "../util/Interface.js";
import { Clock } from "./Clock.js";
@ -17,7 +16,6 @@ describe("Clock", () => {
clock.dispose();
});
if (ONLINE_TESTING) {
it("invokes the callback when started", (done) => {
const clock = new Clock((time) => {
clock.dispose();
@ -35,7 +33,6 @@ describe("Clock", () => {
}).start();
expect(clock.frequency.value).to.equal(8);
});
}
it("can get and set it's values with the set/get", () => {
const clock = new Clock();
@ -136,7 +133,6 @@ describe("Clock", () => {
});
context("Scheduling", () => {
if (ONLINE_TESTING) {
it("passes a time to the callback", (done) => {
const clock = new Clock((time) => {
expect(time).to.be.a("number");
@ -165,7 +161,6 @@ describe("Clock", () => {
const startTime = clock.now() + 0.1;
clock.start(startTime);
});
}
it("can be scheduled to start in the future", () => {
let invokations = 0;

View file

@ -1,5 +1,4 @@
import { expect } from "chai";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Ticker } from "./Ticker.js";
describe("Ticker", () => {
@ -30,7 +29,6 @@ describe("Ticker", () => {
ticker.dispose();
});
if (ONLINE_TESTING) {
context("timeout", () => {
it("provides a callback when set to timeout", (done) => {
const ticker = new Ticker(
@ -55,7 +53,6 @@ describe("Ticker", () => {
ticker.updateInterval = 0.1;
});
});
}
context("worker", () => {
it("provides a callback when set to worker", (done) => {

View file

@ -1,7 +1,6 @@
import { expect } from "chai";
import { ConstantOutput } from "../../../test/helper/ConstantOutput.js";
import { Offline } from "../../../test/helper/Offline.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { TransportClass } from "../clock/Transport.js";
import { getContext } from "../Global.js";
import { createAudioContext } from "./AudioContext.js";
@ -51,7 +50,6 @@ describe("Context", () => {
return ctx.close();
});
if (ONLINE_TESTING) {
it("clock is running", (done) => {
const interval = setInterval(() => {
if (getContext().currentTime > 0.5) {
@ -60,7 +58,6 @@ describe("Context", () => {
}
}, 20);
});
}
it("has a rawContext", () => {
const ctx = new Context(createAudioContext());
@ -124,7 +121,6 @@ describe("Context", () => {
});
});
if (ONLINE_TESTING) {
context("clockSource", () => {
let ctx;
beforeEach(() => {
@ -168,9 +164,7 @@ describe("Context", () => {
}, 200);
});
});
}
context("setTimeout", () => {
if (ONLINE_TESTING) {
let ctx;
beforeEach(() => {
ctx = new Context();
@ -214,7 +208,6 @@ describe("Context", () => {
wasInvoked = true;
}, 0.01);
});
}
it("is invoked in the offline context", () => {
return Offline((context) => {
@ -227,7 +220,6 @@ describe("Context", () => {
});
context("setInterval", () => {
if (ONLINE_TESTING) {
let ctx;
beforeEach(() => {
ctx = new Context();
@ -271,7 +263,6 @@ describe("Context", () => {
wasInvoked = true;
}, 0.01);
});
}
it("is invoked in the offline context", () => {
let invocationCount = 0;

View file

@ -2,7 +2,6 @@ import { Compare, Plot } from "../../../test/helper/compare/index.js";
import { expect } from "chai";
import { BasicTests, testAudioContext } from "../../../test/helper/Basic.js";
import { atTime, Offline } from "../../../test/helper/Offline.js";
import { SCHEDULE_RAMP_AFTER_SET_TARGET } from "../../../test/helper/Supports.js";
import {
BPM,
Decibels,
@ -74,7 +73,6 @@ describe("Param", () => {
});
}
if (SCHEDULE_RAMP_AFTER_SET_TARGET) {
it("correctly handles setTargetAtTime followed by a ramp", async () => {
let param;
// this fails on FF
@ -88,15 +86,9 @@ describe("Param", () => {
param: source.offset,
});
param.setTargetAtTime(2, 0.5, 0.1);
expect(param.getValueAtTime(0.6)).to.be.closeTo(
1.6,
0.1
);
expect(param.getValueAtTime(0.6)).to.be.closeTo(1.6, 0.1);
param.linearRampToValueAtTime(0.5, 0.7);
expect(param.getValueAtTime(0.6)).to.be.closeTo(
0.75,
0.1
);
expect(param.getValueAtTime(0.6)).to.be.closeTo(0.75, 0.1);
},
1.5,
1,
@ -190,10 +182,7 @@ describe("Param", () => {
param.cancelAndHoldAtTime(0.1);
param.linearRampToValueAtTime(1, 0.3);
param.cancelAndHoldAtTime(0.2);
expect(param.getValueAtTime(0.2)).to.be.closeTo(
0.5,
0.001
);
expect(param.getValueAtTime(0.2)).to.be.closeTo(0.5, 0.001);
param.exponentialRampToValueAtTime(0, 0.4);
param.cancelAndHoldAtTime(0.25);
expect(param.getValueAtTime(0.25)).to.be.closeTo(
@ -209,10 +198,7 @@ describe("Param", () => {
param.setValueAtTime(0, 0.45);
param.setValueAtTime(1, 0.48);
param.cancelAndHoldAtTime(0.45);
expect(param.getValueAtTime(0.45)).to.be.closeTo(
0,
0.001
);
expect(param.getValueAtTime(0.45)).to.be.closeTo(0, 0.001);
},
0.5,
1,
@ -243,7 +229,6 @@ describe("Param", () => {
// param.cancelAndHoldAtTime(0.4);
// }, "/base/test/audio/param/curve_0.wav", 0.01, 0.5, 1, 11025);
// });
}
});
context("Units", () => {

View file

@ -1,9 +1,7 @@
import { expect } from "chai";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { DrawClass } from "./Draw.js";
describe("Draw", () => {
if (ONLINE_TESTING) {
const draw = new DrawClass();
after(() => {
@ -13,10 +11,7 @@ describe("Draw", () => {
it("can schedule a callback at a AudioContext time", (done) => {
const scheduledTime = draw.now() + 0.2;
draw.schedule(() => {
expect(draw.context.currentTime).to.be.closeTo(
scheduledTime,
0.05
);
expect(draw.context.currentTime).to.be.closeTo(scheduledTime, 0.05);
done();
}, scheduledTime);
});
@ -26,19 +21,13 @@ describe("Draw", () => {
const firstEvent = draw.now() + 0.1;
draw.schedule(() => {
callbackCount++;
expect(draw.context.currentTime).to.be.closeTo(
firstEvent,
0.05
);
expect(draw.context.currentTime).to.be.closeTo(firstEvent, 0.05);
}, firstEvent);
const thirdEvent = draw.now() + 0.3;
draw.schedule(() => {
callbackCount++;
expect(draw.context.currentTime).to.be.closeTo(
thirdEvent,
0.05
);
expect(draw.context.currentTime).to.be.closeTo(thirdEvent, 0.05);
expect(callbackCount).to.equal(3);
done();
}, thirdEvent);
@ -46,10 +35,7 @@ describe("Draw", () => {
const secondEvent = draw.now() + 0.2;
draw.schedule(() => {
callbackCount++;
expect(draw.context.currentTime).to.be.closeTo(
secondEvent,
0.05
);
expect(draw.context.currentTime).to.be.closeTo(secondEvent, 0.05);
}, secondEvent);
});
@ -77,5 +63,4 @@ describe("Draw", () => {
done();
}, draw.now() + 0.3);
});
}
});

View file

@ -2,7 +2,6 @@ import { expect } from "chai";
import { BasicTests } from "../../test/helper/Basic.js";
import { CompareToFile } from "../../test/helper/CompareToFile.js";
import { Offline, whenBetween } from "../../test/helper/Offline.js";
import { ONLINE_TESTING } from "../../test/helper/Supports.js";
import { ToneConstantSource } from "./ToneConstantSource.js";
describe("ToneConstantSource", () => {
@ -31,7 +30,6 @@ describe("ToneConstantSource", () => {
});
context("onended", () => {
if (ONLINE_TESTING) {
it("invokes the onended callback in the online context", (done) => {
const source = new ToneConstantSource();
source.start();
@ -57,7 +55,6 @@ describe("ToneConstantSource", () => {
done();
};
});
}
it("invokes the onended callback in the offline context", () => {
let wasInvoked = false;
@ -128,7 +125,6 @@ describe("ToneConstantSource", () => {
});
});
if (ONLINE_TESTING) {
it("clamps start time to the currentTime", () => {
const source = new ToneConstantSource();
source.start(0);
@ -154,7 +150,6 @@ describe("ToneConstantSource", () => {
done();
}, 100);
});
}
});
context("State", () => {

View file

@ -1,6 +1,5 @@
import { expect } from "chai";
import { atTime, Offline } from "../../test/helper/Offline.js";
import { ONLINE_TESTING } from "../../test/helper/Supports.js";
import { ToneAudioBuffer } from "../core/context/ToneAudioBuffer.js";
import { getContext } from "../core/Global.js";
import { Player } from "./buffer/Player.js";
@ -98,7 +97,6 @@ describe("Source", () => {
}, 2);
});
if (ONLINE_TESTING) {
it("clamps start time to the currentTime", (done) => {
const source = new Oscillator();
expect(source.state).to.equal("stopped");
@ -124,7 +122,6 @@ describe("Source", () => {
}, 10);
}, 10);
});
}
it("correctly returns the scheduled play state", () => {
return Offline(() => {

View file

@ -1,6 +1,5 @@
import { BasicTests } from "../../test/helper/Basic.js";
import { UserMedia } from "./UserMedia.js";
import { GET_USER_MEDIA } from "../../test/helper/Supports.js";
import { expect } from "chai";
import { OfflineContext } from "../core/index.js";
@ -37,8 +36,6 @@ describe("UserMedia", () => {
});
});
// if it is a manual test (i.e. there is a person to 'allow' the microphone)
if (GET_USER_MEDIA && UserMedia.supported) {
context("Opening and closing", function () {
// long timeout to give testers time to allow the microphone
this.timeout(100000);
@ -176,5 +173,4 @@ describe("UserMedia", () => {
}
});
});
}
});

View file

@ -2,10 +2,6 @@ import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { CompareToFile } from "../../../test/helper/CompareToFile.js";
import { Offline } from "../../../test/helper/Offline.js";
import {
OFFLINE_BUFFERSOURCE_ONENDED,
ONLINE_TESTING,
} from "../../../test/helper/Supports.js";
import { ToneAudioBuffer } from "../../core/context/ToneAudioBuffer.js";
import { getContext } from "../../core/Global.js";
import { ToneBufferSource } from "./ToneBufferSource.js";
@ -241,7 +237,6 @@ describe("ToneBufferSource", () => {
return buffer.load("./test/audio/sine.wav");
});
if (ONLINE_TESTING) {
it.skip("schedules the onended callback in online context", (done) => {
const player = new ToneBufferSource(buffer);
player.start().stop("+0.1");
@ -251,7 +246,6 @@ describe("ToneBufferSource", () => {
done();
};
});
}
it("schedules the onended callback when offline", () => {
let wasInvoked = false;
@ -278,7 +272,6 @@ describe("ToneBufferSource", () => {
});
});
if (OFFLINE_BUFFERSOURCE_ONENDED) {
it("schedules the onended callback when the buffer is done without scheduling stop", () => {
let wasInvoked = false;
return Offline(() => {
@ -291,7 +284,6 @@ describe("ToneBufferSource", () => {
expect(wasInvoked).to.equal(true);
});
});
}
});
context("state", () => {

View file

@ -2,7 +2,6 @@ import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { CompareToFile } from "../../../test/helper/CompareToFile.js";
import { Offline, whenBetween } from "../../../test/helper/Offline.js";
import { ONLINE_TESTING } from "../../../test/helper/Supports.js";
import { Frequency } from "../../core/type/Frequency.js";
import { ToneOscillatorNode } from "./ToneOscillatorNode.js";
@ -74,7 +73,6 @@ describe("ToneOscillatorNode", () => {
});
context("onended", () => {
if (ONLINE_TESTING) {
it("invokes the onended callback in the online context", (done) => {
const osc = new ToneOscillatorNode();
osc.start();
@ -100,7 +98,6 @@ describe("ToneOscillatorNode", () => {
done();
};
});
}
it("invokes the onended callback in the offline context", () => {
let wasInvoked = false;
@ -171,7 +168,6 @@ describe("ToneOscillatorNode", () => {
});
});
if (ONLINE_TESTING) {
it("clamps start time to the currentTime", () => {
const osc = new ToneOscillatorNode();
osc.start(0);
@ -197,7 +193,6 @@ describe("ToneOscillatorNode", () => {
done();
}, 100);
});
}
});
context("State", () => {

View file

@ -1,5 +1,4 @@
import { Compare, TestAudioBuffer } from "./compare/index.js";
import "./ToneAudioBuffer.js";
import { ToneAudioBuffer } from "../../Tone/core/context/ToneAudioBuffer.js";
import { Offline } from "../../Tone/core/context/Offline.js";
import { Context } from "../../Tone/core/context/Context.js";

View file

@ -1,44 +1,28 @@
// import { UAParser } from "ua-parser-js";
// // import { UAParser } from "ua-parser-js";
// const parsed = new UAParser().getBrowser();
// // const parsed = new UAParser().getBrowser();
const name = "Chrome" as string;
// const name = "Chrome" as string;
const version = 121;
// const version = 121;
function is(browser, above?): boolean {
return false;
// above = above || 0;
// return name.includes(browser) && version >= above;
}
// function is(browser, above?): boolean {
// return false;
// // above = above || 0;
// // return name.includes(browser) && version >= above;
// }
function isnt(browser, below?): boolean {
below = below || Infinity;
return !(name.includes(browser) && version <= below);
}
// function isnt(browser, below?): boolean {
// below = below || Infinity;
// return !(name.includes(browser) && version <= below);
// }
function isntVersion(browser, browserVersion?): boolean {
return name.includes(browser) && version !== browserVersion;
}
// function isntVersion(browser, browserVersion?): boolean {
// return name.includes(browser) && version !== browserVersion;
// }
// can disconnect from a specific node
export const NODE_DISCONNECT = is("Chrome", 50);
// // if the tests run in focus
// // export const ONLINE_TESTING = isntVersion("Chrome", 71);
// offline rendering matches Chrome closely
// chrome is the platform the files were rendered on
// so it is the default for continuity testing
export const CHROME_AUDIO_RENDERING = is("Chrome");
// firefox does not correctly handle the situation where
// a linear/exponential ramp is scheduled after setTargetValueAtTime
export const SCHEDULE_RAMP_AFTER_SET_TARGET = is("Chrome");
// if the tests run in focus
export const ONLINE_TESTING = isntVersion("Chrome", 71);
// the close method resolves a promise
export const AUDIO_CONTEXT_CLOSE_RESOLVES =
isnt("Firefox") && isnt("Safari", 10);
// if it supports gUM testing
export const GET_USER_MEDIA = isnt("Safari");
// firefox does not invoke AudioBufferSourceNode.onended in the offline context
export const OFFLINE_BUFFERSOURCE_ONENDED = isnt("Firefox");
// // firefox does not invoke AudioBufferSourceNode.onended in the offline context
// // export const OFFLINE_BUFFERSOURCE_ONENDED = isnt("Firefox");