| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gate/tests.h" | ||
| 2 | #include "test_images.h" | ||
| 3 | #include "gate/graphics/colors.h" | ||
| 4 | #include "gate/graphics/bitmapimages.h" | ||
| 5 | #include "gate/graphics/jpegimages.h" | ||
| 6 | #include "gate/graphics/pngimages.h" | ||
| 7 | #include "gate/graphics/gifimages.h" | ||
| 8 | #include "gate/graphics/pixmapimages.h" | ||
| 9 | #include "gate/graphics/drawing.h" | ||
| 10 | #include "gate/streams.h" | ||
| 11 | |||
| 12 | 1 | GATE_TEST_FUNCTION(test_colors) | |
| 13 | { | ||
| 14 | gate_color_t col; | ||
| 15 | |||
| 16 | 1 | GATE_TEST_UNIT_BEGIN(test_colors); | |
| 17 | |||
| 18 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(6, gate_color_parse_hex("336699", 6, &col)); |
| 19 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(col.r, 0x33); |
| 20 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(col.g, 0x66); |
| 21 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(col.b, 0x99); |
| 22 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | GATE_TEST_CHECK_EQUAL(col.a, 0xff); |
| 23 | |||
| 24 | 1 | GATE_TEST_UNIT_END; | |
| 25 | } | ||
| 26 | |||
| 27 | 5 | static gate_result_t create_raster_image(gate_rasterimage_t* image) | |
| 28 | { | ||
| 29 | gate_result_t ret; | ||
| 30 | 5 | gate_color_t bg_col = GATE_COLOR_BLUE; | |
| 31 | 5 | gate_color_t fg_col = GATE_COLOR_YELLOW; | |
| 32 | |||
| 33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
|
5 | if (NULL == gate_rasterimage_create(image, |
| 34 | GATE_IMAGE_PIXELFORMAT_RGB24, | ||
| 35 | 64, 32, NULL)) | ||
| 36 | { | ||
| 37 | ✗ | return GATE_RESULT_OUTOFMEMORY; | |
| 38 | } | ||
| 39 | 5 | ret = gate_rasterimage_clear(image, &bg_col); | |
| 40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | if (GATE_FAILED(ret)) |
| 41 | { | ||
| 42 | ✗ | gate_rasterimage_release(image); | |
| 43 | ✗ | return ret; | |
| 44 | } | ||
| 45 | 5 | gate_draw_line(image, 0, 0, 64, 32, fg_col); | |
| 46 | 5 | gate_draw_line(image, 0, 32, 64, 0, fg_col); | |
| 47 | 5 | return ret; | |
| 48 | } | ||
| 49 | |||
| 50 | 5 | static gate_bool_t test_save_load_rasterimage(gate_image_reader_t reader, gate_image_writer_t writer) | |
| 51 | { | ||
| 52 | 5 | gate_rasterimage_t image = GATE_INIT_EMPTY; | |
| 53 | 5 | gate_rasterimage_t image2 = GATE_INIT_EMPTY; | |
| 54 | 5 | gate_stream_t* ptr_stream = NULL; | |
| 55 | |||
| 56 |
1/2✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
|
5 | GATE_TEST_REQUIRE_OK(create_raster_image(&image)); |
| 57 | |||
| 58 | 5 | ptr_stream = (gate_stream_t*)gate_memstream_create(0); | |
| 59 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | GATE_TEST_CHECK(ptr_stream); |
| 60 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (ptr_stream) |
| 61 | { | ||
| 62 |
1/2✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
|
5 | GATE_TEST_CHECK_OK(writer(&image, ptr_stream, 0)); |
| 63 | |||
| 64 |
1/2✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
|
5 | GATE_TEST_CHECK_OK(reader(ptr_stream, &image2, 0)); |
| 65 | |||
| 66 | 5 | gate_object_release(ptr_stream); | |
| 67 | } | ||
| 68 | |||
| 69 | 5 | gate_rasterimage_release(&image2); | |
| 70 | 5 | gate_rasterimage_release(&image); | |
| 71 | |||
| 72 | 5 | return true; | |
| 73 | } | ||
| 74 | |||
| 75 | 1 | GATE_TEST_FUNCTION(test_bitmap) | |
| 76 | { | ||
| 77 | 1 | GATE_TEST_UNIT_BEGIN(test_bitmap); | |
| 78 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_save_load_rasterimage(&gate_bitmapimage_load, &gate_bitmapimage_save)); |
| 79 | 1 | GATE_TEST_UNIT_END; | |
| 80 | } | ||
| 81 | |||
| 82 | 1 | GATE_TEST_FUNCTION(test_jpeg) | |
| 83 | { | ||
| 84 | 1 | GATE_TEST_UNIT_BEGIN(test_jpeg); | |
| 85 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_save_load_rasterimage(&gate_jpegimage_load, &gate_jpegimage_save)); |
| 86 | 1 | GATE_TEST_UNIT_END; | |
| 87 | } | ||
| 88 | |||
| 89 | 1 | GATE_TEST_FUNCTION(test_png) | |
| 90 | { | ||
| 91 | 1 | GATE_TEST_UNIT_BEGIN(test_png); | |
| 92 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_save_load_rasterimage(&gate_pngimage_load, &gate_pngimage_save)); |
| 93 | 1 | GATE_TEST_UNIT_END; | |
| 94 | } | ||
| 95 | |||
| 96 | 1 | GATE_TEST_FUNCTION(test_gif) | |
| 97 | { | ||
| 98 | 1 | GATE_TEST_UNIT_BEGIN(test_gif); | |
| 99 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_save_load_rasterimage(&gate_gifimage_load, &gate_gifimage_save)); |
| 100 | 1 | GATE_TEST_UNIT_END; | |
| 101 | } | ||
| 102 | |||
| 103 | 1 | GATE_TEST_FUNCTION(test_pixmap) | |
| 104 | { | ||
| 105 | 1 | GATE_TEST_UNIT_BEGIN(test_pixmap); | |
| 106 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | GATE_TEST_CHECK(test_save_load_rasterimage(&gate_pixmapimage_load, &gate_pixmapimage_save)); |
| 107 | 1 | GATE_TEST_UNIT_END; | |
| 108 | } | ||
| 109 |