Browse Source

test: lua: extension: check activate/deactivate

Check that the activate and deactivate functions are correctly called
from the extension. Note that in this test, the code will wait for the
CMD_DEACTIVATE command to be executed before continuing towards
releasing the extensions_manager and all its extensions. It means that
it doesn't check the path where the extensions_manager is released
**before** the CMD_DEACTIVATE command is executed, which is more likely
to happen in the current UI scenario than the first.
pull/143/head
Alexandre Janniaux 4 years ago
committed by Jean-Baptiste Kempf
parent
commit
d82c134a93
  1. 26
      test/modules/lua/extension.c
  2. 18
      test/modules/lua/extensions/extensions.lua

26
test/modules/lua/extension.c

@ -43,8 +43,21 @@ const char vlc_module_name[] = MODULE_STRING;
static int exitcode = 0;
static int OnLuaEventTriggered(vlc_object_t *obj, const char *name,
vlc_value_t oldv, vlc_value_t newv, void *opaque)
{
(void)obj; (void)name; (void)oldv; (void)newv;
vlc_sem_t *sem = opaque;
vlc_sem_post(sem);
return VLC_SUCCESS;
}
static int OpenIntf(vlc_object_t *root)
{
vlc_object_t *libvlc = (vlc_object_t*)vlc_object_instance(root);
var_Create(libvlc, "test-lua-activate", VLC_VAR_STRING | VLC_VAR_ISCOMMAND);
var_Create(libvlc, "test-lua-deactivate", VLC_VAR_STRING | VLC_VAR_ISCOMMAND);
extensions_manager_t *mgr =
vlc_object_create(root, sizeof *mgr);
assert(mgr);
@ -61,10 +74,23 @@ static int OpenIntf(vlc_object_t *root)
goto end;
}
vlc_sem_t sem_activate, sem_deactivate;
vlc_sem_init(&sem_activate, 0);
vlc_sem_init(&sem_deactivate, 0);
var_AddCallback(libvlc, "test-lua-activate", OnLuaEventTriggered, &sem_activate);
var_AddCallback(libvlc, "test-lua-deactivate", OnLuaEventTriggered, &sem_deactivate);
/* Check that the extension from the test is correctly probed. */
assert(mgr->extensions.i_size == 1);
extension_Activate(mgr, mgr->extensions.p_elems[0]);
vlc_sem_wait(&sem_activate);
extension_Deactivate(mgr, mgr->extensions.p_elems[0]);
vlc_sem_wait(&sem_deactivate);
var_DelCallback(libvlc, "test-lua-activate", OnLuaEventTriggered, &sem_activate);
var_DelCallback(libvlc, "test-lua-deactivate", OnLuaEventTriggered, &sem_deactivate);
module_unneed(mgr, mgr->p_module);
end:

18
test/modules/lua/extensions/extensions.lua

@ -13,26 +13,32 @@ function descriptor()
}
end
function signal_test(event_name)
vlc.msg.dbg("lua test event: " .. event_name)
libvlc = vlc.object.libvlc()
vlc.var.trigger_callback(libvlc, "test-lua-" .. event_name)
end
function activate()
vlc.msg.dbg("Activate")
signal_test("activate")
end
function close()
vlc.msg.dbg("Close")
signal_test("close")
end
function deactivate()
vlc.msg.dbg("Deactivate")
signal_test("deactivate")
end
function input_changed()
vlc.msg.dbg("Input changed")
signal_test("input-changed")
end
function playing_changed()
vlc.msg.dbg("Playing changed")
signal_test("playing-changed")
end
function meta_changed()
vlc.msg.dbg("Meta changed")
signal_test("meta-changed")
end

Loading…
Cancel
Save