This commit is contained in:
2026-10-18 19:17:40 +07:00
parent 9542330125
commit c10ed2db01
10 changed files with 283 additions and 9 deletions
+16 -3
View File
@@ -243,12 +243,12 @@ app.whenReady().then(async () => {
assert.equal((await evaluate('window.screenBridge.packages()')).length, 1)
await evaluate(`window.screenBridge.show(${targetDisplay.id})`)
let output = await poll(
() => BrowserWindow.getAllWindows().find((w) => w !== control),
() => BrowserWindow.getAllWindows().find((w) => w.webContents.getURL() === 'screen-app://app/index.html?output=1'),
'output',
)
const inspect = (source) =>
BrowserWindow.getAllWindows()
.find((w) => w !== control)
.find((w) => w.webContents.getURL() === 'screen-app://app/index.html?output=1')
.webContents.executeJavaScript(source)
await poll(async () => (await state()).channels.main.status === 'stopped', 'fixture prepared')
if (process.platform === 'linux')
@@ -265,6 +265,19 @@ app.whenReady().then(async () => {
await checkDisplay(output)
await command({ action: 'play', channel: 'main' })
await poll(async () => (await state()).channels.main.status === 'playing', 'fixture play')
const audioHost = await evaluate('window.screenBridge.host()')
assert.equal(await evaluate('!!document.querySelector("#audio-output")'), true)
assert.equal(await evaluate('window.screenBridge.selectAudioOutput("missing").then(() => false, () => true)'), true)
if (audioHost.audioOutputs.length) {
const device = audioHost.audioOutputs[0].id
const before = await inspect('document.querySelector("audio[data-channel=main-audio]").currentTime')
await evaluate(`window.screenBridge.selectAudioOutput(${JSON.stringify(device)})`)
assert.deepEqual(await inspect('Array.from(document.querySelectorAll("audio,video")).map(media => media.sinkId)'), [device, device, device, device])
assert.equal(await inspect('document.querySelector("audio[data-channel=main-audio]").paused'), false)
assert.ok(await inspect('document.querySelector("audio[data-channel=main-audio]").currentTime') >= before)
await evaluate('window.screenBridge.selectAudioOutput("")')
assert.equal((await evaluate('window.screenBridge.host()')).audioOutputId, '')
}
await command({ action: 'pause', channel: 'main' })
await command({ action: 'resume', channel: 'main' })
await command({ action: 'stop', channel: 'main' })
@@ -599,7 +612,7 @@ app.whenReady().then(async () => {
const oldSession = (await state()).session
output.close()
await evaluate(`window.screenBridge.show(${targetDisplay.id})`)
output = await poll(() => BrowserWindow.getAllWindows().find((w) => w !== control), 'reopened')
output = await poll(() => BrowserWindow.getAllWindows().find((w) => w.webContents.getURL() === 'screen-app://app/index.html?output=1'), 'reopened')
await poll(async () => {
const s = await state()
return (