Skip to content

Commit

Permalink
test(event) add test for #2886
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Jan 23, 2022
1 parent 446b1eb commit 51ef9c2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/src/test_cases/test_event.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if LV_BUILD_TEST
#include "../lvgl.h"

#include "unity/unity.h"

static void event_object_deletion_cb(const lv_obj_class_t *cls, lv_event_t *e)
{
LV_UNUSED(cls);
if(lv_event_get_code(e) == LV_EVENT_VALUE_CHANGED) {
lv_obj_del(lv_event_get_current_target(e));
}
}

static const lv_obj_class_t event_object_deletion_class = {
.event_cb = event_object_deletion_cb,
.base_class = &lv_obj_class
};


/* Checks for memory leaks/invalid memory accesses on deleted objects */
void test_event_object_deletion(void)
{
lv_obj_t * obj = lv_obj_class_create_obj(&event_object_deletion_class, lv_scr_act());
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
}

#endif

0 comments on commit 51ef9c2

Please sign in to comment.