mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-06-07 20:18:19 +02:00
tests: wplua: add a test for asynchronous script activation
This commit is contained in:
parent
0fba80899c
commit
b29b313e7b
2 changed files with 36 additions and 0 deletions
|
|
@ -43,3 +43,9 @@ test(
|
|||
args: ['require.lua'],
|
||||
env: common_env,
|
||||
)
|
||||
test(
|
||||
'test-lua-async-activation',
|
||||
script_tester,
|
||||
args: ['async-activation.lua'],
|
||||
env: common_env,
|
||||
)
|
||||
|
|
|
|||
30
tests/wplua/scripts/async-activation.lua
Normal file
30
tests/wplua/scripts/async-activation.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
Script.async_activation = true
|
||||
|
||||
tags = {}
|
||||
|
||||
function checkpoint(x)
|
||||
Log.info(x)
|
||||
table.insert(tags, x)
|
||||
end
|
||||
|
||||
Core.timeout_add(100, function()
|
||||
checkpoint("timeout1")
|
||||
return false
|
||||
end)
|
||||
|
||||
Core.timeout_add(200, function()
|
||||
checkpoint("timeout2")
|
||||
return false
|
||||
end)
|
||||
|
||||
Core.timeout_add(300, function()
|
||||
checkpoint("timeout3")
|
||||
assert(#tags == 3)
|
||||
assert(tags[1] == "timeout1")
|
||||
assert(tags[2] == "timeout2")
|
||||
assert(tags[3] == "timeout3")
|
||||
Script:finish_activation()
|
||||
return false
|
||||
end)
|
||||
|
||||
assert(#tags == 0)
|
||||
Loading…
Add table
Reference in a new issue