fix(qrcode): fix crash due to buf_unalign modification (#4987)

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Neo Xu
2023-12-12 16:12:17 +08:00
committed by GitHub
parent 2b53325f49
commit f1e021e7b3
3 changed files with 66 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,59 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
#if LV_USE_QRCODE
static lv_obj_t * active_screen = NULL;
void setUp(void)
{
active_screen = lv_screen_active();
}
void tearDown(void)
{
lv_obj_clean(active_screen);
}
void test_barcode_normal(void)
{
lv_color_t bg_color = lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 5);
lv_color_t fg_color = lv_palette_darken(LV_PALETTE_BLUE, 4);
lv_obj_t * qr = lv_qrcode_create(active_screen);
TEST_ASSERT_NOT_NULL(qr);
lv_qrcode_set_size(qr, 150);
lv_qrcode_set_dark_color(qr, fg_color);
lv_qrcode_set_light_color(qr, bg_color);
/*Set data*/
const char * data = "https://lvgl.io";
lv_result_t res = lv_qrcode_update(qr, data, strlen(data));
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
lv_obj_center(qr);
/*Add a border with bg_color*/
lv_obj_set_style_border_color(qr, bg_color, 0);
lv_obj_set_style_border_width(qr, 5, 0);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/qrcode_1.png");
}
#else
void setUp(void)
{
}
void tearDown(void)
{
}
void test_barcode_normal(void)
{
}
#endif
#endif