feat(test) first experiement with Unity test engine

This commit is contained in:
Gabor Kiss-Vamosi
2021-06-02 15:41:47 +02:00
parent 428db9494d
commit c26bcf1cc6
37 changed files with 4759 additions and 5582 deletions
+2
View File
@@ -0,0 +1,2 @@
*.out
*_Runner.c
+5 -14
View File
@@ -16,25 +16,16 @@ WARNINGS += -Wpedantic -pedantic-errors
#-Wno-unused-value -Wno-unused-parameter #-Wno-unused-value -Wno-unused-parameter
OPTIMIZATION ?= -O3 -g0 OPTIMIZATION ?= -O3 -g0
CFLAGS ?= -I$(LVGL_DIR)/ $(DEFINES) $(WARNINGS) $(OPTIMIZATION) -I$(LVGL_DIR) -I. CFLAGS ?= -I$(LVGL_DIR)/ -Iunity $(DEFINES) $(WARNINGS) $(OPTIMIZATION) -I$(LVGL_DIR) -I.
LDFLAGS ?= -lpng LDFLAGS ?= -lpng
BIN ?= demo BIN ?= test
#Collect the files to compile
MAINSRC = ./lv_test_main.c
include ../lvgl.mk include ../lvgl.mk
CSRCS += lv_test_assert.c CSRCS += ${TEST_SRC}
CSRCS += lv_test_core/lv_test_core.c CSRCS += unity/unity.c
CSRCS += lv_test_core/lv_test_obj.c CSRCS += lv_test_init.c
CSRCS += lv_test_core/lv_test_style.c
CSRCS += lv_test_core/lv_test_font_loader.c
CSRCS += lv_test_widgets/lv_test_label.c
CSRCS += lv_test_fonts/font_1.c
CSRCS += lv_test_fonts/font_2.c
CSRCS += lv_test_fonts/font_3.c
OBJEXT ?= .o OBJEXT ?= .o
+11 -167
View File
@@ -9,7 +9,7 @@ lvgldirname = '"' + lvgldirname + '"'
base_defines = '"-DLV_CONF_PATH=' + lvgldirname +'/tests/lv_test_conf.h -DLV_BUILD_TEST"' base_defines = '"-DLV_CONF_PATH=' + lvgldirname +'/tests/lv_test_conf.h -DLV_BUILD_TEST"'
optimization = '"-O3 -g0"' optimization = '"-O3 -g0"'
def build(name, defines): def build(name, defines, test_name):
global base_defines, optimization global base_defines, optimization
print("=============================") print("=============================")
@@ -22,13 +22,10 @@ def build(name, defines):
d_all += " -D" + d + "=" + str(defines[d]) d_all += " -D" + d + "=" + str(defines[d])
d_all += '"' d_all += '"'
cmd = "make -j8 BIN=test.bin LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization test_file_name = test_name + ".c"
test_file_runner_name = test_name + "_Runner.c"
print("---------------------------") cmd = "make -j8 BIN=test.bin MAINSRC=" + test_file_name + " TEST_SRC=" + test_file_runner_name + " LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization
print("Clean")
print("---------------------------")
os.system("make clean LVGL_DIR_NAME=" + lvgldirname)
os.system("rm -f ./test.bin")
print("---------------------------") print("---------------------------")
print("Build") print("Build")
print("---------------------------") print("---------------------------")
@@ -49,162 +46,9 @@ def build(name, defines):
print("Finished") print("Finished")
print("---------------------------") print("---------------------------")
minimal_monochrome = { def clean():
"LV_COLOR_DEPTH":1, print("---------------------------")
"LV_MEM_SIZE":64 * 1024, print("Clean")
print("---------------------------")
"LV_DPI_DEF":40, os.system("make clean LVGL_DIR_NAME=" + lvgldirname)
"LV_DRAW_COMPLEX":0, os.system("rm -f ./test.bin")
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
minimal_16bit = {
"LV_COLOR_DEPTH":16,
"LV_MEM_CUSTOM":1,
"LV_DPI_DEF":40,
"LV_DRAW_COMPLEX":0,
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
minimal_16bit_swap = {
"LV_COLOR_DEPTH":16,
"LV_COLOR_16_SWAP":1,
"LV_MEM_SIZE":64 * 1024,
"LV_DPI_DEF":40,
"LV_DRAW_COMPLEX":0,
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_FONT_SUBPX": 1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
full_32bit = {
"LV_COLOR_DEPTH":32,
"LV_MEM_SIZE":8 * 1024 * 1024,
"LV_DPI_DEF":160,
"LV_DRAW_COMPLEX":1,
"LV_SHADOW_CACHE_SIZE":1,
"LV_IMG_CACHE_DEF_SIZE":32,
"LV_USE_LOG":1,
"LV_LOG_PRINTF":1,
"LV_USE_FONT_SUBPX": 1,
"LV_FONT_SUBPX_BGR":1,
"LV_USE_PERF_MONITOR":1,
"LV_USE_ASSERT_NULL":1,
"LV_USE_ASSERT_MALLOC":1,
"LV_USE_ASSERT_MEM_INTEGRITY":1,
"LV_USE_ASSERT_OBJ":1,
"LV_USE_ASSERT_STYLE":1,
"LV_USE_USER_DATA": 1,
"LV_USE_LARGE_COORD": 1,
"LV_FONT_MONTSERRAT_8":1,
"LV_FONT_MONTSERRAT_10":1,
"LV_FONT_MONTSERRAT_12":1,
"LV_FONT_MONTSERRAT_14":1,
"LV_FONT_MONTSERRAT_16":1,
"LV_FONT_MONTSERRAT_18":1,
"LV_FONT_MONTSERRAT_20":1,
"LV_FONT_MONTSERRAT_22":1,
"LV_FONT_MONTSERRAT_24":1,
"LV_FONT_MONTSERRAT_26":1,
"LV_FONT_MONTSERRAT_28":1,
"LV_FONT_MONTSERRAT_30":1,
"LV_FONT_MONTSERRAT_32":1,
"LV_FONT_MONTSERRAT_34":1,
"LV_FONT_MONTSERRAT_36":1,
"LV_FONT_MONTSERRAT_38":1,
"LV_FONT_MONTSERRAT_40":1,
"LV_FONT_MONTSERRAT_42":1,
"LV_FONT_MONTSERRAT_44":1,
"LV_FONT_MONTSERRAT_46":1,
"LV_FONT_MONTSERRAT_48":1,
"LV_FONT_MONTSERRAT_12_SUBPX":1,
"LV_FONT_MONTSERRAT_28_COMPRESSED":1,
"LV_FONT_DEJAVU_16_PERSIAN_HEBREW":1,
"LV_FONT_SIMSUN_16_CJK":1,
"LV_FONT_UNSCII_8":1,
"LV_FONT_UNSCII_16":1,
"LV_FONT_FMT_TXT_LARGE":1,
"LV_USE_FONT_COMPRESSED":1,
"LV_USE_BIDI": 1,
"LV_USE_ARABIC_PERSIAN_CHARS":1,
"LV_USE_PERF_MONITOR":1,
"LV_USE_MEM_MONITOR":1,
"LV_LABEL_TEXT_SELECTION":1,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_32\\\"",
}
build("Minimal config monochrome", minimal_monochrome)
build("Minimal config, 16 bit color depth", minimal_16bit)
build("Minimal config, 16 bit color depth swapped", minimal_16bit_swap)
build("Full config, 32 bit color depth", full_32bit)
+5
View File
@@ -0,0 +1,5 @@
:unity:
:includes:
- lv_test_init.h
:suite_setup: "lv_test_init();"
:suite_teardown: "lv_test_deinit();return num_failures;"
+155
View File
@@ -0,0 +1,155 @@
minimal_monochrome = {
"LV_COLOR_DEPTH":1,
"LV_MEM_SIZE":64 * 1024,
"LV_DPI_DEF":40,
"LV_DRAW_COMPLEX":0,
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
minimal_16bit = {
"LV_COLOR_DEPTH":16,
"LV_MEM_CUSTOM":1,
"LV_DPI_DEF":40,
"LV_DRAW_COMPLEX":0,
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
minimal_16bit_swap = {
"LV_COLOR_DEPTH":16,
"LV_COLOR_16_SWAP":1,
"LV_MEM_SIZE":64 * 1024,
"LV_DPI_DEF":40,
"LV_DRAW_COMPLEX":0,
"LV_USE_LOG":1,
"LV_USE_ASSERT_NULL":0,
"LV_USE_ASSERT_MALLOC":0,
"LV_USE_ASSERT_MEM_INTEGRITY":0,
"LV_USE_ASSERT_OBJ":0,
"LV_USE_ASSERT_STYLE":0,
"LV_USE_USER_DATA": 0,
"LV_FONT_UNSCII_8":1,
"LV_USE_FONT_SUBPX": 1,
"LV_USE_BIDI": 0,
"LV_USE_ARABIC_PERSIAN_CHARS":0,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
}
full_32bit = {
"LV_COLOR_DEPTH":32,
"LV_MEM_SIZE":8 * 1024 * 1024,
"LV_DPI_DEF":160,
"LV_DRAW_COMPLEX":1,
"LV_SHADOW_CACHE_SIZE":1,
"LV_IMG_CACHE_DEF_SIZE":32,
"LV_USE_LOG":1,
"LV_LOG_PRINTF":1,
"LV_USE_FONT_SUBPX": 1,
"LV_FONT_SUBPX_BGR":1,
"LV_USE_PERF_MONITOR":1,
"LV_USE_ASSERT_NULL":1,
"LV_USE_ASSERT_MALLOC":1,
"LV_USE_ASSERT_MEM_INTEGRITY":1,
"LV_USE_ASSERT_OBJ":1,
"LV_USE_ASSERT_STYLE":1,
"LV_USE_USER_DATA": 1,
"LV_USE_LARGE_COORD": 1,
"LV_FONT_MONTSERRAT_8":1,
"LV_FONT_MONTSERRAT_10":1,
"LV_FONT_MONTSERRAT_12":1,
"LV_FONT_MONTSERRAT_14":1,
"LV_FONT_MONTSERRAT_16":1,
"LV_FONT_MONTSERRAT_18":1,
"LV_FONT_MONTSERRAT_20":1,
"LV_FONT_MONTSERRAT_22":1,
"LV_FONT_MONTSERRAT_24":1,
"LV_FONT_MONTSERRAT_26":1,
"LV_FONT_MONTSERRAT_28":1,
"LV_FONT_MONTSERRAT_30":1,
"LV_FONT_MONTSERRAT_32":1,
"LV_FONT_MONTSERRAT_34":1,
"LV_FONT_MONTSERRAT_36":1,
"LV_FONT_MONTSERRAT_38":1,
"LV_FONT_MONTSERRAT_40":1,
"LV_FONT_MONTSERRAT_42":1,
"LV_FONT_MONTSERRAT_44":1,
"LV_FONT_MONTSERRAT_46":1,
"LV_FONT_MONTSERRAT_48":1,
"LV_FONT_MONTSERRAT_12_SUBPX":1,
"LV_FONT_MONTSERRAT_28_COMPRESSED":1,
"LV_FONT_DEJAVU_16_PERSIAN_HEBREW":1,
"LV_FONT_SIMSUN_16_CJK":1,
"LV_FONT_UNSCII_8":1,
"LV_FONT_UNSCII_16":1,
"LV_FONT_FMT_TXT_LARGE":1,
"LV_USE_FONT_COMPRESSED":1,
"LV_USE_BIDI": 1,
"LV_USE_ARABIC_PERSIAN_CHARS":1,
"LV_USE_PERF_MONITOR":1,
"LV_USE_MEM_MONITOR":1,
"LV_LABEL_TEXT_SELECTION":1,
"LV_BUILD_EXAMPLES":1,
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_32\\\"",
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

-383
View File
@@ -1,383 +0,0 @@
/**
* @file lv_test_assert.c
*
* Copyright 2002-2010 Guillaume Cottenceau.
*
* This software may be freely redistributed under the terms
* of the X11 license.
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_test_assert.h"
#include "../lvgl.h"
#if LV_BUILD_TEST
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#define PNG_DEBUG 3
#include <png.h>
/*********************
* DEFINES
*********************/
//#define REF_IMGS_PATH "lvgl/tests/lv_test_ref_imgs/"
#define REF_IMGS_PATH "lv_test_ref_imgs/"
/**********************
* TYPEDEFS
**********************/
typedef struct {
int width, height;
png_byte color_type;
png_byte bit_depth;
png_structp png_ptr;
png_infop info_ptr;
int number_of_passes;
png_bytep * row_pointers;
}png_img_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void read_png_file(png_img_t * p, const char* file_name);
//static void write_png_file(png_img_t * p, const char* file_name);
static void png_release(png_img_t * p);
//static void process_file(png_img_t * p);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_test_print(const char * s, ...)
{
va_list args;
va_start(args, s);
vfprintf(stdout, s, args);
fprintf(stdout, "\n");
va_end(args);
}
void lv_test_exit(const char * s, ...)
{
va_list args;
va_start(args, s);
vfprintf(stderr, s, args);
fprintf(stderr, "\n");
va_end(args);
exit(1);
}
void lv_test_error(const char * s, ...)
{
va_list args;
va_start(args, s);
vfprintf(stderr, s, args);
fprintf(stderr, "\n");
va_end(args);
exit(1);
}
void lv_test_assert_true(int32_t expression, const char * s)
{
if(!expression) {
lv_test_error(" FAIL: %s. (Expected: not zero)", s, expression);
} else {
lv_test_print(" PASS: %s. (Expected: not zero)", s, expression);
}
}
void lv_test_assert_int_eq(int32_t n_ref, int32_t n_act, const char * s)
{
if(n_ref != n_act) {
lv_test_error(" FAIL: %s. (Expected: %d, Actual: %d)", s, n_ref, n_act);
} else {
lv_test_print(" PASS: %s. (Expected: %d)", s, n_ref);
}
}
void lv_test_assert_int_gt(int32_t n_ref, int32_t n_act, const char * s)
{
if(n_act <= n_ref) {
lv_test_error(" FAIL: %s. (Expected: > %d, Actual: %d)", s, n_ref, n_act);
} else {
lv_test_print(" PASS: %s. (Expected: > %d, , Actual: %d)", s, n_ref, n_act);
}
}
void lv_test_assert_int_lt(int32_t n_ref, int32_t n_act, const char * s)
{
if(n_act >= n_ref) {
lv_test_error(" FAIL: %s. (Expected: < %d, Actual: %d)", s, n_ref, n_act);
} else {
lv_test_print(" PASS: %s. (Expected: < %d, , Actual: %d)", s, n_ref, n_act);
}
}
void lv_test_assert_str_eq(const char * s_ref, const char * s_act, const char * s)
{
if(strcmp(s_ref, s_act) != 0) {
lv_test_error(" FAIL: %s. (Expected: %s, Actual: %s)", s, s_ref, s_act);
} else {
lv_test_print(" PASS: %s. (Expected: %s)", s, s_ref);
}
}
void lv_test_assert_array_eq(const uint8_t *p_ref, const uint8_t *p_act, int32_t size, const char * s)
{
if(memcmp(p_ref, p_act, size) != 0) {
lv_test_error(" FAIL: %s. (Expected: all %d bytes should be equal)", s, size);
} else {
lv_test_print(" PASS: %s. (Expected: all %d bytes should be equal)", s, size);
}
}
void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * s)
{
if(p_ref != p_act) {
lv_test_error(" FAIL: %s. (Expected: 0x%lx, Actual: 0x%lx)", s, p_ref, p_act);
} else {
lv_test_print(" PASS: %s. (Expected: 0x%lx)", s, p_ref);
}
}
void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s)
{
#if LV_COLOR_16_SWAP == 0
if(c_ref.full != c_act.full) {
lv_test_error(" FAIL: %s. (Expected: R:%02x, G:%02x, B:%02x, Actual: R:%02x, G:%02x, B:%02x)", s,
c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue,
c_act.ch.red, c_act.ch.green, c_act.ch.blue);
} else {
lv_test_print(" PASS: %s. (Expected: R:%02x, G:%02x, B:%02x)", s,
c_ref.ch.red, c_ref.ch.green, c_ref.ch.blue);
}
#else
LV_UNUSED(c_ref);
LV_UNUSED(c_act);
LV_UNUSED(s);
lv_test_print(" SKIP");
#endif
}
void lv_test_assert_img_eq(const char * fn_ref, const char * s)
{
#if LV_COLOR_DEPTH != 32
lv_test_print(" SKIP: Can't compare '%s' because LV_COLOR_DEPTH != 32", fn_ref);
return;
#endif
if (LV_HOR_RES != 800 || LV_VER_RES != 480) {
lv_test_print(" SKIP: Can't compare '%s' because the resolution needs to be 800x480", fn_ref);
return;
}
char fn_ref_full[512];
sprintf(fn_ref_full, "%s%s", REF_IMGS_PATH, fn_ref);
png_img_t p;
read_png_file(&p, fn_ref_full);
uint8_t * screen_buf;
lv_disp_t * disp = lv_disp_get_default();
lv_obj_invalidate(lv_disp_get_scr_act(disp));
lv_refr_now(disp);
extern lv_color_t test_fb[];
screen_buf = (uint8_t *)test_fb;
uint8_t * ptr_act = NULL;
const png_byte* ptr_ref = NULL;
bool err = false;
int x, y, i_buf = 0;
for (y=0; y<p.height; y++) {
png_byte* row = p.row_pointers[y];
for (x=0; x<p.width; x++) {
ptr_ref = &(row[x*3]);
ptr_act = &(screen_buf[i_buf*4]);
uint8_t tmp = ptr_act[0];
ptr_act[0] = ptr_act[2];
ptr_act[2] = tmp;
if(memcmp(ptr_act, ptr_ref, 3) != 0) {
err = true;
break;
}
i_buf++;
}
if(err) break;
}
png_release(&p);
if(err) {
uint32_t ref_px = 0;
uint32_t act_px = 0;
memcpy(&ref_px, ptr_ref, 3);
memcpy(&act_px, ptr_act, 3);
lv_test_error(" FAIL: %s. (Expected: %s, diff. at (%d;%d), %08x instead of %08x)", s, fn_ref, x, y, act_px, ref_px);
} else {
lv_test_print(" PASS: %s. (Expected: %s)", s, fn_ref);
}
}
/**********************
* STATIC FUNCTIONS
**********************/
static void read_png_file(png_img_t * p, const char* file_name)
{
char header[8]; // 8 is the maximum size that can be checked
/*open file and test for it being a png*/
FILE *fp = fopen(file_name, "rb");
if (!fp)
lv_test_exit("[read_png_file] File %s could not be opened for reading", file_name);
size_t rcnt = fread(header, 1, 8, fp);
if (rcnt != 8 || png_sig_cmp((png_const_bytep)header, 0, 8))
lv_test_exit("[read_png_file] File %s is not recognized as a PNG file", file_name);
/*initialize stuff*/
p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!p->png_ptr)
lv_test_exit("[read_png_file] png_create_read_struct failed");
p->info_ptr = png_create_info_struct(p->png_ptr);
if (!p->info_ptr)
lv_test_exit("[read_png_file] png_create_info_struct failed");
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[read_png_file] Error during init_io");
png_init_io(p->png_ptr, fp);
png_set_sig_bytes(p->png_ptr, 8);
png_read_info(p->png_ptr, p->info_ptr);
p->width = png_get_image_width(p->png_ptr, p->info_ptr);
p->height = png_get_image_height(p->png_ptr, p->info_ptr);
p->color_type = png_get_color_type(p->png_ptr, p->info_ptr);
p->bit_depth = png_get_bit_depth(p->png_ptr, p->info_ptr);
p->number_of_passes = png_set_interlace_handling(p->png_ptr);
png_read_update_info(p->png_ptr, p->info_ptr);
/*read file*/
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[read_png_file] Error during read_image");
p->row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * p->height);
int y;
for (y=0; y<p->height; y++)
p->row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(p->png_ptr,p->info_ptr));
png_read_image(p->png_ptr, p->row_pointers);
fclose(fp);
}
//
//
//static void write_png_file(png_img_t * p, const char* file_name)
//{
// /*create file*/
// FILE *fp = fopen(file_name, "wb");
// if (!fp)
// lv_test_exit("[write_png_file] File %s could not be opened for writing", file_name);
//
//
// /*initialize stuff*/
// p->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
//
// if (!p->png_ptr)
// lv_test_exit("[write_png_file] png_create_write_struct failed");
//
// p->info_ptr = png_create_info_struct(p->png_ptr);
// if (!p->info_ptr)
// lv_test_exit("[write_png_file] png_create_info_struct failed");
//
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during init_io");
//
// png_init_io(p->png_ptr, fp);
//
//
// /*write header*/
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during writing header");
//
// png_set_IHDR(p->png_ptr, p->info_ptr, p->width, p->height,
// p->bit_depth, p->color_type, PNG_INTERLACE_NONE,
// PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
//
// png_write_info(p->png_ptr, p->info_ptr);
//
//
// /*write bytes*/
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during writing bytes");
//
// png_write_image(p->png_ptr, p->row_pointers);
//
//
// /*end write*/
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during end of write");
//
// png_write_end(p->png_ptr, NULL);
//
// fclose(fp);
//}
//
static void png_release(png_img_t * p)
{
int y;
for (y=0; y<p->height; y++)
free(p->row_pointers[y]);
free(p->row_pointers);
}
//static void process_file(png_img_t * p)
//{
// if (png_get_color_type(p->png_ptr, p->info_ptr) == PNG_COLOR_TYPE_RGB)
// lv_test_exit("[process_file] input file is PNG_COLOR_TYPE_RGB but must be PNG_COLOR_TYPE_RGBA "
// "(lacks the alpha channel)");
//
// if (png_get_color_type(p->png_ptr, p->info_ptr) != PNG_COLOR_TYPE_RGBA)
// lv_test_exit("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (%d) (is %d)",
// PNG_COLOR_TYPE_RGBA, png_get_color_type(p->png_ptr, p->info_ptr));
//
// int x, y;
// for (y=0; y<p->height; y++) {
// png_byte* row = p->row_pointers[y];
// for (x=0; x<p->width; x++) {
// png_byte* ptr = &(row[x*4]);
// printf("Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n",
// x, y, ptr[0], ptr[1], ptr[2], ptr[3]);
//
// /*set red value to 0 and green value to the blue one*/
// ptr[0] = 0;
// ptr[1] = ptr[2];
// }
// }
//}
#endif
-53
View File
@@ -1,53 +0,0 @@
/**
* @file lv_test_assert.h
*
*/
#ifndef LV_TEST_ASSERT_H
#define LV_TEST_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include <stdbool.h>
#include <stdint.h>
#include "../lvgl.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_print(const char * s, ...);
void lv_test_exit(const char * s, ...);
void lv_test_error(const char * s, ...);
void lv_test_assert_true(int32_t expression, const char * s);
void lv_test_assert_int_eq(int32_t n1, int32_t n2, const char * s);
void lv_test_assert_int_gt(int32_t n_ref, int32_t n_act, const char * s);
void lv_test_assert_int_lt(int32_t n_ref, int32_t n_act, const char * s);
void lv_test_assert_str_eq(const char * str1, const char * str2, const char * s);
void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * s);
void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s);
void lv_test_assert_img_eq(const char * ref_img_fn, const char * s);
void lv_test_assert_array_eq(const uint8_t *p_ref, const uint8_t *p_act, int32_t size, const char * s);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_ASSERT_H*/
-56
View File
@@ -1,56 +0,0 @@
/**
* @file lv_test_core.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../lv_test_assert.h"
#if LV_BUILD_TEST
#include "lv_test_core.h"
#include "lv_test_obj.h"
#include "lv_test_style.h"
#include "lv_test_font_loader.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_test_core(void)
{
lv_test_print("");
lv_test_print("*******************");
lv_test_print("Start lv_core tests");
lv_test_print("*******************");
lv_test_obj();
// lv_test_style();
lv_test_font_loader();
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif
-38
View File
@@ -1,38 +0,0 @@
/**
* @file lv_test_core.h
*
*/
#ifndef LV_TEST_CORE_H
#define LV_TEST_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_core(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_CORE_H*/
-210
View File
@@ -1,210 +0,0 @@
/**
* @file lv_test_font_loader.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../../lvgl.h"
#if LV_BUILD_TEST
#include "../lv_test_assert.h"
#include "../../src/font/lv_font_fmt_txt.h"
#include "../../src/font/lv_font.h"
#include "../../src/font/lv_font_loader.h"
#include "lv_test_font_loader.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static int compare_fonts(lv_font_t * f1, lv_font_t * f2);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
extern lv_font_t font_1;
extern lv_font_t font_2;
extern lv_font_t font_3;
void lv_test_font_loader(void)
{
lv_font_t * font_1_bin = lv_font_load("F:font_1.fnt");
lv_font_t * font_2_bin = lv_font_load("F:font_2.fnt");
lv_font_t * font_3_bin = lv_font_load("F:font_3.fnt");
compare_fonts(&font_1, font_1_bin);
compare_fonts(&font_2, font_2_bin);
compare_fonts(&font_3, font_3_bin);
lv_font_free(font_1_bin);
lv_font_free(font_2_bin);
lv_font_free(font_3_bin);
}
static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
{
lv_test_assert_true(f1 != NULL && f2 != NULL, "font not null");
// Skip these test because -Wpedantic tells
// ISO C forbids passing argument 1 of lv_test_assert_ptr_eq between function pointer and void *
// lv_test_assert_ptr_eq(f1->get_glyph_dsc, f2->get_glyph_dsc, "glyph_dsc");
// lv_test_assert_ptr_eq(f1->get_glyph_bitmap, f2->get_glyph_bitmap, "glyph_bitmap");
lv_test_assert_int_eq(f1->line_height, f2->line_height, "line_height");
lv_test_assert_int_eq(f1->base_line, f2->base_line, "base_line");
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
lv_test_assert_int_eq(f1->subpx, f2->subpx, "subpx");
#endif
lv_font_fmt_txt_dsc_t * dsc1 = (lv_font_fmt_txt_dsc_t *)f1->dsc;
lv_font_fmt_txt_dsc_t * dsc2 = (lv_font_fmt_txt_dsc_t *)f2->dsc;
lv_test_assert_int_eq(dsc1->kern_scale, dsc2->kern_scale, "kern_scale");
lv_test_assert_int_eq(dsc1->cmap_num, dsc2->cmap_num, "cmap_num");
lv_test_assert_int_eq(dsc1->bpp, dsc2->bpp, "bpp");
lv_test_assert_int_eq(dsc1->kern_classes, dsc2->kern_classes, "kern_classes");
lv_test_assert_int_eq(dsc1->bitmap_format, dsc2->bitmap_format, "bitmap_format");
// cmaps
int total_glyphs = 0;
for(int i = 0; i < dsc1->cmap_num; ++i) {
lv_font_fmt_txt_cmap_t * cmaps1 = (lv_font_fmt_txt_cmap_t *)&dsc1->cmaps[i];
lv_font_fmt_txt_cmap_t * cmaps2 = (lv_font_fmt_txt_cmap_t *)&dsc2->cmaps[i];
lv_test_assert_int_eq(cmaps1->range_start, cmaps2->range_start, "range_start");
lv_test_assert_int_eq(cmaps1->range_length, cmaps2->range_length, "range_length");
lv_test_assert_int_eq(cmaps1->glyph_id_start, cmaps2->glyph_id_start, "glyph_id_start");
lv_test_assert_int_eq(cmaps1->type, cmaps2->type, "type");
lv_test_assert_int_eq(cmaps1->list_length, cmaps2->list_length, "list_length");
if(cmaps1->unicode_list != NULL && cmaps2->unicode_list != NULL) {
lv_test_assert_true(cmaps1->unicode_list && cmaps2->unicode_list, "unicode_list");
lv_test_assert_array_eq(
(uint8_t *)cmaps1->unicode_list,
(uint8_t *)cmaps2->unicode_list,
sizeof(uint16_t) * cmaps1->list_length,
"unicode_list");
total_glyphs += cmaps1->list_length;
}
else {
total_glyphs += cmaps1->range_length;
lv_test_assert_ptr_eq(cmaps1->unicode_list, cmaps2->unicode_list, "unicode_list");
}
if(cmaps1->glyph_id_ofs_list != NULL && cmaps2->glyph_id_ofs_list != NULL) {
uint8_t * ids1 = (uint8_t *)cmaps1->glyph_id_ofs_list;
uint8_t * ids2 = (uint8_t *)cmaps2->glyph_id_ofs_list;
lv_test_assert_array_eq(ids1, ids2, cmaps1->list_length, "glyph_id_ofs_list");
}
else {
lv_test_assert_ptr_eq(cmaps1->glyph_id_ofs_list, cmaps2->glyph_id_ofs_list, "glyph_id_ofs_list");
}
}
// kern_dsc
if (dsc1->kern_classes == 1 && dsc2->kern_classes == 1) {
lv_font_fmt_txt_kern_classes_t * kern1 = (lv_font_fmt_txt_kern_classes_t *)dsc1->kern_dsc;
lv_font_fmt_txt_kern_classes_t * kern2 = (lv_font_fmt_txt_kern_classes_t *)dsc2->kern_dsc;
if (kern1 != NULL && kern2 != NULL) {
lv_test_assert_int_eq(kern1->right_class_cnt, kern2->right_class_cnt, "right_class_cnt");
lv_test_assert_int_eq(kern1->left_class_cnt, kern2->left_class_cnt, "left_class_cnt");
lv_test_assert_array_eq(
(uint8_t *)kern1->left_class_mapping,
(uint8_t *)kern2->left_class_mapping,
kern1->left_class_cnt,
"left_class_mapping");
lv_test_assert_array_eq(
(uint8_t *)kern1->right_class_mapping,
(uint8_t *)kern2->right_class_mapping,
kern1->right_class_cnt,
"right_class_mapping");
lv_test_assert_array_eq(
(uint8_t *)kern1->class_pair_values,
(uint8_t *)kern2->class_pair_values,
kern1->right_class_cnt * kern1->left_class_cnt,
"class_pair_values");
}
else {
lv_test_assert_ptr_eq(kern1, kern2, "kern");
}
}
else if (dsc1->kern_classes == 0 && dsc2->kern_classes == 0) {
lv_font_fmt_txt_kern_pair_t * kern1 = (lv_font_fmt_txt_kern_pair_t *)dsc1->kern_dsc;
lv_font_fmt_txt_kern_pair_t * kern2 = (lv_font_fmt_txt_kern_pair_t *)dsc2->kern_dsc;
if (kern1 != NULL && kern2 != NULL) {
lv_test_assert_int_eq(kern1->glyph_ids_size, kern2->glyph_ids_size, "glyph_ids_size");
lv_test_assert_int_eq(kern1->pair_cnt, kern2->pair_cnt, "pair_cnt");
int ids_size;
if (kern1->glyph_ids_size == 0) {
ids_size = sizeof(int8_t) * 2 * kern1->pair_cnt;
}
else {
ids_size = sizeof(int16_t) * 2 * kern1->pair_cnt;
}
lv_test_assert_array_eq(kern1->glyph_ids, kern2->glyph_ids, ids_size, "glyph_ids");
lv_test_assert_array_eq(
(uint8_t * ) kern1->values,
(uint8_t * ) kern2->values,
kern1->pair_cnt,
"glyph_values");
}
}
lv_font_fmt_txt_glyph_dsc_t * glyph_dsc1 = (lv_font_fmt_txt_glyph_dsc_t *)dsc1->glyph_dsc;
lv_font_fmt_txt_glyph_dsc_t * glyph_dsc2 = (lv_font_fmt_txt_glyph_dsc_t *)dsc2->glyph_dsc;
for(int i = 0; i < total_glyphs; ++i) {
if (i < total_glyphs - 1) {
int size1 = glyph_dsc1[i+1].bitmap_index - glyph_dsc1[i].bitmap_index;
if (size1 > 0) {
lv_test_assert_array_eq(
dsc1->glyph_bitmap + glyph_dsc1[i].bitmap_index,
dsc2->glyph_bitmap + glyph_dsc2[i].bitmap_index,
size1 - 1, "glyph_bitmap");
}
}
lv_test_assert_int_eq(glyph_dsc1[i].adv_w, glyph_dsc2[i].adv_w, "adv_w");
lv_test_assert_int_eq(glyph_dsc1[i].box_w, glyph_dsc2[i].box_w, "box_w");
lv_test_assert_int_eq(glyph_dsc1[i].box_h, glyph_dsc2[i].box_h, "box_h");
lv_test_assert_int_eq(glyph_dsc1[i].ofs_x, glyph_dsc2[i].ofs_x, "ofs_x");
lv_test_assert_int_eq(glyph_dsc1[i].ofs_y, glyph_dsc2[i].ofs_y, "ofs_y");
}
LV_LOG_INFO("No differences found!");
return 0;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif // LV_BUILD_TEST
-38
View File
@@ -1,38 +0,0 @@
/**
* @file lv_test_font_loader.h
*
*/
#ifndef LV_TEST_FONT_LOADER_H
#define LV_TEST_FONT_LOADER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_font_loader(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_FONT_LOADER_H*/
-88
View File
@@ -1,88 +0,0 @@
/**
* @file lv_test_obj.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../../lvgl.h"
#include "../lv_test_assert.h"
#include "lv_test_obj.h"
#if LV_BUILD_TEST
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void create_delete_change_parent(void);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_test_obj(void)
{
lv_test_print("");
lv_test_print("==================");
lv_test_print("Start lv_obj tests");
lv_test_print("==================");
create_delete_change_parent();
}
/**********************
* STATIC FUNCTIONS
**********************/
static void create_delete_change_parent(void)
{
lv_test_print("");
lv_test_print("Create, delete, change parent of a simple object:");
lv_test_print("-------------------------------------------------");
lv_test_print("Create an object on the default screen");
lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count before creation");
lv_obj_t * obj = lv_obj_create(lv_scr_act());
lv_test_assert_int_eq(1, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation");
lv_test_assert_int_eq(0, lv_obj_get_child_cnt(obj), "New object's children count after creation");
lv_test_print("Delete the created object");
lv_obj_del(obj);
obj = NULL;
lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after delete");
lv_test_print("Create two objects");
lv_obj_t * obj_parent = lv_obj_create(lv_scr_act());
lv_obj_t * obj_child = lv_obj_create(lv_scr_act());
lv_test_assert_int_eq(2, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after creation");
lv_test_print("Change the parent of the second object to the first");
lv_obj_set_parent(obj_child, obj_parent);
lv_test_assert_int_eq(1, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after parent change");
lv_test_assert_int_eq(1, lv_obj_get_child_cnt(obj_parent), "Parent object's children count after parent change");
lv_test_assert_int_eq(0, lv_obj_get_child_cnt(obj_child), "Child object's children count after parent change");
lv_test_print("Remove the parent object");
lv_obj_del(obj_parent);
lv_test_assert_int_eq(0, lv_obj_get_child_cnt(lv_scr_act()), "Screen's children count after delete");
}
#endif
-38
View File
@@ -1,38 +0,0 @@
/**
* @file lv_test_obj.h
*
*/
#ifndef LV_TEST_OBJ_H
#define LV_TEST_OBJ_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_obj(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_OBJ_H*/
File diff suppressed because it is too large Load Diff
-38
View File
@@ -1,38 +0,0 @@
/**
* @file lv_test_style.h
*
*/
#ifndef LV_TEST_STYLE_H
#define LV_TEST_STYLE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_style(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_STYLE_H*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+146
View File
@@ -0,0 +1,146 @@
#include "../lvgl.h"
#if LV_BUILD_TEST
#include "lv_test_init.h"
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#define HOR_RES 800
#define VER_RES 480
static void hal_init(void);
static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
lv_color_t test_fb[HOR_RES * VER_RES];
static lv_color_t disp_buf1[HOR_RES * VER_RES];
void lv_test_init(void)
{
printf("Call lv_init...\n");
lv_init();
hal_init();
}
void lv_test_deinit(void)
{
printf("Call lv_deinit...\n");
lv_mem_deinit();
}
static void * open_cb(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
{
(void) drv;
(void) mode;
FILE * fp = fopen(path, "rb"); // only reading is supported
return fp;
}
static lv_fs_res_t close_cb(lv_fs_drv_t * drv, void * file_p)
{
(void) drv;
fclose(file_p);
return LV_FS_RES_OK;
}
static lv_fs_res_t read_cb(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
{
(void) drv;
*br = fread(buf, 1, btr, file_p);
return (*br <= 0) ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
}
static lv_fs_res_t seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t w)
{
(void) drv;
uint32_t w2;
switch(w) {
case LV_FS_SEEK_SET:
w2 = SEEK_SET;
break;
case LV_FS_SEEK_CUR:
w2 = SEEK_CUR;
break;
case LV_FS_SEEK_END:
w2 = SEEK_END;
break;
default:
w2 = SEEK_SET;
}
fseek (file_p, pos, w2);
return LV_FS_RES_OK;
}
static lv_fs_res_t tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
{
(void) drv;
*pos_p = ftell(file_p);
return LV_FS_RES_OK;
}
static void hal_init(void)
{
static lv_disp_draw_buf_t draw_buf;
lv_disp_draw_buf_init(&draw_buf, disp_buf1, NULL, LV_HOR_RES * LV_VER_RES);
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.draw_buf = &draw_buf;
disp_drv.flush_cb = dummy_flush_cb;
disp_drv.hor_res = HOR_RES;
disp_drv.ver_res = VER_RES;
lv_disp_drv_register(&disp_drv);
static lv_fs_drv_t drv;
lv_fs_drv_init(&drv); /*Basic initialization*/
drv.letter = 'F'; /*An uppercase letter to identify the drive*/
drv.open_cb = open_cb; /*Callback to open a file*/
drv.close_cb = close_cb; /*Callback to close a file*/
drv.read_cb = read_cb; /*Callback to read a file*/
drv.seek_cb = seek_cb; /*Callback to seek in a file (Move cursor)*/
drv.tell_cb = tell_cb; /*Callback to tell the cursor position*/
lv_fs_drv_register(&drv); /*Finally register the drive*/
}
#include <stdio.h>
static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
LV_UNUSED(area);
LV_UNUSED(color_p);
memcpy(test_fb, color_p, lv_area_get_size(area) * sizeof(lv_color_t));
lv_disp_flush_ready(disp_drv);
}
uint32_t custom_tick_get(void)
{
static uint64_t start_ms = 0;
if(start_ms == 0) {
struct timeval tv_start;
gettimeofday(&tv_start, NULL);
start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
}
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
uint64_t now_ms;
now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
uint32_t time_ms = now_ms - start_ms;
return time_ms;
}
#endif
+19
View File
@@ -0,0 +1,19 @@
#ifndef LV_TEST_INIT_H
#define LV_TEST_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
void lv_test_init(void);
void lv_test_deinit(void);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_INIT_H*/
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

-71
View File
@@ -1,71 +0,0 @@
typedef int _keep_pedantic_happy;
///**
// * @file lv_test_label.c
// *
// */
//
///*********************
// * INCLUDES
// *********************/
//#include "../../lvgl.h"
//#include "../lv_test_assert.h"
//#include "lv_test_label.h"
//
//#if LV_BUILD_TEST
//
///*********************
// * DEFINES
// *********************/
//
///**********************
// * TYPEDEFS
// **********************/
//
///**********************
// * STATIC PROTOTYPES
// **********************/
//static void create_copy(void);
//
///**********************
// * STATIC VARIABLES
// **********************/
//
///**********************
// * MACROS
// **********************/
//
///**********************
// * GLOBAL FUNCTIONS
// **********************/
//
//void lv_test_label(void)
//{
// lv_test_print("");
// lv_test_print("===================");
// lv_test_print("Start lv_label tests");
// lv_test_print("===================");
//
//#if LV_USE_LABEL
// create_copy();
//#else
// lv_test_print("Skip label test: LV_USE_LABEL == 0");
//#endif
//}
//
///**********************
// * STATIC FUNCTIONS
// **********************/
//
//static void create_copy(void)
//{
// lv_test_print("");
// lv_test_print("Create a label");
// lv_test_print("---------------------------");
//
// lv_label_create(lv_scr_act());
//#if LV_COLOR_DEPTH == 32
// lv_test_assert_img_eq("lv_test_img32_label_1.png", "Create a label and leave the default settings");
//#endif
//}
//#endif
-38
View File
@@ -1,38 +0,0 @@
/**
* @file lv_test_label.h
*
*/
#ifndef LV_TEST_LABEL_H
#define LV_TEST_LABEL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_test_label(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEST_CONT_H*/
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import defines
import build
import test
files = test.prepare()
for f in files:
name = f[:-2] #test_foo.c -> test_foo
build.build("Minimal config, 16 bit color depth", defines.minimal_16bit, name)
#build("Minimal config monochrome", minimal_monochrome)
#build.build("Minimal config, 16 bit color depth", defines.minimal_16bit, "test_obj_tree")
#build("Minimal config, 16 bit color depth swapped", minimal_16bit_swap)
#build("Full config, 32 bit color depth", full_32bit)
+9
View File
@@ -0,0 +1,9 @@
import os
import glob
def prepare():
os.system("rm test_*_Runner.c")
files = glob.glob("./test_*.c")
for f in files:
os.system("ruby unity/generate_test_runner.rb " + f + " config.yml")
return files
+25
View File
@@ -0,0 +1,25 @@
#include "../lvgl.h"
#include "unity/unity.h"
void test_obj_tree_1(void);
void test_obj_tree_2(void);
void test_obj_tree_1(void)
{
TEST_ASSERT_EQUAL(lv_obj_get_child_cnt(lv_scr_act()), 0);
}
void test_obj_tree_2(void)
{
return;
lv_obj_create(lv_scr_act());
lv_obj_t * o2 = lv_obj_create(lv_scr_act());
lv_obj_create(lv_scr_act());
TEST_ASSERT_EQUAL(lv_obj_get_child_cnt(lv_scr_act()), 3);
lv_obj_del(o2);
TEST_ASSERT_EQUAL(lv_obj_get_child_cnt(lv_scr_act()), 2);
lv_obj_clean(lv_scr_act());
TEST_ASSERT_EQUAL(lv_obj_get_child_cnt(lv_scr_act()), 0);
}
File diff suppressed because it is too large Load Diff
+37
View File
@@ -0,0 +1,37 @@
/*=======Test Runner Used To Run Each Test=====*/
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)
{
Unity.CurrentTestName = name;
Unity.CurrentTestLineNumber = line_num;
#ifdef UNITY_USE_COMMAND_LINE_ARGS
if (!UnityTestMatches())
return;
#endif
Unity.NumberOfTests++;
UNITY_CLR_DETAILS();
UNITY_EXEC_TIME_START();
CMock_Init();
if (TEST_PROTECT())
{
<% if @options[:plugins].include?(:cexception) %>
CEXCEPTION_T e;
Try {
<%= @options[:setup_name] %>();
func();
} Catch(e) {
TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!");
}
<% else %>
<%= @options[:setup_name] %>();
func();
<% end %>
}
if (TEST_PROTECT())
{
<%= @options[:teardown_name] %>();
CMock_Verify();
}
CMock_Destroy();
UNITY_EXEC_TIME_STOP();
UnityConcludeTest();
}
+6
View File
@@ -0,0 +1,6 @@
module TypeSanitizer
def self.sanitize_c_identifier(unsanitized)
# convert filename to valid C identifier by replacing invalid chars with '_'
unsanitized.gsub(/[-\/\\\.\,\s]/, '_')
end
end
+2110
View File
File diff suppressed because it is too large Load Diff
+661
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff