Skip to content

Commit f651d32

Browse files
author
Gauthier Provost
committed
quick fix to make lv_test_screenshot read only
1 parent c016f72 commit f651d32

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/others/test/lv_test_screenshot_compare.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#endif
4444

4545
#ifndef REF_IMG_TOLERANCE
46-
#define REF_IMG_TOLERANCE 0
46+
#define REF_IMG_TOLERANCE 5
4747
#endif
4848

4949
#define ERR_FILE_NOT_FOUND -1
@@ -103,7 +103,7 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
103103
char fn_ref_full[256];
104104
lv_snprintf(fn_ref_full, sizeof(fn_ref_full), "%s%s", REF_IMGS_PATH, fn_ref);
105105

106-
create_folders_if_needed(fn_ref_full);
106+
//create_folders_if_needed(fn_ref_full);
107107

108108
lv_draw_buf_t * draw_buf = lv_display_get_buf_active(NULL);
109109

@@ -115,10 +115,10 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
115115
unsigned ref_img_height = 0;
116116
unsigned res = read_png_file(&ref_draw_buf, &ref_img_width, &ref_img_height, fn_ref_full);
117117
if(res) {
118-
LV_LOG_WARN("%s%s", fn_ref_full, " was not found, creating it now from the rendered screen");
119-
write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full);
120-
lv_free(screen_buf_xrgb8888);
121-
return true;
118+
LV_LOG_WARN("%s%s", fn_ref_full, " was not found");
119+
//write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full);
120+
//lv_free(screen_buf_xrgb8888);
121+
return false;
122122
}
123123

124124
if(ref_img_width != draw_buf->header.w || ref_img_height != draw_buf->header.h) {
@@ -136,6 +136,11 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
136136
uint8_t * ptr_ref = &(ref_row[x * 4]);
137137
uint8_t * ptr_act = &screen_buf_tmp[x * 4];
138138

139+
// skip transparent pixels
140+
if (ptr_ref[3] == 0) {
141+
continue;
142+
}
143+
139144
if(LV_ABS((int32_t) ptr_act[0] - (int32_t) ptr_ref[0]) > tolerance ||
140145
LV_ABS((int32_t) ptr_act[1] - (int32_t) ptr_ref[1]) > tolerance ||
141146
LV_ABS((int32_t) ptr_act[2] - (int32_t) ptr_ref[2]) > tolerance) {
@@ -164,7 +169,7 @@ static bool screenshot_compare(const char * fn_ref, uint8_t tolerance)
164169
char fn_err_full[256];
165170
lv_snprintf(fn_err_full, sizeof(fn_err_full), "%s%s_err.png", REF_IMGS_PATH, fn_ref_no_ext);
166171

167-
write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_err_full);
172+
//write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_err_full);
168173
}
169174

170175
fflush(stdout);

src/others/xml/lv_xml_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static lv_xml_test_t test;
8585
static lv_display_t * test_display;
8686
static lv_obj_t * cursor;
8787
static lv_tick_get_cb_t tick_cb_original;
88+
static bool test_initialized = false;
8889

8990
/**********************
9091
* MACROS
@@ -235,6 +236,7 @@ void lv_xml_test_run_init(void)
235236
}
236237
lv_refr_now(normal_display);
237238
test.step_act = 0;
239+
test_initialized = true;
238240
}
239241

240242
bool lv_xml_test_run_next(uint32_t slowdown)
@@ -251,10 +253,14 @@ bool lv_xml_test_run_next(uint32_t slowdown)
251253

252254
void lv_xml_test_run_stop(void)
253255
{
256+
if(!test_initialized) {
257+
return;
258+
}
254259
lv_obj_delete(cursor);
255260
lv_tick_set_cb(tick_cb_original);
256261
lv_display_delete(test_display);
257262
lv_test_indev_delete_all();
263+
test_initialized = false;
258264
}
259265

260266

0 commit comments

Comments
 (0)