50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { setupTest, startEngine, startClientInTmux, openCmdFifo, wait, ensureGenTone, exec, tmuxCapturePane, teardownTest } from './test_utils';
|
||
import * as globals from "./test_globals";
|
||
|
||
export async function testVUMeter(): Promise<void> {
|
||
console.log("\nTest: VU METER RESPONDS TO AUDIO");
|
||
setupTest();
|
||
const engine = await startEngine();
|
||
await startClientInTmux();
|
||
openCmdFifo();
|
||
await wait(500);
|
||
|
||
// Capture initial VU line (should be empty/spaces)
|
||
let pane = tmuxCapturePane("looper", "0");
|
||
const paneLines = pane.split("\n");
|
||
// Look for any line containing x or # – that is the VU meter line.
|
||
const vuLineBefore = paneLines.find(l => /[x#]/.test(l)) || "";
|
||
console.log(` Initial VU line: "${vuLineBefore.trim()}"`);
|
||
|
||
// Generate tone in background (does not block the test)
|
||
ensureGenTone();
|
||
const toneProc = exec(`${globals.GEN_TONE_BIN} 3.0 "looper:ch0in"`, { timeout: 8000 });
|
||
|
||
// Wait for audio to start reaching the meter
|
||
await wait(1500);
|
||
|
||
// Capture pane while tone is playing
|
||
pane = tmuxCapturePane("looper", "0");
|
||
const paneLines2 = pane.split("\n");
|
||
// Same detection as above
|
||
const vuLineDuring = paneLines2.find(l => /[x#]/.test(l)) || "";
|
||
console.log(` VU line during tone: "${vuLineDuring.trim()}"`);
|
||
|
||
// The VU meter should show non-space characters (at least one 'x' or '#')
|
||
const hasSignal = /[x#]/.test(vuLineDuring);
|
||
if (hasSignal) {
|
||
console.log(" PASS: VU meter shows signal (non‑space characters)");
|
||
} else {
|
||
console.log(" FAIL: VU meter line does not show any signal characters");
|
||
console.log(" Pane excerpt:\n" + pane.slice(0, 2000));
|
||
engine.kill(); teardownTest();
|
||
throw new Error("VU meter not responsive");
|
||
}
|
||
|
||
// Wait for tone process to finish
|
||
try { toneProc.kill(); } catch {}
|
||
|
||
engine.kill();
|
||
teardownTest();
|
||
}
|