diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:24:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:24:41 +0000 |
commit | a9bcc81f821d7c66f623779fa5147e728eb3c388 (patch) | |
tree | 98676963bcdd537ae5908a067a8eb110b93486a6 /rdtk/librdtk/test | |
parent | Initial commit. (diff) | |
download | freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip |
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | rdtk/librdtk/test/CMakeLists.txt | 25 | ||||
-rw-r--r-- | rdtk/librdtk/test/TestRdTkNinePatch.c | 62 |
2 files changed, 87 insertions, 0 deletions
diff --git a/rdtk/librdtk/test/CMakeLists.txt b/rdtk/librdtk/test/CMakeLists.txt new file mode 100644 index 0000000..97a04cc --- /dev/null +++ b/rdtk/librdtk/test/CMakeLists.txt @@ -0,0 +1,25 @@ + +set(MODULE_NAME "TestRdTk") +set(MODULE_PREFIX "TEST_RDTK") + +set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) + +set(${MODULE_PREFIX}_TESTS + TestRdTkNinePatch.c) + +create_test_sourcelist(${MODULE_PREFIX}_SRCS + ${${MODULE_PREFIX}_DRIVER} + ${${MODULE_PREFIX}_TESTS}) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + +target_link_libraries(${MODULE_NAME} winpr rdtk) + +set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}") + +foreach(test ${${MODULE_PREFIX}_TESTS}) + get_filename_component(TestName ${test} NAME_WE) + add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName}) +endforeach() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "RdTk/Test") diff --git a/rdtk/librdtk/test/TestRdTkNinePatch.c b/rdtk/librdtk/test/TestRdTkNinePatch.c new file mode 100644 index 0000000..2c7405f --- /dev/null +++ b/rdtk/librdtk/test/TestRdTkNinePatch.c @@ -0,0 +1,62 @@ + +#include <stdio.h> +#include <stdint.h> +#include <rdtk/rdtk.h> +#include <winpr/error.h> + +int TestRdTkNinePatch(int argc, char* argv[]) +{ + rdtkEngine* engine = NULL; + rdtkSurface* surface = NULL; + uint32_t scanline = 0; + uint32_t width = 0; + uint32_t height = 0; + uint8_t* data = NULL; + int ret = -1; + + WINPR_UNUSED(argc); + WINPR_UNUSED(argv); + + if (!(engine = rdtk_engine_new())) + { + printf("%s: error creating rdtk engine (%" PRIu32 ")\n", __func__, GetLastError()); + goto out; + } + + width = 1024; + height = 768; + scanline = width * 4; + + /* let rdtk allocate the surface buffer */ + if (!(surface = rdtk_surface_new(engine, NULL, width, height, scanline))) + { + printf("%s: error creating auto-allocated surface (%" PRIu32 ")\n", __func__, + GetLastError()); + goto out; + } + rdtk_surface_free(surface); + surface = NULL; + + /* test self-allocated buffer */ + if (!(data = calloc(height, scanline))) + { + printf("%s: error allocating surface buffer (%" PRIu32 ")\n", __func__, GetLastError()); + goto out; + } + + if (!(surface = rdtk_surface_new(engine, data, width, height, scanline))) + { + printf("%s: error creating self-allocated surface (%" PRIu32 ")\n", __func__, + GetLastError()); + goto out; + } + + ret = 0; + +out: + rdtk_surface_free(surface); + rdtk_engine_free(engine); + free(data); + + return ret; +} |