// Regression for capture resolution normalization (#10). On scale-factor-1 // displays this is a no-op, while HiDPI displays catch capturePage inflation. const { app } = require('electron') const fs = require('node:fs') const os = require('node:os') const path = require('node:path') const { execFileSync } = require('node:child_process') const { renderMp4Job } = require('../dist-electron/renderWorker.cjs') const scene = { canvas: { width: 320, height: 240, background: '#ffffff' }, duration: 0.25, assets: [{ id: 'rect', kind: 'rect', width: 80, height: 60, fill: '#2563eb' }], layers: [ { id: 'layer-rect', assetId: 'rect', visible: true, base: { x: 160, y: 120, scaleX: 1, scaleY: 1, rotation: 0, opacity: 1 }, keyframes: [{ time: 0, props: {} }], }, ], } async function main() { const outPath = path.join(os.tmpdir(), 'ruwio-verify-resolution.mp4') fs.rmSync(outPath, { force: true }) await renderMp4Job({ jobId: 'verify-resolution', scene, options: { fps: 2, duration: 0.25, totalFrames: 1, crf: '28', preset: 'ultrafast' }, outputPath: outPath, signal: new AbortController().signal, onProgress: () => {}, }) const probe = JSON.parse(execFileSync('ffprobe', [ '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height', '-of', 'json', outPath, ]).toString()) const stream = probe.streams[0] const pass = stream.width === scene.canvas.width && stream.height === scene.canvas.height console.log(`ffprobe dimensions: ${stream.width}x${stream.height}`) console.log(pass ? 'RESULT: PASS' : 'RESULT: FAIL') app.exit(pass ? 0 : 1) } app.on('window-all-closed', () => {}) app.whenReady().then(() => main().catch((err) => { console.error('HARNESS ERROR:', err) app.exit(2) }), )