From f39be2686446c41a5fbf93eba7fb40ca99efcc3a Mon Sep 17 00:00:00 2001 From: Mihael Koep Date: Tue, 9 Sep 2014 13:57:32 +0200 Subject: Add software roi feature to dexela plugin --- test/CMakeLists.txt | 4 ++++ test/test-software-roi.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 test/test-software-roi.c (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e8cfad..afe79ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,14 @@ cmake_minimum_required(VERSION 2.6) +include_directories(${ucadexela_SOURCE_DIR}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gtester.xsl ${CMAKE_CURRENT_BINARY_DIR}/gtester.xsl) add_executable(test-mock test-mock.c) add_executable(test-ring-buffer test-ring-buffer.c) +add_executable(test-software-roi test-software-roi.c ${ucadexela_SOURCE_DIR}/software-roi.c) target_link_libraries(test-mock uca ${UCA_DEPS}) target_link_libraries(test-ring-buffer uca ${UCA_DEPS}) +target_link_libraries(test-software-roi ${UCA_DEPS}) diff --git a/test/test-software-roi.c b/test/test-software-roi.c new file mode 100644 index 0000000..2b628c5 --- /dev/null +++ b/test/test-software-roi.c @@ -0,0 +1,53 @@ +#include +#include "software-roi.h" + +static const guchar test_frame[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, + 0, 1, 2, 3, 4, 5, 6, 7, 8, + 0, 1, 2, 3, 4, 5, 6, 7, 8, + 0, 1, 2, 3, 4, 5, 6, 7, 8, + 0, 1, 2, 3, 4, 5, 6, 7, 8, +}; +static const guint test_frame_width = 9; + +static guchar test_roi_2x1_5x3[] = { + 2, 3, 4, 5, 6, + 2, 3, 4, 5, 6, + 2, 3, 4, 5, 6, +}; + +void typical_roi_test(void) +{ + guint roiX = 2; + guint roiY = 1; + guint roiWidth = 5; + guint roiHeight = 3; + guint roiSize = roiWidth * roiHeight; + guchar roiFrame[roiSize]; + apply_software_roi(test_frame, test_frame_width, roiFrame, roiX, roiY, roiWidth, roiHeight); + for (guint i = 0; i < roiSize; i++) { + g_assert_cmpint(test_roi_2x1_5x3[i], ==, roiFrame[i]); + } +} + +void nrows_only_roi_test(void) +{ + guint roiX = 0; + guint roiY = 0; + guint roiWidth = test_frame_width; + guint roiHeight = 3; + guint roiSize = roiWidth * roiHeight; + guchar roiFrame[roiSize]; + apply_software_roi(test_frame, test_frame_width, roiFrame, roiX, roiY, roiWidth, roiHeight); + for (guint i = 0; i < roiSize; i++) { + g_assert_cmpint(test_frame[i], ==, roiFrame[i]); + } +} + +int main(int argc, char** argv) +{ + g_test_init(&argc, &argv, NULL); + g_test_add_func("/software-roi/apply-typical-roi", typical_roi_test); + g_test_add_func("/software-roi/apply-roi-nrows-only", nrows_only_roi_test); + return g_test_run(); +} -- cgit v1.2.3