mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 00:51:49 +08:00
Merge branch 'feat/test-unity'
This commit is contained in:
@@ -2,9 +2,9 @@ name: C/C++ CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, dev ]
|
||||
branches: [ feat/test-unity ]
|
||||
pull_request:
|
||||
branches: [master, dev ]
|
||||
branches: [ feat/test-unity ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -15,4 +15,4 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ammaraskar/gcc-problem-matcher@master
|
||||
- name: Run tests
|
||||
run: sudo apt-get install libpng-dev; cd tests; python ./build.py
|
||||
run: sudo apt-get install libpng-dev ruby-full; cd tests; python ./main.py
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
**/*bin
|
||||
**/*.swp
|
||||
**/*.swo
|
||||
**/*.gcda
|
||||
**/*.gcno
|
||||
tags
|
||||
docs/api_doc
|
||||
scripts/cppcheck_res.txt
|
||||
@@ -16,3 +18,4 @@ docs/env
|
||||
out_html
|
||||
__pycache__
|
||||
/emscripten_builder
|
||||
image_err.h
|
||||
|
||||
@@ -335,7 +335,7 @@ const char * lv_dropdown_get_options(const lv_obj_t * obj)
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_dropdown_t * dropdown = (lv_dropdown_t *)obj;
|
||||
return dropdown->options;
|
||||
return dropdown->options == NULL ? "" : dropdown->options;
|
||||
}
|
||||
|
||||
uint16_t lv_dropdown_get_selected(const lv_obj_t * obj)
|
||||
|
||||
@@ -656,8 +656,8 @@ bool lv_textarea_text_is_selected(const lv_obj_t * obj)
|
||||
#if LV_LABEL_TEXT_SELECTION
|
||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||
|
||||
if((lv_label_get_text_selection_start(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL ||
|
||||
lv_label_get_text_selection_end(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL)) {
|
||||
if((lv_label_get_text_selection_start(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL ||
|
||||
lv_label_get_text_selection_end(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
*.out
|
||||
*_Runner.c
|
||||
/report
|
||||
+14
-19
@@ -14,27 +14,19 @@ WARNINGS = -Werror -Wall -Wextra \
|
||||
WARNINGS += -Wpedantic -pedantic-errors
|
||||
|
||||
#-Wno-unused-value -Wno-unused-parameter
|
||||
OPTIMIZATION ?= -O3 -g0
|
||||
OPTIMIZATION ?= -g0
|
||||
|
||||
CFLAGS ?= -I$(LVGL_DIR)/ $(DEFINES) $(WARNINGS) $(OPTIMIZATION) -I$(LVGL_DIR) -I.
|
||||
CFLAGS ?= -I$(LVGL_DIR)/ --coverage -Isrc -Iunity $(DEFINES) $(WARNINGS) $(OPTIMIZATION) -I$(LVGL_DIR) -I.
|
||||
|
||||
LDFLAGS ?= -lpng
|
||||
BIN ?= demo
|
||||
|
||||
#Collect the files to compile
|
||||
MAINSRC = ./lv_test_main.c
|
||||
LDFLAGS ?= -lpng --coverage
|
||||
BIN ?= test
|
||||
|
||||
include ../lvgl.mk
|
||||
|
||||
CSRCS += lv_test_assert.c
|
||||
CSRCS += lv_test_core/lv_test_core.c
|
||||
CSRCS += lv_test_core/lv_test_obj.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
|
||||
CSRCS += ${TEST_SRC}
|
||||
CSRCS += src/lv_test_init.c
|
||||
CSRCS += src/lv_test_indev.c
|
||||
CSRCS := $(CSRCS) $(EXTRA_CSRCS)
|
||||
|
||||
OBJEXT ?= .o
|
||||
|
||||
@@ -51,11 +43,14 @@ OBJS = $(AOBJS) $(COBJS)
|
||||
all: default
|
||||
|
||||
%.o: %.c
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
@echo "CC $<"
|
||||
@$(CC) $(CFLAGS) -c -o $@ $<
|
||||
# @echo "CC $<"
|
||||
|
||||
default: $(AOBJS) $(COBJS) $(MAINOBJ)
|
||||
$(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ)
|
||||
find ../ -type f -name '*.o' -exec rm -f {} +
|
||||
find ../ -type f -name '*.gcda' -exec rm -f {} +
|
||||
find ../ -type f -name '*.gcno' -exec rm -f {} +
|
||||
rm -f $(BIN)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# Tests for LVGL
|
||||
|
||||
The tests in the folder can be run locally and automatically by GitHub CI.
|
||||
|
||||
## Running locally
|
||||
|
||||
### Requirements (Linux)
|
||||
1. Be sure GCC and Python3 is installed.
|
||||
2. Install [gcovr](https://gcovr.com/en/stable/index.html) with `pip install gcovr`
|
||||
3. Install Ruby with `sudo apt-get install ruby-full`
|
||||
|
||||
### Run test
|
||||
1. Enter `lvgl/tests/`
|
||||
2. Run the tests with `./main.py [OPTIONS]`. The options are
|
||||
- `report` Create a html page in the `report` folder with the coverage report.
|
||||
- `test` Build and run only test. Without this option LVGL will be built with various configurations.
|
||||
- `noclean` Do not clean the project before building. Useful while writing test to save some times.
|
||||
|
||||
For example:
|
||||
- `./main.py` Run all the test as they run in the CI.
|
||||
- `./main.py report test noclean` Run only the test, should be sued when writing tests.
|
||||
|
||||
|
||||
## Running automatically
|
||||
TODO
|
||||
|
||||
GitHub's CI automatically runs these tests on pushes and pull requests to `master` and `releasev8.*` branches.
|
||||
|
||||
## Directory structure
|
||||
- `src` Source files of the tests
|
||||
- `test_cases` The written tests,
|
||||
- `test_runners` Generated automatically from the files in `test_cases`.
|
||||
- other miscellaneous files and folders
|
||||
- `ref_imgs` - Reference images for screenshot compare
|
||||
- `report` - Coverage report. Generated if the `report` flag was passed to `./main.py`
|
||||
- `unity` Source files of the test engine
|
||||
|
||||
## Add new tests
|
||||
|
||||
### Create new test file
|
||||
New test needs to be added into the `src/test_cases` folder. The name of the files should look like `test_<name>.c`. The the basic skeleton of a test file copy `_test_template.c`.
|
||||
|
||||
### Asserts
|
||||
See the list of asserts [here](https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md).
|
||||
|
||||
There are some custom, LVGL specific asserts:
|
||||
- `TEST_ASSERT_EQUAL_SCREENSHOT("image1.png")` Render the active screen and compare its content with an image in the `ref_imgs` folder.
|
||||
If the compare fails `lvgl/test_screenshot_error.h` is created with the content of the frame buffer as an image.
|
||||
To see the that image `#include "test_screenshot_error.h"` and call `test_screenshot_error_show();`.
|
||||
- `TEST_ASSERT_EQUAL_COLOR(color1, color2)` Compare two colors.
|
||||
|
||||
### Adding new reference images
|
||||
The reference images can be taken by copy-pasting the test code in to LVGL simulator and saving the screen.
|
||||
LVGL needs to
|
||||
- 800x480 resolution
|
||||
- 32 bit color depth
|
||||
- `LV_USE_PERF_MONITOR` and `LV_USE_MEM_MONITOR` disabled
|
||||
- use the default theme, with the default color (don't set a theme manually)
|
||||
+60
-183
@@ -1,20 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
lvgldirname = os.path.abspath('..')
|
||||
lvgldirname = os.path.basename(lvgldirname)
|
||||
lvgldirname = '"' + lvgldirname + '"'
|
||||
|
||||
base_defines = '"-DLV_CONF_PATH=' + lvgldirname +'/tests/lv_test_conf.h -DLV_BUILD_TEST"'
|
||||
optimization = '"-O3 -g0"'
|
||||
base_defines = '"-DLV_CONF_PATH=' + lvgldirname +'/tests/src/lv_test_conf.h -DLV_BUILD_TEST"'
|
||||
|
||||
def build(name, defines):
|
||||
global base_defines, optimization
|
||||
def build(defines):
|
||||
global base_defines
|
||||
optimization = '"-O3 -g0"'
|
||||
d_all = base_defines[:-1] + " ";
|
||||
|
||||
for d in defines:
|
||||
d_all += " -D" + d + "=" + str(defines[d])
|
||||
|
||||
d_all += '"'
|
||||
# -s makes it silence
|
||||
cmd = "make -s -j BIN=test.bin " + "MAINSRC=src/lv_test_main.c LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization
|
||||
|
||||
print("=============================")
|
||||
print(name)
|
||||
print("=============================")
|
||||
print("")
|
||||
print("Build")
|
||||
print("-----------------------", flush=True)
|
||||
# print(cmd)
|
||||
ret = os.system(cmd)
|
||||
if(ret != 0):
|
||||
print("BUILD ERROR! (error code " + str(ret) + ")")
|
||||
exit(1)
|
||||
|
||||
print("")
|
||||
print("Run")
|
||||
print("-----------------------", flush=True)
|
||||
ret = os.system("./test.bin")
|
||||
if(ret != 0):
|
||||
print("RUN ERROR! (error code " + str(ret) + ")", flush=True)
|
||||
exit(1)
|
||||
|
||||
|
||||
def build_test(defines, test_name):
|
||||
global base_defines
|
||||
optimization = '"-g0"'
|
||||
|
||||
print("")
|
||||
print("")
|
||||
print("~~~~~~~~~~~~~~~~~~~~~~~~")
|
||||
print(re.search("/[a-z_]*$", test_name).group(0)[1:])
|
||||
print("~~~~~~~~~~~~~~~~~~~~~~~~", flush=True)
|
||||
|
||||
d_all = base_defines[:-1] + " ";
|
||||
|
||||
@@ -22,189 +55,33 @@ def build(name, defines):
|
||||
d_all += " -D" + d + "=" + str(defines[d])
|
||||
|
||||
d_all += '"'
|
||||
cmd = "make -j8 BIN=test.bin LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization
|
||||
|
||||
print("---------------------------")
|
||||
print("Clean")
|
||||
print("---------------------------")
|
||||
os.system("make clean LVGL_DIR_NAME=" + lvgldirname)
|
||||
os.system("rm -f ./test.bin")
|
||||
print("---------------------------")
|
||||
test_file_name = test_name + ".c"
|
||||
test_file_runner_name = test_name + "_Runner.c"
|
||||
test_file_runner_name = test_file_runner_name.replace("/test_cases/", "/test_runners/")
|
||||
csrcs = " EXTRA_CSRCS=\"unity/unity.c unity/unity_support.c src/test_fonts/font_1.c src/test_fonts/font_2.c src/test_fonts/font_3.c \" "
|
||||
# -s makes it silence
|
||||
cmd = "make -s -j BIN=test.bin MAINSRC=" + test_file_name + " TEST_SRC=" + test_file_runner_name + csrcs + " LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization
|
||||
|
||||
print("")
|
||||
print("Build")
|
||||
print("---------------------------")
|
||||
print("-----------------------", flush=True)
|
||||
# print(cmd)
|
||||
ret = os.system(cmd)
|
||||
if(ret != 0):
|
||||
print("BUILD ERROR! (error code " + str(ret) + ")")
|
||||
print("BUILD ERROR! (error code " + str(ret) + ")", flush=True)
|
||||
exit(1)
|
||||
|
||||
print("---------------------------")
|
||||
print("")
|
||||
print("Run")
|
||||
print("---------------------------")
|
||||
print("-----------------------")
|
||||
ret = os.system("./test.bin")
|
||||
if(ret != 0):
|
||||
print("RUN ERROR! (error code " + str(ret) + ")")
|
||||
print("RUN ERROR! (error code " + str(ret) + ")", flush=True)
|
||||
exit(1)
|
||||
|
||||
print("---------------------------")
|
||||
print("Finished")
|
||||
print("---------------------------")
|
||||
|
||||
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\\\"",
|
||||
}
|
||||
|
||||
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)
|
||||
def clean():
|
||||
print("")
|
||||
print("Clean")
|
||||
print("-----------------------", flush=True)
|
||||
os.system("make clean LVGL_DIR_NAME=" + lvgldirname)
|
||||
os.system("rm -f ./test.bin")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
:unity:
|
||||
:includes:
|
||||
- lv_test_init.h
|
||||
:suite_setup: "lv_test_init();"
|
||||
:suite_teardown: "lv_test_deinit();return num_failures;"
|
||||
@@ -0,0 +1,201 @@
|
||||
|
||||
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\\\"",
|
||||
|
||||
}
|
||||
|
||||
normal_16bit_swap = {
|
||||
"LV_COLOR_DEPTH":16,
|
||||
"LV_COLOR_16_SWAP":1,
|
||||
|
||||
"LV_MEM_SIZE":64 * 1024,
|
||||
|
||||
"LV_DPI_DEF":40,
|
||||
"LV_DRAW_COMPLEX":1,
|
||||
|
||||
"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_USE_LOG_LEVEL":"LV_LOG_LEVEL_TRACE",
|
||||
"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_24\\\"",
|
||||
}
|
||||
|
||||
test = {
|
||||
"LV_COLOR_DEPTH":32,
|
||||
"LV_MEM_SIZE":2 * 1024 * 1024,
|
||||
|
||||
"LV_SHADOW_CACHE_SIZE":10*1024,
|
||||
"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_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": 1,
|
||||
"LV_USE_LARGE_COORD": 1,
|
||||
|
||||
"LV_FONT_MONTSERRAT_14":1,
|
||||
"LV_FONT_MONTSERRAT_16":1,
|
||||
"LV_FONT_MONTSERRAT_18":1,
|
||||
"LV_FONT_MONTSERRAT_24":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_LABEL_TEXT_SELECTION":1,
|
||||
|
||||
"LV_BUILD_EXAMPLES":1,
|
||||
|
||||
"LV_FONT_DEFAULT":"\\\"&lv_font_montserrat_14\\\"",
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -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
|
||||
@@ -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*/
|
||||
@@ -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
|
||||
@@ -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*/
|
||||
@@ -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*/
|
||||
@@ -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
|
||||
@@ -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
@@ -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*/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -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
|
||||
@@ -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
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import defines
|
||||
import build
|
||||
import test
|
||||
import sys
|
||||
import os
|
||||
|
||||
def build_conf(title, defs):
|
||||
print("")
|
||||
print("")
|
||||
print("============================================")
|
||||
print(title)
|
||||
print("============================================")
|
||||
print("", flush=True)
|
||||
|
||||
build.clean()
|
||||
build.build(defs)
|
||||
|
||||
|
||||
test_only = False;
|
||||
test_report = False;
|
||||
test_noclean = False;
|
||||
if "test" in sys.argv: test_only = True;
|
||||
if "report" in sys.argv: test_report = True;
|
||||
if "noclean" in sys.argv: test_noclean = True;
|
||||
|
||||
if not test_only:
|
||||
build_conf("Minimal config monochrome", defines.minimal_monochrome)
|
||||
build_conf("Minimal config, 16 bit color depth", defines.minimal_16bit)
|
||||
build_conf("Normal config, 16 bit color depth swapped", defines.normal_16bit_swap)
|
||||
build_conf("Full config, 32 bit color depth", defines.full_32bit)
|
||||
|
||||
|
||||
files = test.prepare()
|
||||
if test_noclean == False:
|
||||
build.clean()
|
||||
|
||||
for f in files:
|
||||
name = f[:-2] #test_foo.c -> test_foo
|
||||
build.build_test(defines.test, name)
|
||||
|
||||
if test_report:
|
||||
print("")
|
||||
print("Generating report")
|
||||
print("-----------------------", flush=True)
|
||||
os.system("rm -r report")
|
||||
os.system("mkdir report")
|
||||
os.system("gcovr -r ../ --html-details -o report/index.html --exclude-directories '\.\./examples' --exclude-directories 'src/.*' --exclude-directories 'unity' --exclude 'lv_test_.*\.c'")
|
||||
print("Done: See report/index.html", flush=True)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,140 @@
|
||||
#include "../lvgl.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if LV_BUILD_TEST
|
||||
#include <sys/time.h>
|
||||
#include "lv_test_indev.h"
|
||||
#include "lv_test_init.h"
|
||||
|
||||
static lv_coord_t x_act;
|
||||
static lv_coord_t y_act;
|
||||
static uint32_t key_act;
|
||||
static int32_t diff_act;
|
||||
static bool mouse_pressed;
|
||||
static bool key_pressed;
|
||||
static bool enc_pressed;
|
||||
|
||||
void lv_test_mouse_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->point.x = x_act;
|
||||
data->point.y = y_act;
|
||||
data->state = mouse_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_to(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act = x;
|
||||
y_act = y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_by(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act += x;
|
||||
y_act += y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_press(void)
|
||||
{
|
||||
mouse_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_mouse_release(void)
|
||||
{
|
||||
mouse_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_mouse_click_at(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_move_to(x, y);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_keypad_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->key = key_act;
|
||||
data->state = key_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
void lv_test_key_press(uint32_t k)
|
||||
{
|
||||
key_act = k;
|
||||
key_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_key_release(void)
|
||||
{
|
||||
key_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_key_hit(uint32_t k)
|
||||
{
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_press(k);
|
||||
lv_test_mouse_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_key_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
void lv_test_encoder_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->enc_diff = diff_act;
|
||||
data->state = enc_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
diff_act = 0;
|
||||
}
|
||||
|
||||
void lv_test_encoder_add_diff(int32_t d)
|
||||
{
|
||||
diff_act += d;
|
||||
}
|
||||
|
||||
void lv_test_encoder_turn(int32_t d)
|
||||
{
|
||||
diff_act += d;
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_encoder_press(void)
|
||||
{
|
||||
enc_pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_encoder_release(void)
|
||||
{
|
||||
enc_pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_encoder_click(void)
|
||||
{
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_press();
|
||||
lv_test_indev_wait(50);
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
}
|
||||
|
||||
|
||||
void lv_test_indev_wait(uint32_t ms)
|
||||
{
|
||||
uint32_t t = lv_tick_get();
|
||||
while(lv_tick_elaps(t) < ms) {
|
||||
lv_timer_handler();
|
||||
lv_tick_inc(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
#ifndef LV_TEST_INDEV_H
|
||||
#define LV_TEST_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../lvgl.h"
|
||||
|
||||
void lv_test_mouse_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data);
|
||||
|
||||
void lv_test_mouse_move_to(lv_coord_t x, lv_coord_t y);
|
||||
void lv_test_mouse_move_by(lv_coord_t x, lv_coord_t y);
|
||||
void lv_test_mouse_press(void);
|
||||
void lv_test_mouse_release(void);
|
||||
void lv_test_mouse_click_at(lv_coord_t x, lv_coord_t y);
|
||||
|
||||
void lv_test_keypad_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data);
|
||||
|
||||
void lv_test_key_press(uint32_t k);
|
||||
void lv_test_key_release(void);
|
||||
void lv_test_key_hit(uint32_t k);
|
||||
|
||||
|
||||
void lv_test_encoder_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data) ;
|
||||
|
||||
void lv_test_encoder_add_diff(int32_t d);
|
||||
void lv_test_encoder_turn(int32_t d);
|
||||
void lv_test_encoder_press(void);
|
||||
void lv_test_encoder_release(void);
|
||||
void lv_test_encoder_click(void);
|
||||
|
||||
void lv_test_indev_wait(uint32_t ms);
|
||||
|
||||
extern lv_indev_t * lv_test_mouse_indev;
|
||||
extern lv_indev_t * lv_test_keypad_indev;
|
||||
extern lv_indev_t * lv_test_encoder_indev;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEST_INDEV_H*/
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "../lvgl.h"
|
||||
|
||||
#if LV_BUILD_TEST
|
||||
#include "lv_test_init.h"
|
||||
#include "lv_test_indev.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "lv_test_core/lv_test_core.h"
|
||||
#include "lv_test_widgets/lv_test_label.h"
|
||||
|
||||
#if LV_BUILD_TEST && !defined(LV_BUILD_TEST_NO_MAIN)
|
||||
#include <sys/time.h>
|
||||
|
||||
#define HOR_RES 800
|
||||
#define VER_RES 480
|
||||
@@ -13,20 +12,22 @@
|
||||
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_indev_t * lv_test_mouse_indev;
|
||||
lv_indev_t * lv_test_keypad_indev;
|
||||
lv_indev_t * lv_test_encoder_indev;
|
||||
|
||||
lv_color_t test_fb[HOR_RES * VER_RES];
|
||||
static lv_color_t disp_buf1[HOR_RES * VER_RES];
|
||||
|
||||
int main(void)
|
||||
void lv_test_init(void)
|
||||
{
|
||||
printf("Call lv_init...\n");
|
||||
lv_init();
|
||||
|
||||
hal_init();
|
||||
}
|
||||
|
||||
lv_test_core();
|
||||
// lv_test_label();
|
||||
|
||||
printf("Exit with success!\n");
|
||||
return 0;
|
||||
void lv_test_deinit(void)
|
||||
{
|
||||
lv_mem_deinit();
|
||||
}
|
||||
|
||||
static void * open_cb(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
@@ -88,13 +89,11 @@ static lv_fs_res_t tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
static void hal_init(void)
|
||||
{
|
||||
static lv_disp_draw_buf_t draw_buf;
|
||||
lv_color_t * disp_buf1 = (lv_color_t *)malloc(LV_HOR_RES * LV_VER_RES * sizeof(lv_color_t));
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf, disp_buf1, NULL, LV_HOR_RES * LV_VER_RES);
|
||||
lv_disp_draw_buf_init(&draw_buf, disp_buf1, NULL, HOR_RES * VER_RES);
|
||||
|
||||
static lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
@@ -103,6 +102,25 @@ static void hal_init(void)
|
||||
disp_drv.hor_res = HOR_RES;
|
||||
disp_drv.ver_res = VER_RES;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
static lv_indev_drv_t indev_mouse_drv;
|
||||
lv_indev_drv_init(&indev_mouse_drv);
|
||||
indev_mouse_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_mouse_drv.read_cb = lv_test_mouse_read_cb;
|
||||
lv_test_mouse_indev = lv_indev_drv_register(&indev_mouse_drv);
|
||||
|
||||
static lv_indev_drv_t indev_keypad_drv;
|
||||
lv_indev_drv_init(&indev_keypad_drv);
|
||||
indev_keypad_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_keypad_drv.read_cb = lv_test_keypad_read_cb;
|
||||
lv_test_keypad_indev = lv_indev_drv_register(&indev_keypad_drv);
|
||||
|
||||
static lv_indev_drv_t indev_encoder_drv;
|
||||
lv_indev_drv_init(&indev_encoder_drv);
|
||||
indev_encoder_drv.type = LV_INDEV_TYPE_ENCODER;
|
||||
indev_encoder_drv.read_cb = lv_test_encoder_read_cb;
|
||||
lv_test_encoder_indev = lv_indev_drv_register(&indev_encoder_drv);
|
||||
|
||||
|
||||
static lv_fs_drv_t drv;
|
||||
lv_fs_drv_init(&drv); /*Basic initialization*/
|
||||
@@ -116,7 +134,6 @@ static void hal_init(void)
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef LV_TEST_INIT_H
|
||||
#define LV_TEST_INIT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <../lvgl.h>
|
||||
|
||||
void lv_test_init(void);
|
||||
void lv_test_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEST_INIT_H*/
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "../lvgl.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if LV_BUILD_TEST && !defined(LV_BUILD_TEST_NO_MAIN)
|
||||
#include <sys/time.h>
|
||||
#include "lv_test_init.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lv_test_init();
|
||||
|
||||
printf("Exit with success!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../lvgl.h"
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void test_func_1(void);
|
||||
|
||||
void test_func_1(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(actual, expected);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "../lvgl.h"
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void test_config(void);
|
||||
|
||||
void test_config(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(130, LV_DPI_DEF);
|
||||
TEST_ASSERT_EQUAL(130, lv_disp_get_dpi(NULL));
|
||||
TEST_ASSERT_EQUAL(800, LV_HOR_RES);
|
||||
TEST_ASSERT_EQUAL(800, lv_disp_get_hor_res(NULL));
|
||||
TEST_ASSERT_EQUAL(480, LV_VER_RES);
|
||||
TEST_ASSERT_EQUAL(480, lv_disp_get_ver_res(NULL));
|
||||
TEST_ASSERT_EQUAL(32, LV_COLOR_DEPTH);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,432 @@
|
||||
#include "../lvgl.h"
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
#include "lv_test_indev.h"
|
||||
|
||||
void test_dropdown_create_delete(void);
|
||||
void test_dropdown_set_text_and_symbol(void);
|
||||
void test_dropdown_set_options(void);
|
||||
void test_dropdown_select(void);
|
||||
void test_dropdown_click(void);
|
||||
void test_dropdown_keypad(void);
|
||||
void test_dropdown_encoder(void);
|
||||
void test_dropdown_render_1(void);
|
||||
void test_dropdown_render_2(void);
|
||||
|
||||
void test_dropdown_create_delete(void)
|
||||
{
|
||||
lv_dropdown_create(lv_scr_act());
|
||||
TEST_ASSERT_EQUAL(1, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
|
||||
lv_obj_t * dd2 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd2, 200, 0);
|
||||
TEST_ASSERT_EQUAL(2, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
lv_dropdown_open(dd2);
|
||||
TEST_ASSERT_EQUAL(3, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd2));
|
||||
lv_dropdown_open(dd2); /*Try to pen again*/
|
||||
TEST_ASSERT_EQUAL(3, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
|
||||
lv_obj_t * dd3 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd3, 400, 0);
|
||||
TEST_ASSERT_EQUAL(4, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
lv_dropdown_open(dd3);
|
||||
TEST_ASSERT_EQUAL(5, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
lv_dropdown_close(dd3);
|
||||
TEST_ASSERT_EQUAL(4, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
lv_dropdown_close(dd3); /*Try to close again*/
|
||||
TEST_ASSERT_EQUAL(4, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
|
||||
lv_obj_del(dd2);
|
||||
TEST_ASSERT_EQUAL(2, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
TEST_ASSERT_EQUAL(0, lv_obj_get_child_cnt(lv_scr_act()));
|
||||
|
||||
}
|
||||
|
||||
void test_dropdown_set_text_and_symbol(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(0, 0);
|
||||
}
|
||||
|
||||
void test_dropdown_set_options(void)
|
||||
{
|
||||
|
||||
lv_mem_monitor_t m1;
|
||||
lv_mem_monitor(&m1);
|
||||
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
TEST_ASSERT_EQUAL_STRING("Option 1\nOption 2\nOption 3", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(3, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_set_options(dd1, "a1\nb2\nc3\nd4\ne5\nf6");
|
||||
TEST_ASSERT_EQUAL_STRING("a1\nb2\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(6, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_obj_set_width(dd1, 200);
|
||||
lv_dropdown_open(dd1);
|
||||
lv_obj_update_layout(dd1);
|
||||
TEST_ASSERT_EQUAL(200, lv_obj_get_width(lv_dropdown_get_list(dd1)));
|
||||
|
||||
lv_dropdown_close(dd1);
|
||||
|
||||
lv_dropdown_add_option(dd1, "x0", 0);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(7, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_add_option(dd1, "y0", 3);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\ny0\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(8, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_add_option(dd1, "z0", LV_DROPDOWN_POS_LAST);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\ny0\nc3\nd4\ne5\nf6\nz0", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(9, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_clear_options(dd1);
|
||||
TEST_ASSERT_EQUAL_STRING("", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(0, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_set_options(dd1, "o1\no2"); /*Just to add some content before lv_dropdown_set_options_static*/
|
||||
|
||||
lv_dropdown_set_options_static(dd1, "a1\nb2\nc3\nd4\ne5\nf6");
|
||||
TEST_ASSERT_EQUAL_STRING("a1\nb2\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(6, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_add_option(dd1, "x0", 0);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(7, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_add_option(dd1, "y0", 3);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\ny0\nc3\nd4\ne5\nf6", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(8, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_add_option(dd1, "z0", LV_DROPDOWN_POS_LAST);
|
||||
TEST_ASSERT_EQUAL_STRING("x0\na1\nb2\ny0\nc3\nd4\ne5\nf6\nz0", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(9, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_dropdown_clear_options(dd1);
|
||||
TEST_ASSERT_EQUAL_STRING("", lv_dropdown_get_options(dd1));
|
||||
TEST_ASSERT_EQUAL(0, lv_dropdown_get_option_cnt(dd1));
|
||||
|
||||
lv_obj_del(dd1);
|
||||
|
||||
lv_mem_monitor_t m2;
|
||||
lv_mem_monitor(&m2);
|
||||
TEST_ASSERT_UINT32_WITHIN(48, m1.free_size, m2.free_size);
|
||||
}
|
||||
|
||||
void test_dropdown_select(void)
|
||||
{
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_selected(dd1, 2);
|
||||
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
|
||||
char buf[32];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
lv_dropdown_get_selected_str(dd1, buf, sizeof(buf));
|
||||
TEST_ASSERT_EQUAL_STRING("Option 3", buf);
|
||||
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
lv_dropdown_get_selected_str(dd1, buf, 4);
|
||||
TEST_ASSERT_EQUAL_STRING("Opt", buf);
|
||||
|
||||
/*Out of range*/
|
||||
lv_dropdown_set_selected(dd1, 3);
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
}
|
||||
|
||||
void test_dropdown_click(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_update_layout(dd1);
|
||||
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_mouse_click_at(dd1->coords.x1 + 5, dd1->coords.y1 + 5);
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
|
||||
lv_obj_t * list = lv_dropdown_get_list(dd1);
|
||||
TEST_ASSERT_EQUAL(0, lv_dropdown_get_selected(dd1));
|
||||
lv_test_mouse_click_at(list->coords.x1 + 5, list->coords.y2 - 25);
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
}
|
||||
|
||||
static uint32_t event_cnt;
|
||||
static void dd_event(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(e);
|
||||
event_cnt++;
|
||||
}
|
||||
|
||||
void test_dropdown_keypad(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_group_t * g = lv_group_create();
|
||||
lv_indev_set_group(lv_test_keypad_indev, g);
|
||||
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd1, 20, 20);
|
||||
lv_dropdown_set_options(dd1, "1\n2\n3\n4\n5\n6\n7\n8");
|
||||
lv_group_add_obj(g, dd1);
|
||||
lv_obj_add_event_cb(dd1, dd_event, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
lv_obj_t * dd2 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd2, 300, 20);
|
||||
lv_group_add_obj(g, dd2);
|
||||
|
||||
event_cnt = 0;
|
||||
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_RIGHT); /*Same as down*/
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(1, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_DOWN); /*Open the list too*/
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(3, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(2, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_RIGHT); /*Open the list too*/
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_key_hit(LV_KEY_RIGHT);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(4, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(3, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_LEFT); /*Open the list too*/
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_key_hit(LV_KEY_LEFT);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(3, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(4, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_UP); /*Open the list too*/
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_key_hit(LV_KEY_UP);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(5, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_UP);
|
||||
lv_test_key_hit(LV_KEY_UP);
|
||||
lv_test_key_hit(LV_KEY_UP);
|
||||
lv_test_key_hit(LV_KEY_UP);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(0, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(6, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_DOWN);
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(7, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(7, event_cnt);
|
||||
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
|
||||
lv_test_key_hit(LV_KEY_NEXT);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
|
||||
lv_test_key_hit(LV_KEY_ENTER);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd2));
|
||||
|
||||
lv_indev_set_group(lv_test_keypad_indev, NULL);
|
||||
lv_group_del(g);
|
||||
}
|
||||
|
||||
|
||||
void test_dropdown_encoder(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_group_t * g = lv_group_create();
|
||||
lv_indev_set_group(lv_test_encoder_indev, g);
|
||||
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd1, 20, 20);
|
||||
lv_dropdown_set_options(dd1, "1\n2\n3\n4\n5\n6\n7\n8");
|
||||
lv_group_add_obj(g, dd1);
|
||||
lv_obj_add_event_cb(dd1, dd_event, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
lv_obj_t * dd2 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd2, 300, 20);
|
||||
lv_group_add_obj(g, dd2);
|
||||
|
||||
event_cnt = 0;
|
||||
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
lv_test_encoder_click();
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd2));
|
||||
|
||||
lv_test_encoder_turn(5);
|
||||
lv_test_encoder_click();
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(5, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(1, event_cnt);
|
||||
|
||||
lv_test_encoder_click();
|
||||
lv_test_encoder_turn(-1);
|
||||
lv_test_encoder_click();
|
||||
TEST_ASSERT_EQUAL(4, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(2, event_cnt);
|
||||
|
||||
lv_test_encoder_click();
|
||||
lv_test_encoder_turn(2);
|
||||
lv_test_encoder_press();
|
||||
lv_test_indev_wait(1000); //Long press
|
||||
lv_test_encoder_release();
|
||||
lv_test_indev_wait(50);
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_EQUAL(4, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_EQUAL(2, event_cnt);
|
||||
|
||||
lv_test_encoder_turn(1);
|
||||
lv_test_encoder_click();
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd2));
|
||||
|
||||
lv_indev_set_group(lv_test_encoder_indev, NULL);
|
||||
lv_group_del(g);
|
||||
}
|
||||
|
||||
|
||||
void test_dropdown_render_1(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd1, 10, 10);
|
||||
lv_dropdown_set_selected(dd1, 1);
|
||||
|
||||
lv_obj_t * dd2 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_pos(dd2, 200, 10);
|
||||
lv_obj_set_width(dd2, 200);
|
||||
lv_dropdown_set_selected(dd2, 2);
|
||||
lv_dropdown_open(dd2);
|
||||
TEST_ASSERT_TRUE(lv_dropdown_get_selected_highlight(dd2));
|
||||
lv_dropdown_set_selected_highlight(dd2, false);
|
||||
TEST_ASSERT_FALSE(lv_dropdown_get_selected_highlight(dd2));
|
||||
|
||||
lv_obj_t * dd3 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_set_style_pad_hor(dd3, 5, 0);
|
||||
lv_obj_set_style_pad_ver(dd3, 20, 0);
|
||||
lv_obj_set_pos(dd3, 500, 150);
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_dropdown_get_text(dd3));
|
||||
lv_dropdown_set_text(dd3, "A text");
|
||||
TEST_ASSERT_EQUAL_STRING("A text", lv_dropdown_get_text(dd3));
|
||||
|
||||
lv_dropdown_set_selected(dd3, 2);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_DIR_BOTTOM, lv_dropdown_get_dir(dd3));
|
||||
lv_dropdown_set_dir(dd3, LV_DIR_LEFT);
|
||||
TEST_ASSERT_EQUAL(LV_DIR_LEFT, lv_dropdown_get_dir(dd3));
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(LV_SYMBOL_DOWN, lv_dropdown_get_symbol(dd3));
|
||||
lv_dropdown_set_symbol(dd3, LV_SYMBOL_LEFT);
|
||||
TEST_ASSERT_EQUAL_STRING(LV_SYMBOL_LEFT, lv_dropdown_get_symbol(dd3));
|
||||
|
||||
lv_dropdown_set_options(dd3, "a0\na1\na2\na3\na4\na5\na6\na7\na8\na9\na10\na11\na12\na13\na14\na15\na16");
|
||||
lv_dropdown_open(dd3);
|
||||
lv_dropdown_set_selected(dd3, 3);
|
||||
lv_obj_t * list = lv_dropdown_get_list(dd3);
|
||||
lv_obj_set_style_text_line_space(list, 5, 0);
|
||||
lv_obj_set_style_bg_color(list, lv_color_hex3(0xf00), LV_PART_SELECTED | LV_STATE_CHECKED);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("dropdown_1.png");
|
||||
}
|
||||
|
||||
void test_dropdown_render_2(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
LV_IMG_DECLARE(img_caret_down);
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd1, "Short");
|
||||
lv_dropdown_set_options(dd1, "1\n2");
|
||||
lv_dropdown_set_symbol(dd1, &img_caret_down);
|
||||
lv_dropdown_open(dd1);
|
||||
|
||||
lv_obj_t * dd2 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd2, "Go Up");
|
||||
lv_dropdown_set_options(dd2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15");
|
||||
lv_dropdown_set_symbol(dd2, NULL);
|
||||
lv_obj_align(dd2, LV_ALIGN_LEFT_MID, 150, 50);
|
||||
lv_dropdown_open(dd2);
|
||||
|
||||
lv_obj_t * dd3 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd3, "Limit Down");
|
||||
lv_dropdown_set_options(dd3, "1aaaaaaaaaaaaaaaa\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15");
|
||||
lv_obj_align(dd3, LV_ALIGN_LEFT_MID, 300, -10);
|
||||
lv_dropdown_open(dd3);
|
||||
|
||||
lv_obj_t * dd4 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd4, "Limit Top");
|
||||
lv_dropdown_set_options(dd4, "1aaaaaaaaaaaaaaaa\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15");
|
||||
lv_obj_align(dd4, LV_ALIGN_LEFT_MID, 450, 10);
|
||||
lv_dropdown_set_dir(dd4, LV_DIR_TOP);
|
||||
lv_dropdown_set_symbol(dd4, LV_SYMBOL_UP);
|
||||
lv_dropdown_open(dd4);
|
||||
|
||||
lv_obj_t * dd5 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd5, "Go Down");
|
||||
lv_dropdown_set_options(dd5, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15");
|
||||
lv_dropdown_set_dir(dd5, LV_DIR_TOP);
|
||||
lv_dropdown_set_symbol(dd5, LV_SYMBOL_UP);
|
||||
lv_obj_align(dd5, LV_ALIGN_LEFT_MID, 650, -200);
|
||||
lv_dropdown_open(dd5);
|
||||
|
||||
lv_obj_t * dd6 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd6, "Right");
|
||||
lv_dropdown_set_options(dd6, "1aaa\n2aa\n3aa");
|
||||
lv_dropdown_set_dir(dd6, LV_DIR_RIGHT);
|
||||
lv_dropdown_set_symbol(dd6, LV_SYMBOL_RIGHT);
|
||||
lv_obj_align(dd6, LV_ALIGN_BOTTOM_LEFT, 20, -20);
|
||||
lv_dropdown_open(dd6);
|
||||
lv_obj_set_style_text_align(lv_dropdown_get_list(dd6), LV_TEXT_ALIGN_RIGHT, 0);
|
||||
|
||||
lv_obj_t * dd7 = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_text(dd7, "Left");
|
||||
lv_dropdown_set_options(dd7, "1aaa\n2\n3");
|
||||
lv_dropdown_set_dir(dd7, LV_DIR_LEFT);
|
||||
lv_dropdown_set_symbol(dd7, LV_SYMBOL_LEFT);
|
||||
lv_dropdown_open(dd7);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("dropdown_2.png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+45
-49
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file lv_test_font_loader.c
|
||||
* @file test_font_loader.c
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -9,12 +9,8 @@
|
||||
|
||||
#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"
|
||||
#include "unity/unity.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -29,6 +25,7 @@
|
||||
**********************/
|
||||
|
||||
static int compare_fonts(lv_font_t * f1, lv_font_t * f2);
|
||||
void test_font_loader(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -46,11 +43,11 @@ extern lv_font_t font_1;
|
||||
extern lv_font_t font_2;
|
||||
extern lv_font_t font_3;
|
||||
|
||||
void lv_test_font_loader(void)
|
||||
void 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");
|
||||
lv_font_t * font_1_bin = lv_font_load("F:src/test_fonts/font_1.fnt");
|
||||
lv_font_t * font_2_bin = lv_font_load("F:src/test_fonts/font_2.fnt");
|
||||
lv_font_t * font_3_bin = lv_font_load("F:src/test_fonts/font_3.fnt");
|
||||
|
||||
compare_fonts(&font_1, font_1_bin);
|
||||
compare_fonts(&font_2, font_2_bin);
|
||||
@@ -63,26 +60,25 @@ void lv_test_font_loader(void)
|
||||
|
||||
static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
{
|
||||
lv_test_assert_true(f1 != NULL && f2 != NULL, "font not null");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(f1, "font not null");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(f2, "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");
|
||||
// TEST_ASSERT_EQUAL_PTR_MESSAGE(f1->get_glyph_dsc, f2->get_glyph_dsc, "glyph_dsc");
|
||||
// TEST_ASSERT_EQUAL_PTR_MESSAGE(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
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(f1->line_height, f2->line_height, "line_height");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(f1->base_line, f2->base_line, "base_line");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(f1->subpx, f2->subpx, "subpx");
|
||||
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");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(dsc1->kern_scale, dsc2->kern_scale, "kern_scale");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(dsc1->cmap_num, dsc2->cmap_num, "cmap_num");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(dsc1->bpp, dsc2->bpp, "bpp");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(dsc1->kern_classes, dsc2->kern_classes, "kern_classes");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(dsc1->bitmap_format, dsc2->bitmap_format, "bitmap_format");
|
||||
|
||||
// cmaps
|
||||
int total_glyphs = 0;
|
||||
@@ -90,16 +86,16 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
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");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(cmaps1->range_start, cmaps2->range_start, "range_start");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(cmaps1->range_length, cmaps2->range_length, "range_length");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(cmaps1->glyph_id_start, cmaps2->glyph_id_start, "glyph_id_start");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(cmaps1->type, cmaps2->type, "type");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(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");
|
||||
TEST_ASSERT_TRUE_MESSAGE(cmaps1->unicode_list && cmaps2->unicode_list, "unicode_list");
|
||||
|
||||
lv_test_assert_array_eq(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
(uint8_t *)cmaps1->unicode_list,
|
||||
(uint8_t *)cmaps2->unicode_list,
|
||||
sizeof(uint16_t) * cmaps1->list_length,
|
||||
@@ -108,17 +104,17 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
}
|
||||
else {
|
||||
total_glyphs += cmaps1->range_length;
|
||||
lv_test_assert_ptr_eq(cmaps1->unicode_list, cmaps2->unicode_list, "unicode_list");
|
||||
TEST_ASSERT_EQUAL_PTR_MESSAGE(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");
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(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");
|
||||
TEST_ASSERT_EQUAL_PTR_MESSAGE(cmaps1->glyph_id_ofs_list, cmaps2->glyph_id_ofs_list, "glyph_id_ofs_list");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,37 +123,37 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
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");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->right_class_cnt, kern2->right_class_cnt, "right_class_cnt");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->left_class_cnt, kern2->left_class_cnt, "left_class_cnt");
|
||||
|
||||
lv_test_assert_array_eq(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
(uint8_t *)kern1->left_class_mapping,
|
||||
(uint8_t *)kern2->left_class_mapping,
|
||||
kern1->left_class_cnt,
|
||||
"left_class_mapping");
|
||||
|
||||
lv_test_assert_array_eq(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
(uint8_t *)kern1->right_class_mapping,
|
||||
(uint8_t *)kern2->right_class_mapping,
|
||||
kern1->right_class_cnt,
|
||||
"right_class_mapping");
|
||||
|
||||
lv_test_assert_array_eq(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
(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");
|
||||
TEST_ASSERT_EQUAL_PTR_MESSAGE(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");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->glyph_ids_size, kern2->glyph_ids_size, "glyph_ids_size");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(kern1->pair_cnt, kern2->pair_cnt, "pair_cnt");
|
||||
|
||||
int ids_size;
|
||||
|
||||
@@ -168,8 +164,8 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
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(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(kern1->glyph_ids, kern2->glyph_ids, ids_size, "glyph_ids");
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
(uint8_t * ) kern1->values,
|
||||
(uint8_t * ) kern2->values,
|
||||
kern1->pair_cnt,
|
||||
@@ -185,17 +181,17 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
|
||||
int size1 = glyph_dsc1[i+1].bitmap_index - glyph_dsc1[i].bitmap_index;
|
||||
|
||||
if (size1 > 0) {
|
||||
lv_test_assert_array_eq(
|
||||
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(
|
||||
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");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(glyph_dsc1[i].adv_w, glyph_dsc2[i].adv_w, "adv_w");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(glyph_dsc1[i].box_w, glyph_dsc2[i].box_w, "box_w");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(glyph_dsc1[i].box_h, glyph_dsc2[i].box_h, "box_h");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(glyph_dsc1[i].ofs_x, glyph_dsc2[i].ofs_x, "ofs_x");
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(glyph_dsc1[i].ofs_y, glyph_dsc2[i].ofs_y, "ofs_y");
|
||||
}
|
||||
|
||||
LV_LOG_INFO("No differences found!");
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "../lvgl.h"
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
lv_color_t c1 = lv_color_hex(0x444444);
|
||||
lv_color_t c2 = lv_color_hex3(0x444);
|
||||
TEST_ASSERT_EQUAL_COLOR(c1, c2);
|
||||
|
||||
lv_obj_remove_style_all(lv_scr_act());
|
||||
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x112233), 0);
|
||||
lv_obj_set_style_bg_opa(lv_scr_act(), LV_OPA_COVER, 0);
|
||||
|
||||
//TEST_ASSERT_EQUAL_SCREENSHOT("scr1.png")
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "../lvgl.h"
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
//void test_func_1(void);
|
||||
|
||||
//void test_func_1(void)
|
||||
//{
|
||||
// TEST_ASSERT_EQUAL(actual, expected);
|
||||
//}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
import glob
|
||||
|
||||
def prepare():
|
||||
os.system("rm src/*.o")
|
||||
os.system("rm -rdf src/test_runners")
|
||||
os.system("mkdir src/test_runners")
|
||||
files = glob.glob("./src/test_cases/test_*.c")
|
||||
|
||||
for index, item in enumerate(files):
|
||||
if item == "./src/test_cases/test_config.c":
|
||||
files.pop(index)
|
||||
break
|
||||
|
||||
files.insert(0, "./src/test_cases/test_config.c")
|
||||
|
||||
for f in files:
|
||||
r = f[:-2] + "_Runner.c"
|
||||
r = r.replace("/test_cases/", "/test_runners/")
|
||||
cmd = "ruby unity/generate_test_runner.rb " + f + " " + r + " config.yml"
|
||||
os.system(cmd)
|
||||
return files
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user