1 #if LV_BUILD_TEST 2 #include "../lvgl.h" 3 4 #if LV_USE_SNAPSHOT 5 6 #include "unity/unity.h" 7 8 #define NUM_SNAPSHOTS 1 9 test_snapshot_should_not_leak_memory(void)10void test_snapshot_should_not_leak_memory(void) 11 { 12 uint32_t idx = 0; 13 uint32_t initial_available_memory = 0; 14 uint32_t final_available_memory = 0; 15 lv_mem_monitor_t monitor; 16 17 lv_img_dsc_t * snapshots[NUM_SNAPSHOTS] = {NULL}; 18 19 lv_mem_monitor(&monitor); 20 initial_available_memory = monitor.free_size; 21 22 for(idx = 0; idx < NUM_SNAPSHOTS; idx++) { 23 snapshots[idx] = lv_snapshot_take(lv_scr_act(), LV_IMG_CF_TRUE_COLOR_ALPHA); 24 TEST_ASSERT_NOT_NULL(snapshots[idx]); 25 } 26 27 for(idx = 0; idx < NUM_SNAPSHOTS; idx++) { 28 lv_snapshot_free(snapshots[idx]); 29 } 30 31 lv_mem_monitor(&monitor); 32 final_available_memory = monitor.free_size; 33 34 TEST_ASSERT_EQUAL(initial_available_memory, final_available_memory); 35 } 36 37 #else /*LV_USE_SNAPSHOT*/ 38 test_snapshot_should_not_leak_memory(void)39void test_snapshot_should_not_leak_memory(void) 40 { 41 42 } 43 44 #endif 45 46 #endif 47