aboutsummaryrefslogtreecommitdiff
path: root/tests/unity/unity_support.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unity/unity_support.c')
-rw-r--r--tests/unity/unity_support.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/unity/unity_support.c b/tests/unity/unity_support.c
index c495b93e3..6906bd22b 100644
--- a/tests/unity/unity_support.c
+++ b/tests/unity/unity_support.c
@@ -73,7 +73,7 @@ bool lv_test_assert_img_eq(const char * fn_ref)
lv_obj_invalidate(lv_scr_act());
lv_refr_now(NULL);
-
+
extern lv_color_t test_fb[];
screen_buf = (uint8_t *)test_fb;
@@ -85,17 +85,17 @@ bool lv_test_assert_img_eq(const char * fn_ref)
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]);
-
+
uint32_t ref_px = 0;
uint32_t act_px = 0;
memcpy(&ref_px, ptr_ref, 3);
memcpy(&act_px, ptr_act, 3);
//printf("0xFF%06x, ", act_px);
-
+
uint8_t act_swap[3] = {ptr_act[2], ptr_act[1], ptr_act[0]};
if(memcmp(act_swap, ptr_ref, 3) != 0) {
@@ -112,12 +112,12 @@ bool lv_test_assert_img_eq(const char * fn_ref)
uint32_t act_px = 0;
memcpy(&ref_px, ptr_ref, 3);
memcpy(&act_px, ptr_act, 3);
-
+
FILE * f = fopen("../test_screenshot_error.h", "w");
-
+
fprintf(f, "//Diff in %s at (%d;%d), %x instead of %x)\n\n", fn_ref, x, y, act_px, ref_px);
fprintf(f, "static const uint32_t test_screenshot_error_data[] = {\n");
-
+
i_buf = 0;
for (y = 0; y < 480; y++) {
fprintf(f, "\n");
@@ -130,7 +130,7 @@ bool lv_test_assert_img_eq(const char * fn_ref)
}
}
fprintf(f, "};\n\n");
-
+
fprintf(f, "static lv_img_dsc_t test_screenshot_error_dsc = { \n"
" .header.w = 800,\n"
" .header.h = 480,\n"
@@ -143,16 +143,16 @@ bool lv_test_assert_img_eq(const char * fn_ref)
" lv_obj_t * img = lv_img_create(lv_scr_act());\n"
" lv_img_set_src(img, &test_screenshot_error_dsc);\n"
"}\n");
-
+
fclose(f);
-
+
}
-
+
png_release(&p);
return !err;
-
+
}
/**********************
@@ -169,13 +169,13 @@ static int read_png_file(png_img_t * p, const char* file_name)
TEST_PRINTF("%s", "PNG file %s could not be opened for reading");
return -1;
}
-
+
size_t rcnt = fread(header, 1, 8, fp);
if (rcnt != 8 || png_sig_cmp((png_const_bytep)header, 0, 8)) {
TEST_PRINTF("%s is not recognized as a PNG file", file_name);
return -1;
}
-
+
/*initialize stuff*/
p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -183,7 +183,7 @@ static int read_png_file(png_img_t * p, const char* file_name)
TEST_PRINTF("%s", "png_create_read_struct failed");
return -1;
}
-
+
p->info_ptr = png_create_info_struct(p->png_ptr);
if (!p->info_ptr) {
TEST_PRINTF("%s", "png_create_info_struct failed");
@@ -227,7 +227,7 @@ 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);
png_destroy_read_struct(&p->png_ptr, &p->info_ptr, NULL);