Skip to content

Commit 477b8f9

Browse files
committed
feat: update
1 parent 757d93a commit 477b8f9

File tree

14 files changed

+270
-88
lines changed

14 files changed

+270
-88
lines changed

test_apps/lcd/3wire_spi_rgb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5-
project(test_app_lcd)
5+
project(3wire_spi_rgb_lcd_test)

test_apps/lcd/3wire_spi_rgb/main/test_3wire_spi_rgb_lcd.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,6 @@ const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
108108

109109
static const char *TAG = "test_3wire_spi_rgb_lcd";
110110

111-
#define CREATE_LCD(name, panel_bus) \
112-
({ \
113-
ESP_LOGI(TAG, "Create LCD device: " #name); \
114-
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
115-
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
116-
lcd; \
117-
})
118-
#define CREATE_TEST_CASE(name) \
119-
TEST_CASE("Test LCD (" #name ") to draw color bar", "[3wire_spi_rgb_lcd][" #name "]") \
120-
{ \
121-
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
122-
shared_ptr<ESP_PanelBus_RGB> panel_bus = init_panel_bus(); \
123-
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
124-
test_lcd(lcd); \
125-
}
126-
127-
/**
128-
* Here are some common functions for initializing the backlight, panel bus, and drawing the color bar
129-
*
130-
*/
131111
static shared_ptr<ESP_PanelBacklight> init_backlight(void)
132112
{
133113
#if TEST_LCD_PIN_NUM_BK_LIGHT >= 0
@@ -211,7 +191,7 @@ IRAM_ATTR bool onVsyncEndCallback(void *user_data)
211191
}
212192
#endif
213193

214-
static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
194+
static void run_test(shared_ptr<ESP_PanelLcd> lcd)
215195
{
216196
#if TEST_LCD_USE_EXTERNAL_CMD
217197
// Configure external initialization commands, should called before `init()`
@@ -233,6 +213,22 @@ static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
233213
TEST_ASSERT_TRUE_MESSAGE(lcd->colorBarTest(TEST_LCD_WIDTH, TEST_LCD_HEIGHT), "LCD color bar test failed");
234214
}
235215

216+
#define CREATE_LCD(name, panel_bus) \
217+
({ \
218+
ESP_LOGI(TAG, "Create LCD device: " #name); \
219+
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
220+
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
221+
lcd; \
222+
})
223+
#define CREATE_TEST_CASE(name) \
224+
TEST_CASE("Test LCD (" #name ") to draw color bar", "[3wire_spi_rgb_lcd][" #name "]") \
225+
{ \
226+
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
227+
shared_ptr<ESP_PanelBus_RGB> panel_bus = init_panel_bus(); \
228+
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
229+
run_test(lcd); \
230+
}
231+
236232
/**
237233
* Here to create test cases for different LCDs
238234
*

test_apps/lcd/qspi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5-
project(test_app_lcd)
5+
project(qspi_lcd_test)

test_apps/lcd/qspi/main/test_qspi_lcd.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,6 @@ const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
7070

7171
static const char *TAG = "test_qspi_lcd";
7272

73-
#define CREATE_LCD(name, panel_bus) \
74-
({ \
75-
ESP_LOGI(TAG, "Create LCD device: " #name); \
76-
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
77-
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
78-
lcd; \
79-
})
80-
#define CREATE_TEST_CASE(name) \
81-
TEST_CASE("Test LCD (" #name ") to draw color bar", "[qspi_lcd][" #name "]") \
82-
{ \
83-
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
84-
shared_ptr<ESP_PanelBus_QSPI> panel_bus = init_panel_bus(); \
85-
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
86-
test_lcd(lcd); \
87-
}
88-
89-
/**
90-
* Here are some common functions for initializing the backlight, panel bus, and drawing the color bar
91-
*
92-
*/
9373
static shared_ptr<ESP_PanelBacklight> init_backlight(void)
9474
{
9575
#if TEST_LCD_PIN_NUM_BK_LIGHT >= 0
@@ -133,7 +113,7 @@ IRAM_ATTR static bool onDrawBitmapFinishCallback(void *user_data)
133113
}
134114
#endif
135115

136-
static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
116+
static void run_test(shared_ptr<ESP_PanelLcd> lcd)
137117
{
138118
#if TEST_LCD_USE_EXTERNAL_CMD
139119
// Configure external initialization commands, should called before `init()`
@@ -153,6 +133,22 @@ static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
153133
TEST_ASSERT_TRUE_MESSAGE(lcd->colorBarTest(TEST_LCD_WIDTH, TEST_LCD_HEIGHT), "LCD color bar test failed");
154134
}
155135

136+
#define CREATE_LCD(name, panel_bus) \
137+
({ \
138+
ESP_LOGI(TAG, "Create LCD device: " #name); \
139+
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
140+
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
141+
lcd; \
142+
})
143+
#define CREATE_TEST_CASE(name) \
144+
TEST_CASE("Test LCD (" #name ") to draw color bar", "[qspi_lcd][" #name "]") \
145+
{ \
146+
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
147+
shared_ptr<ESP_PanelBus_QSPI> panel_bus = init_panel_bus(); \
148+
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
149+
run_test(lcd); \
150+
}
151+
156152
/**
157153
* Here to create test cases for different LCDs
158154
*

test_apps/lcd/rgb/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5-
project(test_app_lcd)
5+
project(rgb_lcd_test)

test_apps/lcd/rgb/main/test_rgb_lcd.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,6 @@ using namespace std;
7777

7878
static const char *TAG = "test_rgb_lcd";
7979

80-
#define CREATE_LCD(name, panel_bus) \
81-
({ \
82-
ESP_LOGI(TAG, "Create LCD device: " #name); \
83-
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
84-
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
85-
lcd; \
86-
})
87-
#define CREATE_TEST_CASE(name) \
88-
TEST_CASE("Test LCD (" #name ") to draw color bar", "[rgb_lcd][" #name "]") \
89-
{ \
90-
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
91-
shared_ptr<ESP_PanelBus_RGB> panel_bus = init_panel_bus(); \
92-
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
93-
test_lcd(lcd); \
94-
}
95-
96-
/**
97-
* Here are some common functions for initializing the backlight, panel bus, and drawing the color bar
98-
*
99-
*/
10080
static shared_ptr<ESP_PanelBacklight> init_backlight(void)
10181
{
10282
#if TEST_LCD_PIN_NUM_BK_LIGHT >= 0
@@ -178,7 +158,7 @@ IRAM_ATTR bool onVsyncEndCallback(void *user_data)
178158
}
179159
#endif
180160

181-
static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
161+
static void run_test(shared_ptr<ESP_PanelLcd> lcd)
182162
{
183163
#if TEST_LCD_USE_EXTERNAL_CMD
184164
// Configure external initialization commands, should called before `init()`
@@ -200,6 +180,22 @@ static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
200180
TEST_ASSERT_TRUE_MESSAGE(lcd->colorBarTest(TEST_LCD_WIDTH, TEST_LCD_HEIGHT), "LCD color bar test failed");
201181
}
202182

183+
#define CREATE_LCD(name, panel_bus) \
184+
({ \
185+
ESP_LOGI(TAG, "Create LCD device: " #name); \
186+
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
187+
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
188+
lcd; \
189+
})
190+
#define CREATE_TEST_CASE(name) \
191+
TEST_CASE("Test LCD (" #name ") to draw color bar", "[rgb_lcd][" #name "]") \
192+
{ \
193+
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
194+
shared_ptr<ESP_PanelBus_RGB> panel_bus = init_panel_bus(); \
195+
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
196+
run_test(lcd); \
197+
}
198+
203199
/**
204200
* Here to create test cases for different LCDs
205201
*

test_apps/lcd/spi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.5)
44
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5-
project(test_app_lcd)
5+
project(spi_lcd_test)

test_apps/lcd/spi/main/test_spi_lcd.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,6 @@ const esp_lcd_panel_vendor_init_cmd_t lcd_init_cmd[] = {
6969

7070
static const char *TAG = "test_spi_lcd";
7171

72-
#define CREATE_LCD(name, panel_bus) \
73-
({ \
74-
ESP_LOGI(TAG, "Create LCD device: " #name); \
75-
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
76-
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
77-
lcd; \
78-
})
79-
#define CREATE_TEST_CASE(name) \
80-
TEST_CASE("Test LCD (" #name ") to draw color bar", "[spi_lcd][" #name "]") \
81-
{ \
82-
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
83-
shared_ptr<ESP_PanelBus_SPI> panel_bus = init_panel_bus(); \
84-
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
85-
test_lcd(lcd); \
86-
}
87-
88-
/**
89-
* Here are some common functions for initializing the backlight, panel bus, and drawing the color bar
90-
*
91-
*/
9272
static shared_ptr<ESP_PanelBacklight> init_backlight(void)
9373
{
9474
#if TEST_LCD_PIN_NUM_BK_LIGHT >= 0
@@ -131,7 +111,7 @@ IRAM_ATTR static bool onDrawBitmapFinishCallback(void *user_data)
131111
}
132112
#endif
133113

134-
static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
114+
static void run_test(shared_ptr<ESP_PanelLcd> lcd)
135115
{
136116
#if TEST_LCD_USE_EXTERNAL_CMD
137117
// Configure external initialization commands, should called before `init()`
@@ -151,6 +131,22 @@ static void test_lcd(shared_ptr<ESP_PanelLcd> lcd)
151131
TEST_ASSERT_TRUE_MESSAGE(lcd->colorBarTest(TEST_LCD_WIDTH, TEST_LCD_HEIGHT), "LCD color bar test failed");
152132
}
153133

134+
#define CREATE_LCD(name, panel_bus) \
135+
({ \
136+
ESP_LOGI(TAG, "Create LCD device: " #name); \
137+
shared_ptr<ESP_PanelLcd> lcd = make_shared<ESP_PanelLcd_##name>(panel_bus, TEST_LCD_COLOR_BITS, TEST_LCD_PIN_NUM_RST); \
138+
TEST_ASSERT_NOT_NULL_MESSAGE(lcd, "Create LCD object failed"); \
139+
lcd; \
140+
})
141+
#define CREATE_TEST_CASE(name) \
142+
TEST_CASE("Test LCD (" #name ") to draw color bar", "[spi_lcd][" #name "]") \
143+
{ \
144+
shared_ptr<ESP_PanelBacklight> backlight = init_backlight(); \
145+
shared_ptr<ESP_PanelBus_SPI> panel_bus = init_panel_bus(); \
146+
shared_ptr<ESP_PanelLcd> lcd = CREATE_LCD(name, panel_bus.get()); \
147+
run_test(lcd); \
148+
}
149+
154150
/**
155151
* Here to create test cases for different LCDs
156152
*

test_apps/touch/spi/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.5)
4+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5+
project(spi_touch_test)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
idf_component_register(
2+
SRCS "test_app_main.c" "test_spi_touch.cpp"
3+
PRIV_REQUIRES esp_lcd driver
4+
WHOLE_ARCHIVE
5+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## IDF Component Manager Manifest File
2+
dependencies:
3+
test_utils:
4+
path: ${IDF_PATH}/tools/unit-test-app/components/test_utils
5+
test_driver_utils:
6+
path: ${IDF_PATH}/components/driver/test_apps/components/test_driver_utils
7+
ESP32_Display_Panel:
8+
version: "*"
9+
override_path: "../../../../../ESP32_Display_Panel"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: CC0-1.0
5+
*/
6+
#include <inttypes.h>
7+
#include "freertos/FreeRTOS.h"
8+
#include "freertos/task.h"
9+
#include "esp_heap_caps.h"
10+
#include "unity.h"
11+
#include "unity_test_runner.h"
12+
13+
// Some resources are lazy allocated in the LCD driver, the threadhold is left for that case
14+
#define TEST_MEMORY_LEAK_THRESHOLD (-300)
15+
16+
static size_t before_free_8bit;
17+
static size_t before_free_32bit;
18+
19+
static void check_leak(size_t before_free, size_t after_free, const char *type)
20+
{
21+
ssize_t delta = after_free - before_free;
22+
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
23+
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
24+
}
25+
26+
void setUp(void)
27+
{
28+
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
29+
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
30+
}
31+
32+
void tearDown(void)
33+
{
34+
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
35+
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
36+
check_leak(before_free_8bit, after_free_8bit, "8BIT");
37+
check_leak(before_free_32bit, after_free_32bit, "32BIT");
38+
}
39+
40+
void app_main(void)
41+
{
42+
/**
43+
* ______ _______ ______ __ ______ _______
44+
* / \ | \| \ | \ / \ | \
45+
* | $$$$$$\| $$$$$$$\\$$$$$$ | $$ | $$$$$$\| $$$$$$$\
46+
* | $$___\$$| $$__/ $$ | $$ | $$ | $$ \$$| $$ | $$
47+
* \$$ \ | $$ $$ | $$ | $$ | $$ | $$ | $$
48+
* _\$$$$$$\| $$$$$$$ | $$ | $$ | $$ __ | $$ | $$
49+
* | \__| $$| $$ _| $$_ | $$_____| $$__/ \| $$__/ $$
50+
* \$$ $$| $$ | $$ \ | $$ \\$$ $$| $$ $$
51+
* \$$$$$$ \$$ \$$$$$$ \$$$$$$$$ \$$$$$$ \$$$$$$$
52+
*/
53+
printf(" ______ _______ ______ __ ______ _______\r\n");
54+
printf(" / \\ | \\| \\ | \\ / \\ | \\\r\n");
55+
printf("| $$$$$$\\| $$$$$$$\\\\$$$$$$ | $$ | $$$$$$\\| $$$$$$$\\\r\n");
56+
printf("| $$___\\$$| $$__/ $$ | $$ | $$ | $$ \\$$| $$ | $$\r\n");
57+
printf(" \\$$ \\ | $$ $$ | $$ | $$ | $$ | $$ | $$\r\n");
58+
printf(" _\\$$$$$$\\| $$$$$$$ | $$ | $$ | $$ __ | $$ | $$\r\n");
59+
printf("| \\__| $$| $$ _| $$_ | $$_____| $$__/ \\| $$__/ $$\r\n");
60+
printf(" \\$$ $$| $$ | $$ \\ | $$ \\\\$$ $$| $$ $$\r\n");
61+
printf(" \\$$$$$$ \\$$ \\$$$$$$ \\$$$$$$$$ \\$$$$$$ \\$$$$$$$\r\n");
62+
unity_run_menu();
63+
}

0 commit comments

Comments
 (0)