test-utils.lua: add support for defined test cases

This commit is contained in:
Ashok Sidipotu 2023-01-05 20:40:52 +05:30 committed by Julian Bouzas
parent 669b91678d
commit 0099ef2932

View file

@ -25,7 +25,7 @@ function u.createDeviceNode (name, media_class)
end
node = Node ("adapter", properties)
node:activate (Feature.Proxy.BOUND, function (n)
node:activate (Features.ALL, function (n)
local name = n.properties ["node.name"]
local mc = n.properties ["media.class"]
Log.info (n, "created and activated device node: " .. name)
@ -49,7 +49,7 @@ assert (u.metadata ~= nil)
-- hook to keep track of the linkables created.
SimpleEventHook {
name = "test-utils-linking",
name = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
@ -85,7 +85,45 @@ SimpleEventHook {
-- configure default device.
u.metadata:set (0, key, "Spa:String:JSON", args_json:get_data ())
end
end
}:register ()
-- update the defined target in node props of stream session item.
function u.set_target_in_stream (prop, lname, value)
-- Ideally the target.object originates from node properties, however the
-- stream node here is created in C before the target device is made in
-- the Lua code.
local si_props = u.lnkbls ["stream-node"].properties
if value then
si_props [prop] = value
else
si_props [prop] = u.lnkbls [lname].properties ["node.id"]
end
u.lnkbls ["stream-node"].properties = si_props
end
-- update the defined target for stream session item in metadata.
function u. set_target_in_metadata (prop, lname)
u.metadata:set (u.lnkbls ["stream-node"].properties ["node.id"], prop,
"Spa:Id", u.lnkbls [lname].properties ["node.id"])
end
function u.linkables_ready ()
local count = 0
for k, v in pairs (u.lnkbls) do
if v then
count = count + 1
end
end
if count == u.lnkbl_count then
return true
end
return false
end
return u