fix
This commit is contained in:
@@ -258,6 +258,58 @@ app.whenReady().then(async () => {
|
||||
return s.sequence >= sequence && (!c || c.status !== 'pending') && s
|
||||
}, JSON.stringify(intent))
|
||||
}
|
||||
if (process.argv.includes('--sound-check')) {
|
||||
const devices = BrowserWindow.getAllWindows().find((w) => w.webContents.getURL().includes('audio-devices=1'))
|
||||
const inspectAudio = (source) => devices.webContents.executeJavaScript(source)
|
||||
await command({ action: 'mute', enabled: true })
|
||||
await command({ action: 'volume', channel: 'main', volume: 37 })
|
||||
await command({ action: 'volume', channel: 'music', volume: 29 })
|
||||
const before = await state()
|
||||
await poll(() => evaluate('!!document.querySelector("[data-testid=check-sound]:not([disabled])")'), 'sound check enabled')
|
||||
await evaluate('document.querySelector("[data-testid=check-sound]").click()')
|
||||
await poll(() => inspectAudio('!document.querySelector("audio").paused'), 'test signal playing without output')
|
||||
assert.equal(await evaluate('document.querySelector("[data-testid=check-sound]").disabled'), true)
|
||||
assert.equal(await evaluate('!!document.querySelector("#audio-output .n-base-selection--disabled")'), true)
|
||||
await assert.rejects(evaluate('window.screenBridge.checkSound()'), /уже выполняется/)
|
||||
await assert.rejects(evaluate('window.screenBridge.selectAudioOutput("")'), /проверки звука/)
|
||||
assert.equal(await inspectAudio('document.querySelector("audio").muted'), false)
|
||||
await poll(() => evaluate('!document.querySelector("[data-testid=check-sound]").disabled'), 'test signal completed')
|
||||
assert.equal(await inspectAudio('document.querySelector("audio").getAttribute("src")'), null)
|
||||
assert.equal((await state()).outputOpen, false)
|
||||
assert.equal((await state()).muted, true)
|
||||
assert.deepEqual((await state()).channels, before.channels)
|
||||
const audioHost = await evaluate('window.screenBridge.host()')
|
||||
if (audioHost.audioOutputs.length) {
|
||||
const id = audioHost.audioOutputs[0].id
|
||||
await evaluate(`window.screenBridge.selectAudioOutput(${JSON.stringify(id)})`)
|
||||
await evaluate('window.screenBridge.checkSound()')
|
||||
assert.equal(await inspectAudio('document.querySelector("audio").sinkId'), id)
|
||||
}
|
||||
await evaluate(`window.screenBridge.show(${targetDisplay.id})`)
|
||||
await poll(async () => (await state()).channels.main.status === 'stopped', 'output prepared')
|
||||
await command({ action: 'play', channel: 'main' })
|
||||
const playing = (await state()).channels.main
|
||||
await evaluate('window.screenBridge.checkSound()')
|
||||
const after = (await state()).channels.main
|
||||
assert.equal(after.desired, 'playing')
|
||||
assert.equal(after.operation, playing.operation)
|
||||
assert.equal(after.volume, playing.volume)
|
||||
assert.deepEqual(after.source, playing.source)
|
||||
assert.equal((await state()).muted, true)
|
||||
const outputWindow = BrowserWindow.getAllWindows().find((w) => w.webContents.getURL().includes('output=1'))
|
||||
await assert.rejects(outputWindow.webContents.executeJavaScript('window.screenBridge.checkSound()'), /Недоступно/)
|
||||
await inspectAudio('window.originalSetSinkId = HTMLMediaElement.prototype.setSinkId; HTMLMediaElement.prototype.setSinkId = async () => { throw new Error("TEST_MISSING_DEVICE") }; void 0')
|
||||
await assert.rejects(evaluate('window.screenBridge.checkSound()'), /TEST_MISSING_DEVICE/)
|
||||
await inspectAudio('HTMLMediaElement.prototype.setSinkId = window.originalSetSinkId; void 0')
|
||||
await inspectAudio('window.originalPlay = HTMLMediaElement.prototype.play; HTMLMediaElement.prototype.play = () => Promise.resolve(); void 0')
|
||||
await assert.rejects(evaluate('window.screenBridge.checkSound()'), /Превышено время проверки/)
|
||||
assert.equal(await inspectAudio('document.querySelector("audio").getAttribute("src")'), null)
|
||||
await inspectAudio('HTMLMediaElement.prototype.play = window.originalPlay; void 0')
|
||||
await evaluate('window.screenBridge.checkSound()')
|
||||
console.log('SCREEN_SOUND_CHECK_PASS')
|
||||
app.exit(0)
|
||||
return
|
||||
}
|
||||
assert.equal(await evaluate('typeof window.require'), 'undefined')
|
||||
assert.equal((await evaluate('window.screenBridge.packages()')).length, 1)
|
||||
if (process.argv.includes('--intro-waveform'))
|
||||
|
||||
Reference in New Issue
Block a user