diff --git a/tests/scripts/scripts/00-test-linking-non-default-device-node.lua b/tests/scripts/scripts/00-test-linking-non-default-device-node.lua index 3dad25b2..a14927b3 100644 --- a/tests/scripts/scripts/00-test-linking-non-default-device-node.lua +++ b/tests/scripts/scripts/00-test-linking-non-default-device-node.lua @@ -8,7 +8,28 @@ Script.async_activation = true tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") +-- hook to create stream node, stream is created after the device nodes are +-- ready +SimpleEventHook { + name = "linkable-added@test-linking", + after = "linkable-added@test-utils-linking", + interests = { + -- on linkable added or removed, where linkable is adapter or plain node + EventInterest { + Constraint { "event.type", "=", "session-item-added" }, + Constraint { "event.session-item.interface", "=", "linkable" }, + Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" }, + }, + }, + execute = function (event) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + tu.createStreamNode ("playback") + end + end +}:register () SimpleEventHook { name = "linking/test-linking", @@ -21,7 +42,6 @@ SimpleEventHook { execute = function (event) local source, om, si, si_props, si_flags, target = pu:unwrap_find_target_event (event) - if not target then return end diff --git a/tests/scripts/scripts/01-test-linking-non-default-device-node-capture.lua b/tests/scripts/scripts/01-test-linking-non-default-device-node-capture.lua index 2f0fc121..75bf9614 100644 --- a/tests/scripts/scripts/01-test-linking-non-default-device-node-capture.lua +++ b/tests/scripts/scripts/01-test-linking-non-default-device-node-capture.lua @@ -8,7 +8,27 @@ Script.async_activation = true tu.createDeviceNode ("nondefault-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") +-- hook to create stream node, stream is created after the device nodes are +-- ready +SimpleEventHook { + name = "linkable-added@test-linking", + after = "linkable-added@test-utils-linking", + interests = { + -- on linkable added or removed, where linkable is adapter or plain node + EventInterest { + Constraint { "event.type", "=", "session-item-added" }, + Constraint { "event.session-item.interface", "=", "linkable" }, + Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" }, + }, + }, + execute = function (event) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + tu.createStreamNode ("capture") + end + end +}:register () SimpleEventHook { name = "linking/test-linking", diff --git a/tests/scripts/scripts/02-test-linking-default-device-node.lua b/tests/scripts/scripts/02-test-linking-default-device-node.lua index babd6ba6..dc6a65a6 100644 --- a/tests/scripts/scripts/02-test-linking-default-device-node.lua +++ b/tests/scripts/scripts/02-test-linking-default-device-node.lua @@ -9,7 +9,28 @@ Script.async_activation = true tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") +-- hook to create stream node, stream is created after the device nodes are +-- ready +SimpleEventHook { + name = "linkable-added@test-linking", + after = "linkable-added@test-utils-linking", + interests = { + -- on linkable added or removed, where linkable is adapter or plain node + EventInterest { + Constraint { "event.type", "=", "session-item-added" }, + Constraint { "event.session-item.interface", "=", "linkable" }, + Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" }, + }, + }, + execute = function (event) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + tu.createStreamNode ("playback") + end + end +}:register () SimpleEventHook { name = "linking/test-linking", diff --git a/tests/scripts/scripts/03-test-linking-default-device-node-capture.lua b/tests/scripts/scripts/03-test-linking-default-device-node-capture.lua index 2006bfd1..50ae7109 100644 --- a/tests/scripts/scripts/03-test-linking-default-device-node-capture.lua +++ b/tests/scripts/scripts/03-test-linking-default-device-node-capture.lua @@ -9,7 +9,28 @@ Script.async_activation = true tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") -tu.createStreamNode ("stream-node", "Stream/Input/Audio") +-- hook to create stream node, stream is created after the device nodes are +-- ready +SimpleEventHook { + name = "linkable-added@test-linking", + after = "linkable-added@test-utils-linking", + interests = { + -- on linkable added or removed, where linkable is adapter or plain node + EventInterest { + Constraint { "event.type", "=", "session-item-added" }, + Constraint { "event.session-item.interface", "=", "linkable" }, + Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" }, + }, + }, + execute = function (event) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + tu.createStreamNode ("capture") + end + end +}:register () SimpleEventHook { name = "linking/test-linking", diff --git a/tests/scripts/scripts/04-test-linking-defined-device-node-target-object-string.lua b/tests/scripts/scripts/04-test-linking-defined-device-node-target-object-string.lua index ae344752..6d4c73b3 100644 --- a/tests/scripts/scripts/04-test-linking-defined-device-node-target-object-string.lua +++ b/tests/scripts/scripts/04-test-linking-defined-device-node-target-object-string.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,8 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node") + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.id"] + } + tu.createStreamNode ("playback", props) end end }:register () diff --git a/tests/scripts/scripts/05-test-linking-defined-device-node-target-object-int.lua b/tests/scripts/scripts/05-test-linking-defined-device-node-target-object-int.lua index d77f1623..6f3252ef 100644 --- a/tests/scripts/scripts/05-test-linking-defined-device-node-target-object-int.lua +++ b/tests/scripts/scripts/05-test-linking-defined-device-node-target-object-int.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,9 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node", - tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"])) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]), + } + tu.createStreamNode ("playback", props) end end }:register () diff --git a/tests/scripts/scripts/06-test-linking-defined-device-node-target-object-name.lua b/tests/scripts/scripts/06-test-linking-defined-device-node-target-object-name.lua index 8bc8b49b..f1446158 100644 --- a/tests/scripts/scripts/06-test-linking-defined-device-node-target-object-name.lua +++ b/tests/scripts/scripts/06-test-linking-defined-device-node-target-object-name.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,9 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node", - tu.lnkbls ["defined-device-node"].properties ["node.name"]) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.name"] + } + tu.createStreamNode ("playback", props) end end }:register () diff --git a/tests/scripts/scripts/07-test-linking-defined-device-node-target-object-string-capture.lua b/tests/scripts/scripts/07-test-linking-defined-device-node-target-object-string-capture.lua index 05b77e72..88b132d9 100644 --- a/tests/scripts/scripts/07-test-linking-defined-device-node-target-object-string-capture.lua +++ b/tests/scripts/scripts/07-test-linking-defined-device-node-target-object-string-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,9 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node", - tonumber (tu.lnkbls ["defined-device-node"].properties ["node.name"])) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.id"] + } + tu.createStreamNode ("capture", props) end end }:register () diff --git a/tests/scripts/scripts/08-test-linking-defined-device-node-target-object-int-capture.lua b/tests/scripts/scripts/08-test-linking-defined-device-node-target-object-int-capture.lua index b4df20af..fb766f77 100644 --- a/tests/scripts/scripts/08-test-linking-defined-device-node-target-object-int-capture.lua +++ b/tests/scripts/scripts/08-test-linking-defined-device-node-target-object-int-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,9 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node", - tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"])) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]), + } + tu.createStreamNode ("capture", props) end end }:register () diff --git a/tests/scripts/scripts/09-test-linking-defined-device-node-target-object-name-capture.lua b/tests/scripts/scripts/09-test-linking-defined-device-node-target-object-name-capture.lua index 3058127b..749ccbbf 100644 --- a/tests/scripts/scripts/09-test-linking-defined-device-node-target-object-name-capture.lua +++ b/tests/scripts/scripts/09-test-linking-defined-device-node-target-object-name-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,9 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node", - tu.lnkbls ["defined-device-node"].properties ["node.name"]) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.name"] + } + tu.createStreamNode ("capture", props) end end }:register () diff --git a/tests/scripts/scripts/10-test-linking-defined-device-node-node-target.lua b/tests/scripts/scripts/10-test-linking-defined-device-node-node-target.lua index 0a003d82..d146b10f 100644 --- a/tests/scripts/scripts/10-test-linking-defined-device-node-node-target.lua +++ b/tests/scripts/scripts/10-test-linking-defined-device-node-node-target.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,8 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("node.target", "defined-device-node") + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["node.target"] = tu.lnkbls ["defined-device-node"].properties ["node.id"] + } + tu.createStreamNode ("playback", props) end end }:register () diff --git a/tests/scripts/scripts/11-test-linking-defined-device-node-node-target-capture.lua b/tests/scripts/scripts/11-test-linking-defined-device-node-node-target-capture.lua index eede3afc..7b0dc283 100644 --- a/tests/scripts/scripts/11-test-linking-defined-device-node-node-target-capture.lua +++ b/tests/scripts/scripts/11-test-linking-defined-device-node-node-target-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,8 +25,13 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("node.target", "defined-device-node") + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + if tu.linkables_ready () and name ~= "stream-node" then + local props = { + ["node.target"] = tu.lnkbls ["defined-device-node"].properties ["node.id"] + } + tu.createStreamNode ("capture", props) end end }:register () diff --git a/tests/scripts/scripts/12-test-linking-defined-device-node-target-node-metadata.lua b/tests/scripts/scripts/12-test-linking-defined-device-node-target-node-metadata.lua index 9f88e1da..8300f0d8 100644 --- a/tests/scripts/scripts/12-test-linking-defined-device-node-target-node-metadata.lua +++ b/tests/scripts/scripts/12-test-linking-defined-device-node-target-node-metadata.lua @@ -11,7 +11,32 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") +-- hook to create stream node, stream is created after the device nodes are +-- ready +SimpleEventHook { + name = "linkable-added@test-linking", + after = "linkable-added@test-utils-linking", + interests = { + -- on linkable added or removed, where linkable is adapter or plain node + EventInterest { + Constraint { "event.type", "=", "session-item-added" }, + Constraint { "event.session-item.interface", "=", "linkable" }, + Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" }, + }, + }, + execute = function (event) + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + tu.createStreamNode ("playback") + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready + tu.set_target_in_metadata ("target.node", "defined-device-node") + end + end +}:register () -- hook to selet defined target SimpleEventHook { @@ -55,9 +80,9 @@ SimpleEventHook { local link = pu.lookupLink (si.id, si_flags.peer_id) assert (link ~= nil) assert (si_props ["node.name"] == "stream-node") - assert (target.properties ["node.name"] == "defined-device-node") assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0) - - Script:finish_activation () + if (target.properties ["node.name"] == "defined-device-node") then + Script:finish_activation () + end end }:register () diff --git a/tests/scripts/scripts/13-test-linking-defined-device-node-target-node-metadata-capture.lua b/tests/scripts/scripts/13-test-linking-defined-device-node-target-node-metadata-capture.lua index 0bbd4a42..d70bca19 100644 --- a/tests/scripts/scripts/13-test-linking-defined-device-node-target-node-metadata-capture.lua +++ b/tests/scripts/scripts/13-test-linking-defined-device-node-target-node-metadata-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,7 +25,14 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + tu.createStreamNode ("capture") + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready tu.set_target_in_metadata ("target.node", "defined-device-node") end end @@ -55,9 +61,9 @@ SimpleEventHook { local link = pu.lookupLink (si.id, si_flags.peer_id) assert (link ~= nil) assert (si_props ["node.name"] == "stream-node") - assert (target.properties ["node.name"] == "defined-device-node") assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0) - - Script:finish_activation () + if (target.properties ["node.name"] == "defined-device-node") then + Script:finish_activation () + end end }:register () diff --git a/tests/scripts/scripts/14-test-linking-defined-device-node-target-object-metadata.lua b/tests/scripts/scripts/14-test-linking-defined-device-node-target-object-metadata.lua index 0abb9555..4f03b3ff 100644 --- a/tests/scripts/scripts/14-test-linking-defined-device-node-target-object-metadata.lua +++ b/tests/scripts/scripts/14-test-linking-defined-device-node-target-object-metadata.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink") tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,7 +25,14 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + tu.createStreamNode ("playback") + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready tu.set_target_in_metadata ("target.object", "defined-device-node") end end @@ -55,9 +61,10 @@ SimpleEventHook { local link = pu.lookupLink (si.id, si_flags.peer_id) assert (link ~= nil) assert (si_props ["node.name"] == "stream-node") - assert (target.properties ["node.name"] == "defined-device-node") assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0) - Script:finish_activation () + if (target.properties ["node.name"] == "defined-device-node") then + Script:finish_activation () + end end }:register () diff --git a/tests/scripts/scripts/15-test-linking-defined-device-node-target-object-metadata-capture.lua b/tests/scripts/scripts/15-test-linking-defined-device-node-target-object-metadata-capture.lua index 4527991d..e1ea9dee 100644 --- a/tests/scripts/scripts/15-test-linking-defined-device-node-target-object-metadata-capture.lua +++ b/tests/scripts/scripts/15-test-linking-defined-device-node-target-object-metadata-capture.lua @@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source") tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -26,7 +25,14 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + tu.createStreamNode ("capture") + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready tu.set_target_in_metadata ("target.object", "defined-device-node") end end @@ -55,9 +61,10 @@ SimpleEventHook { local link = pu.lookupLink (si.id, si_flags.peer_id) assert (link ~= nil) assert (si_props ["node.name"] == "stream-node") - assert (target.properties ["node.name"] == "defined-device-node") assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0) - Script:finish_activation () + if (target.properties ["node.name"] == "defined-device-node") then + Script:finish_activation () + end end }:register () diff --git a/tests/scripts/scripts/16-test-linking-defined-device-node-target-object-int-metadata.lua b/tests/scripts/scripts/16-test-linking-defined-device-node-target-object-int-metadata.lua index 4d8e152e..73243023 100644 --- a/tests/scripts/scripts/16-test-linking-defined-device-node-target-object-int-metadata.lua +++ b/tests/scripts/scripts/16-test-linking-defined-device-node-target-object-int-metadata.lua @@ -12,9 +12,8 @@ tu.createDeviceNode ("default-device-node", "Audio/Sink") tu.createDeviceNode ("defined-device-node-in-props", "Audio/Sink") tu.createDeviceNode ("defined-device-node-in-metadata", "Audio/Sink") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -27,9 +26,18 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node-in-props") - tu.set_target_in_metadata ("target.node", "defined-device-node-in-metadata") + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node-in-props"].properties ["node.id"] + } + tu.createStreamNode ("playback", props) + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready + tu.set_target_in_metadata ("target.object", "defined-device-node-in-metadata") end end }:register () @@ -57,9 +65,9 @@ SimpleEventHook { local link = pu.lookupLink (si.id, si_flags.peer_id) assert (link ~= nil) assert (si_props ["node.name"] == "stream-node") - assert (target.properties ["node.name"] == "defined-device-node-in-metadata") assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0) - - Script:finish_activation () + if (target.properties ["node.name"] == "defined-device-node-in-metadata") then + Script:finish_activation () + end end }:register () diff --git a/tests/scripts/scripts/17-test-linking-defined-device-node-target-object-int-metadata-capture.lua b/tests/scripts/scripts/17-test-linking-defined-device-node-target-object-int-metadata-capture.lua index 0f0a0db7..699fe01d 100644 --- a/tests/scripts/scripts/17-test-linking-defined-device-node-target-object-int-metadata-capture.lua +++ b/tests/scripts/scripts/17-test-linking-defined-device-node-target-object-int-metadata-capture.lua @@ -12,9 +12,8 @@ tu.createDeviceNode ("default-device-node", "Audio/Source") tu.createDeviceNode ("defined-device-node-in-props", "Audio/Source") tu.createDeviceNode ("defined-device-node-in-metadata", "Audio/Source") -tu.createStreamNode ("stream-node") - --- hook to selet defined target +-- hook to create stream node, stream is created after the device nodes are +-- ready SimpleEventHook { name = "linkable-added@test-linking", after = "linkable-added@test-utils-linking", @@ -27,9 +26,18 @@ SimpleEventHook { }, }, execute = function (event) - if tu.linkables_ready () then - tu.set_target_in_stream ("target.object", "defined-device-node-in-props") - tu.set_target_in_metadata ("target.node", "defined-device-node-in-metadata") + local lnkbl = event:get_subject () + local name = lnkbl.properties ["node.name"] + + if tu.linkables_ready () and name ~= "stream-node" then + -- all linkables created execept stream-node + local props = { + ["target.object"] = tu.lnkbls ["defined-device-node-in-props"].properties ["node.id"] + } + tu.createStreamNode ("capture", props) + elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then + -- when "stream-node" linkable is ready + tu.set_target_in_metadata ("target.object", "defined-device-node-in-metadata") end end }:register ()