From 4e05c7735d08d9aed4f09440f251d446deb0c3e4 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 19 Jan 2015 00:16:58 -0500 Subject: [PATCH] add color format visual verification test --- CMakeLists.txt | 3 +++ test/test_color_format.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/test_color_format.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ecbd659..99871c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,3 +24,6 @@ target_link_libraries("test_primitives" ${SDL2_LIBRARY}) add_executable("test_surfaces" "${TESTS_DIR}/test_surfaces.c" ${LIB_SRC_FILES}) target_link_libraries("test_surfaces" ${SDL2_LIBRARY}) + +add_executable("test_color_format" "${TESTS_DIR}/test_color_format.c" ${LIB_SRC_FILES}) +target_link_libraries("test_color_format" ${SDL2_LIBRARY}) diff --git a/test/test_color_format.c b/test/test_color_format.c new file mode 100644 index 0000000..7255df2 --- /dev/null +++ b/test/test_color_format.c @@ -0,0 +1,39 @@ +#include +#include "vm/vm.h" +#include + +int main(int argc, char **argv) { + log_init(); + input_init(); + WINDOW *window = window_init("test_color_format", 1024, 768, 320, 240); + if (!window) + return 1; + + int step = 0; + + while (step < 4) { + if (!window_do_events(window)) + break; + if (input_is_key_down(KSYM_ESCAPE)) + break; + if (input_is_key_pressed(KSYM_SPACE)) + ++step; + + // obviously requiring visual confirmation that the color being rendered is + // the one specified in the code ... + switch (step) { + case 0: surface_clear(window->surface, color_create_rgb(0, 0, 0)); break; + case 1: surface_clear(window->surface, color_create_rgb(255, 0, 0)); break; + case 2: surface_clear(window->surface, color_create_rgb(0, 255, 0)); break; + case 3: surface_clear(window->surface, color_create_rgb(0, 0, 255)); break; + } + + window_render(window); + } + + window_destroy(window); + input_destroy(); + log_end(); + + return 0; +}