1 #if LV_BUILD_TEST 2 #include "../lvgl.h" 3 4 #include "unity/unity.h" 5 event_object_deletion_cb(const lv_obj_class_t * cls,lv_event_t * e)6static void event_object_deletion_cb(const lv_obj_class_t * cls, lv_event_t * e) 7 { 8 LV_UNUSED(cls); 9 if(lv_event_get_code(e) == LV_EVENT_VALUE_CHANGED) { 10 lv_obj_del(lv_event_get_current_target(e)); 11 } 12 } 13 14 static const lv_obj_class_t event_object_deletion_class = { 15 .event_cb = event_object_deletion_cb, 16 .base_class = &lv_obj_class 17 }; 18 19 /* Checks for memory leaks/invalid memory accesses on deleted objects */ test_event_object_deletion(void)20void test_event_object_deletion(void) 21 { 22 lv_obj_t * obj = lv_obj_class_create_obj(&event_object_deletion_class, lv_scr_act()); 23 lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL); 24 } 25 26 #endif 27