-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bin_decoder): fix memory leak (lvgl#5990)
- Loading branch information
1 parent
a28ddae
commit bcc3059
Showing
17 changed files
with
296 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,91 @@ | ||
#if LV_BUILD_TEST | ||
#include "../lvgl.h" | ||
|
||
#include "unity/unity.h" | ||
|
||
void setUp(void) | ||
{ | ||
/* Function run before every test */ | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
lv_obj_clean(lv_screen_active()); | ||
} | ||
|
||
static void create_image(const void * src) | ||
{ | ||
lv_obj_t * img = lv_image_create(lv_screen_active()); | ||
lv_image_set_src(img, src); | ||
lv_obj_center(img); | ||
} | ||
|
||
static void bin_decoder(const void * src, const char * screenshot) | ||
{ | ||
create_image(src); | ||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot); | ||
lv_obj_clean(lv_screen_active()); | ||
|
||
size_t mem_before = lv_test_get_free_mem(); | ||
for(uint32_t i = 0; i < 20; i ) { | ||
lv_obj_clean(lv_screen_active()); | ||
create_image(src); | ||
|
||
lv_obj_invalidate(lv_screen_active()); | ||
lv_refr_now(NULL); | ||
} | ||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot); | ||
lv_obj_clean(lv_screen_active()); | ||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem_before, 0); | ||
} | ||
|
||
static void create_image_tile(const void * src) | ||
{ | ||
lv_obj_t * img = lv_image_create(lv_screen_active()); | ||
lv_image_set_src(img, src); | ||
lv_obj_center(img); | ||
lv_obj_set_size(img, 275, 175); | ||
lv_image_set_inner_align(img, LV_IMAGE_ALIGN_TILE); | ||
} | ||
|
||
void bin_decoder_tile(const void * src, const char * screenshot) | ||
{ | ||
create_image_tile(src); | ||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot); | ||
lv_obj_clean(lv_screen_active()); | ||
|
||
size_t mem_before = lv_test_get_free_mem(); | ||
for(uint32_t i = 0; i < 20; i ) { | ||
lv_obj_clean(lv_screen_active()); | ||
create_image_tile(src); | ||
|
||
lv_obj_invalidate(lv_screen_active()); | ||
lv_refr_now(NULL); | ||
} | ||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot); | ||
lv_obj_clean(lv_screen_active()); | ||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem_before, 0); | ||
} | ||
|
||
void test_bin_decoder_i4(void) | ||
{ | ||
LV_IMAGE_DECLARE(test_image_cogwheel_i4); | ||
bin_decoder(&test_image_cogwheel_i4, "libs/bin_decoder_1.png"); | ||
} | ||
void test_bin_decoder_i4_tile(void) | ||
{ | ||
LV_IMAGE_DECLARE(test_image_cogwheel_i4); | ||
bin_decoder_tile(&test_image_cogwheel_i4, "libs/bin_decoder_2.png"); | ||
} | ||
void test_bin_decoder_argb8888(void) | ||
{ | ||
LV_IMAGE_DECLARE(test_image_cogwheel_argb8888); | ||
bin_decoder(&test_image_cogwheel_argb8888, "libs/bin_decoder_3.png"); | ||
} | ||
void test_bin_decoder_argb8888_tile(void) | ||
{ | ||
LV_IMAGE_DECLARE(test_image_cogwheel_argb8888); | ||
bin_decoder_tile(&test_image_cogwheel_argb8888, "libs/bin_decoder_4.png"); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,71 @@ | ||
#if LV_BUILD_TEST | ||
#include "../lvgl.h" | ||
|
||
#include "unity/unity.h" | ||
#include "lv_test_helpers.h" | ||
|
||
void setUp(void) | ||
{ | ||
/* Function run before every test */ | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
lv_obj_clean(lv_screen_active()); | ||
} | ||
|
||
static void create_image(void) | ||
{ | ||
lv_obj_t * img = lv_image_create(lv_screen_active()); | ||
lv_image_set_src(img, "A:src/test_assets/test_img_lvgl_logo.bmp"); | ||
lv_obj_center(img); | ||
} | ||
|
||
void test_bmp(void) | ||
{ | ||
create_image(); | ||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/bmp_1.png"); | ||
lv_obj_clean(lv_screen_active()); | ||
|
||
size_t mem_before = lv_test_get_free_mem(); | ||
for(uint32_t i = 0; i < 20; i ) { | ||
lv_obj_clean(lv_screen_active()); | ||
create_image(); | ||
|
||
lv_obj_invalidate(lv_screen_active()); | ||
lv_refr_now(NULL); | ||
} | ||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/bmp_1.png"); | ||
lv_obj_clean(lv_screen_active()); | ||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem_before, 0); | ||
} | ||
|
||
static void create_image_tile(void) | ||
{ | ||
lv_obj_t * img = lv_image_create(lv_screen_active()); | ||
lv_image_set_src(img, "A:src/test_assets/test_img_lvgl_logo.bmp"); | ||
lv_obj_center(img); | ||
lv_obj_set_size(img, 300, 200); | ||
lv_image_set_inner_align(img, LV_IMAGE_ALIGN_TILE); | ||
} | ||
|
||
void test_bmp_align_tile(void) | ||
{ | ||
create_image_tile(); | ||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/bmp_2.png"); | ||
lv_obj_clean(lv_screen_active()); | ||
|
||
size_t mem_before = lv_test_get_free_mem(); | ||
for(uint32_t i = 0; i < 20; i ) { | ||
lv_obj_clean(lv_screen_active()); | ||
create_image_tile(); | ||
|
||
lv_obj_invalidate(lv_screen_active()); | ||
lv_refr_now(NULL); | ||
} | ||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/bmp_2.png"); | ||
lv_obj_clean(lv_screen_active()); | ||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem_before, 0); | ||
} | ||
|
||
#endif |
Oops, something went wrong.