|
UEFIStarter
a simple UEFI framework
|
Tests for graphics functions. More...
#include <Uefi.h>#include <Library/UefiLib.h>#include <Library/BaseMemoryLib.h>#include <math.h>#include <UEFIStarter/core.h>#include <UEFIStarter/graphics.h>#include <UEFIStarter/tests/tests.h>Data Structures | |
| struct | parse_image_data_testcase_t |
| data type for netpbm image parser tests More... | |
| union | contents_buffer_t |
| helper data type for easier access to file_contents_t's memory content More... | |
| struct | rotation_testcase_t |
| data type for image rotation testcases More... | |
Macros | |
| #define | RUN_PARSE_IMAGE_TESTS(TYPE) |
| shortcut macro to quickly run a netpbm test case More... | |
| #define | B {0,0,0,0} |
| helper macro to quickly create black pixel data | |
| #define | W {255,255,255,0} |
| helper macro to quickly create white pixel data | |
Functions | |
| static file_contents_t * | assemble_file_contents (unsigned int size, char *data) |
| internal: assembles a file_contents_t structure manually More... | |
| void | do_parse_image_test (parse_image_data_testcase_t *testcase, image_t *(*parser)(file_contents_t *)) |
| Runs an individual netpbm test case. More... | |
| void | test_parse_ppm_image_data () |
| Makes sure parse_ppm_image_data() works. More... | |
| void | test_parse_pgm_image_data () |
| Makes sure parse_pgm_image_data() works. More... | |
| void | test_parse_pbm_image_data () |
| Makes sure parse_pbm_image_data() works. More... | |
| static void | _do_rotation_checks (image_t *image, INTN r, INTN dx, INTN dy, CHAR16 *msg_prefix) |
| internal: checks a rotated image at 9 specific pixels to see if it was rotated correctly. More... | |
| void | test_rotate_image () |
| Makes sure rotate_image() works. More... | |
| void | test_interpolate_4px () |
| Makes sure interpolate_4px works. More... | |
| void | test_interpolate_2px () |
| Makes sure interpolate_2px() works. More... | |
| static glyph_list_t * | _get_parse_glyphs_font () |
| internal: creates a glyph list for use in tests. More... | |
| void | test_parse_glyphs () |
| Makes sure parse_glyphs() works. More... | |
| void | test_draw_text () |
| Makes sure draw_text() works. More... | |
| BOOLEAN | run_graphics_tests () |
| Test runner for this group. More... | |
Variables | |
| static contents_buffer_t | _file_contents_buffer |
| internal image data buffer for netpbm parser tests | |
| char | ppm_data [] ={0x50,0x36,0x0a,0x23,0x20,0x78,0x0a,0x32,0x20,0x33,0x0a,0x32,0x35,0x35,0x0a,0xed,0x1c,0x24,0xff,0xf2,0x00,0x00,0xa2,0xe8,0xb5,0xe6,0x1d,0x00,0x00,0x00,0xff,0xff,0xff} |
| the PPM image data to parse for tests | |
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL | expected_ppm_pixels [] |
| the PPM image's expected pixels More... | |
| parse_image_data_testcase_t | ppm_testcases [] |
| the test case for the PPM parser test More... | |
| char | pgm_data [] ={0x50,0x35,0x0a,0x23,0x0a,0x32,0x20,0x32,0x0a,0x32,0x35,0x35,0x0a,0x00,0x7f,0xff,0xc3} |
| the PGM image data to parse for tests | |
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL | expected_pgm_pixels [] |
| the PGM image's expected pixels More... | |
| parse_image_data_testcase_t | pgm_testcases [] |
| the test case for the PGM parser test More... | |
| char | pbm_data [] ={0x50,0x34,0x0a,0x23,0x23,0x0a,0x31,0x37,0x20,0x32,0x0a,0xf2,0x1b,0xff,0x90,0xde,0x7f} |
| the PBM image data to parse for tests | |
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL | expected_pbm_pixels [] ={B,B,B,B,W,W,B,W,W,W,W,B,B,W,B,B,B,B,W,W,B,W,W,W,W,B,B,W,B,B,B,B,W,W} |
| the PBM image's expected pixels | |
| parse_image_data_testcase_t | pbm_testcases [] |
| the test case for the PBM parse test More... | |
| rotation_testcase_t | rotation_testcases [] |
| test cases for test_rotate_image() More... | |
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL | rotation_color_yarp ={200,150,30,0} |
| "on" color for rotation tests | |
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL | rotation_color_narp ={80,240,110,0} |
| "off" color for rotation tests | |
| static EFI_GRAPHICS_OUTPUT_BLT_PIXEL | _interpolation_data [] ={{0,0,0,0},{0,0,255,0},{123,5,0,0},{0,255,0,0},{255,0,0,0},{50,200,164,0}} |
| test data for pixel interpolation | |
Tests for graphics functions.
| #define RUN_PARSE_IMAGE_TESTS | ( | TYPE | ) |
shortcut macro to quickly run a netpbm test case
| TYPE | the image format to test ("ppm", "pgm" or "pbm") |
|
static |
internal: assembles a file_contents_t structure manually
| size | the content length, in bytes |
| data | the content data |
| void do_parse_image_test | ( | parse_image_data_testcase_t * | testcase, |
| image_t *(*)(file_contents_t *) | parser | ||
| ) |
Runs an individual netpbm test case.
| testcase | the test case to run |
| parser | the parser function to test |
| void test_parse_ppm_image_data | ( | ) |
Makes sure parse_ppm_image_data() works.
| void test_parse_pgm_image_data | ( | ) |
Makes sure parse_pgm_image_data() works.
| void test_parse_pbm_image_data | ( | ) |
Makes sure parse_pbm_image_data() works.
|
static |
internal: checks a rotated image at 9 specific pixels to see if it was rotated correctly.
Here's an example image being rotated. The original image is on the left, the result after rotating by 90° clockwise on the right:
........... ........... . . . . . . . . . *****. ==> . * . . . . * . ........... .....*..... original 90° CW
The rotated images are tested at 9 points. These points are in a 3x3 grid, with the center pixel in the middle of the image. The center point is the center of a new coordinate system, with x going right and y going down. Test points are marked with °:
...........
. .
. ° ° ° .
. ° ° ° . --> x
. ° ° ° .
...........
|
V
y
Thus, the top left point is at coordinates (-1,-1), the center left point at (-1,0) and so on.
Because of the contents of the original and rotated image the tests work by asserting that:
The coordinates to expect a foreground color pixel at are passed in parameters "dx" and "dy".
The scale of the 3x3 grid can be adjusted with the "r" parameter.
| image | the rotated image to check |
| r | the distance scale to use for checks, in pixels |
| dx | the horizontal direction to expect change in |
| dy | the vertical direction to expect change in |
| msg_prefix | a description of what's being tested, to include in error messages |
| void test_rotate_image | ( | ) |
Makes sure rotate_image() works.
The _do_rotation_checks() function documentation illustrates how this is asserted.
| void test_interpolate_4px | ( | ) |
Makes sure interpolate_4px works.
interpolate_4px() handles all 4 corners correctly
interpolate_4px() handles all 5 mid points correctly
interpolate_4px() handles arbitrary points correctly
| void test_interpolate_2px | ( | ) |
Makes sure interpolate_2px() works.
interpolate_2px() uses second pixel for ratio 1.0
interpolate_2px() handles arbitrary points correctly
|
static |
internal: creates a glyph list for use in tests.
| void test_parse_glyphs | ( | ) |
Makes sure parse_glyphs() works.
parse_glyphs() initializes the glyph list correctly
parse_glyphs() splits an input text of 4 characters into 4 glyphs
parse_glyphs() reads glyphs correctly when given a multiline input string
| void test_draw_text | ( | ) |
Makes sure draw_text() works.
draw_text() writes text at the correct position
draw_text() blends semi-transparent glyphs onto background
| BOOLEAN run_graphics_tests | ( | ) |
Test runner for this group.
Gets called via the generated test runner.
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL expected_ppm_pixels[] |
the PPM image's expected pixels
| parse_image_data_testcase_t ppm_testcases[] |
the test case for the PPM parser test
| EFI_GRAPHICS_OUTPUT_BLT_PIXEL expected_pgm_pixels[] |
the PGM image's expected pixels
| parse_image_data_testcase_t pgm_testcases[] |
the test case for the PGM parser test
| parse_image_data_testcase_t pbm_testcases[] |
the test case for the PBM parse test
| rotation_testcase_t rotation_testcases[] |
test cases for test_rotate_image()
1.8.13