test: signal: Add additional disconnection tests for Object
Add two tests that exercise the Signal::disconnect(Object *) and Signal::disconnect() methods, to verify that they correctly remove the signal from the connected object's list of signals. This triggers an issue that was detected through manual code inspection, and is expected to crash or at least generate valgrind warnings. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
0228e9c927
commit
b6d93f9772
1 changed files with 24 additions and 0 deletions
|
@ -220,6 +220,30 @@ protected:
|
|||
delete dynamicSignal;
|
||||
delete slotObject;
|
||||
|
||||
/*
|
||||
* Test that signal manual disconnection from Object removes
|
||||
* the signal for the object. This shall not generate any
|
||||
* valgrind warning.
|
||||
*/
|
||||
dynamicSignal = new Signal<>();
|
||||
slotObject = new SlotObject();
|
||||
dynamicSignal->connect(slotObject, &SlotObject::slot);
|
||||
dynamicSignal->disconnect(slotObject);
|
||||
delete dynamicSignal;
|
||||
delete slotObject;
|
||||
|
||||
/*
|
||||
* Test that signal manual disconnection from all slots removes
|
||||
* the signal for the object. This shall not generate any
|
||||
* valgrind warning.
|
||||
*/
|
||||
dynamicSignal = new Signal<>();
|
||||
slotObject = new SlotObject();
|
||||
dynamicSignal->connect(slotObject, &SlotObject::slot);
|
||||
dynamicSignal->disconnect();
|
||||
delete dynamicSignal;
|
||||
delete slotObject;
|
||||
|
||||
/* Exercise the Object slot code paths. */
|
||||
slotObject = new SlotObject();
|
||||
signalVoid_.connect(slotObject, &SlotObject::slot);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue