ci(spinner): add unit test for spinner (#3901)
BIN
tests/ref_imgs/spinner_00.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/ref_imgs/spinner_01.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/ref_imgs/spinner_02.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/ref_imgs/spinner_03.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
tests/ref_imgs/spinner_04.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
tests/ref_imgs/spinner_05.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/ref_imgs/spinner_06.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
tests/ref_imgs/spinner_07.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
tests/ref_imgs/spinner_08.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
tests/ref_imgs/spinner_09.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
@ -72,7 +72,12 @@ static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_
|
||||
LV_UNUSED(area);
|
||||
LV_UNUSED(color_p);
|
||||
|
||||
memcpy(test_fb, color_p, lv_area_get_size(area) * sizeof(lv_color_t));
|
||||
for(int y = area->y1; y <= area->y2; y++) {
|
||||
for(int x = area->x1; x <= area->x2; x++) {
|
||||
test_fb[y * HOR_RES + x] = *color_p;
|
||||
color_p++;
|
||||
}
|
||||
}
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
34
tests/src/test_cases/test_spinner.c
Normal file
@ -0,0 +1,34 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
static lv_obj_t * spinner = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_scr_act();
|
||||
spinner = lv_spinner_create(lv_scr_act(), 1000, 60);
|
||||
lv_obj_set_size(spinner, 100, 100);
|
||||
lv_obj_center(spinner);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(active_screen);
|
||||
}
|
||||
|
||||
void test_spinner_spinning(void)
|
||||
{
|
||||
for(int i = 0; i < 10; ++i) {
|
||||
lv_tick_inc(50);
|
||||
lv_task_handler();
|
||||
|
||||
char filename[15];
|
||||
snprintf(filename, 15, "spinner_%02d.png", i);
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT(filename);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|