diff --git a/scripts/smoke.cjs b/scripts/smoke.cjs
index 2aee316..f5485ec 100644
--- a/scripts/smoke.cjs
+++ b/scripts/smoke.cjs
@@ -329,17 +329,42 @@ app.whenReady().then(async () => {
.find((w) => w.webContents.getURL() === 'screen-app://app/index.html?output=1')
.webContents.executeJavaScript(source)
if (process.argv.includes('--intro-waveform')) {
+ const selectedDevice = (await evaluate('window.screenBridge.host()')).audioOutputs
+ .find(device => device.id && !['default', 'communications'].includes(device.id))
+ if (selectedDevice)
+ await evaluate(`window.screenBridge.selectAudioOutput(${JSON.stringify(selectedDevice.id)})`)
await command({ action: 'step', index: 1 })
await poll(() => inspect('document.querySelector(".intro-waveform")?.getAttribute("aria-valuenow") === "0"'), 'intro waveform starts empty')
assert.equal(await inspect('document.querySelectorAll(".intro-recording button,.intro-recording input").length'), 0)
+ assert.equal(await inspect('document.querySelectorAll(".intro-waveform rect").length'), 128)
+ assert.equal(await inspect('document.querySelector(".intro-recording").textContent.trim()'), '')
+ assert.equal(await inspect('getComputedStyle(document.querySelector(".intro-recording")).backgroundColor'), 'rgba(0, 0, 0, 0)')
+ const bars = () => inspect('Array.from(document.querySelectorAll(".intro-waveform rect"), r => Number(r.getAttribute("height")))')
+ const sinkBefore = await inspect('document.querySelector("audio[data-channel=main-audio]").sinkId')
await command({ action: 'play', channel: 'main' })
+ await poll(async () => (await bars()).some(h => h > 3), 'wave reacts to audio')
+ const playingBars = JSON.stringify(await bars())
+ await poll(async () => JSON.stringify(await bars()) !== playingBars, 'wave changes with audio')
+ await command({ action: 'mute', enabled: true })
+ await poll(async () => (await bars()).every(h => h === 2), 'mute shows silence')
+ await command({ action: 'mute', enabled: false })
+ await poll(async () => (await bars()).some(h => h > 3), 'unmute restores wave')
+ assert.equal(await inspect('document.querySelector("audio[data-channel=main-audio]").sinkId'), sinkBefore)
await command({ action: 'seek', channel: 'main', position: 15 })
await command({ action: 'pause', channel: 'main' })
await poll(() => inspect('Number(document.querySelector(".intro-waveform").getAttribute("aria-valuenow")) >= 24'), 'intro progress follows seek')
- const pausedTime = await inspect('document.querySelector(".intro-time").textContent')
+ await poll(async () => (await state()).channels.main.status === 'paused', 'intro paused')
+ const pausedBars = await bars()
await delay(400)
- assert.equal(await inspect('document.querySelector(".intro-time").textContent'), pausedTime)
+ assert.deepEqual(await bars(), pausedBars)
writeFileSync('/tmp/screen-intro-waveform.png', (await output.webContents.capturePage()).toPNG())
+ for (const [width, height] of [[1280, 720], [1024, 768]]) {
+ output.webContents.enableDeviceEmulation({ screenPosition: 'desktop', screenSize: { width, height }, viewSize: { width, height }, deviceScaleFactor: 1, scale: 1 })
+ await poll(() => inspect(`innerWidth === ${width} && innerHeight === ${height}`), 'intro aspect ratio')
+ assert.ok(await inspect('(() => { const r = document.querySelector(".intro-waveform").getBoundingClientRect(); return Math.abs(r.x + r.width / 2 - innerWidth / 2) < 1 && Math.abs(r.y + r.height / 2 - innerHeight / 2) < 1 })()'))
+ }
+ output.webContents.disableDeviceEmulation()
+ await evaluate('window.screenBridge.selectAudioOutput("")')
const pausedPosition = await inspect('document.querySelector("audio[data-channel=main-audio]").currentTime')
await command({ action: 'resume', channel: 'main' })
await poll(() => inspect(`document.querySelector('audio[data-channel=main-audio]').currentTime > ${pausedPosition + 0.3}`), 'intro resumes')
@@ -352,13 +377,14 @@ app.whenReady().then(async () => {
await poll(() => inspect('Number(document.querySelector(".intro-waveform").getAttribute("aria-valuenow")) < 5'), 'intro replay resets progress')
await command({ action: 'seek', channel: 'main', position: 59.7 })
await poll(async () => (await state()).channels.main.status === 'ended', 'intro audio ends')
- await poll(() => inspect('document.querySelector(".intro-waveform").getAttribute("aria-valuenow") === "100"'), 'intro finishes filled')
+ await poll(() => inspect('document.querySelector(".intro-waveform").getAttribute("aria-valuenow") === "100"'), 'intro accessible progress reaches end')
+ assert.ok((await bars()).every(h => h === 2))
await command({ action: 'step', index: 2 })
await poll(() => inspect('!document.querySelector(".intro-recording")'), 'waveform hidden in other modes')
await command({ action: 'step', index: 1 })
await poll(() => inspect('document.querySelector(".intro-waveform")?.getAttribute("aria-valuenow") === "0"'), 'return to intro resets progress')
await inspect('const a = document.querySelector("audio[data-channel=main-audio]"); Object.defineProperty(a, "duration", { value: NaN, configurable: true }); a.dispatchEvent(new Event("durationchange"))')
- await poll(() => inspect('document.querySelector(".intro-time").textContent === "00:00 / —"'), 'unknown duration')
+ await poll(() => inspect('document.querySelector(".intro-waveform").getAttribute("aria-valuetext") === "00:00 / —"'), 'unknown duration')
await inspect('delete document.querySelector("audio[data-channel=main-audio]").duration')
await evaluate('window.screenBridge.closeOutput()')
await evaluate('window.screenBridge.selectPackage(null)')
@@ -366,6 +392,11 @@ app.whenReady().then(async () => {
await poll(() => BrowserWindow.getAllWindows().some((w) => w.webContents.getURL() === 'screen-app://app/index.html?output=1' && !w.webContents.isLoading()), 'new output ready')
await command({ action: 'mode', mode: 2 })
await poll(() => inspect('document.querySelector(".intro-waveform")?.getAttribute("aria-valuenow") === "0"'), 'new game starts empty')
+ await inspect('window.originalCaptureStream = HTMLMediaElement.prototype.captureStream; HTMLMediaElement.prototype.captureStream = () => { throw new Error("unavailable") }; void 0')
+ await command({ action: 'play', channel: 'main' })
+ await poll(async () => (await state()).channels.main.status === 'playing', 'visualization failure does not stop audio')
+ await poll(async () => (await bars()).every(h => h === 2), 'visualization failure shows baseline')
+ await inspect('HTMLMediaElement.prototype.captureStream = window.originalCaptureStream; void 0')
console.log('SCREEN_INTRO_WAVEFORM_PASS')
app.exit(0)
return
diff --git a/src/components/OutputPage.vue b/src/components/OutputPage.vue
index ad94a28..70ce2f4 100644
--- a/src/components/OutputPage.vue
+++ b/src/components/OutputPage.vue
@@ -18,7 +18,98 @@ const introPosition = ref(0)
const introDuration = ref
{{ introTime }}