Warning, /frameworks/kimageformats/autotests/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 include(ECMMarkAsTest)
0002 
0003 add_definitions(-DPLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}/../bin")
0004 remove_definitions(-DQT_NO_CAST_FROM_ASCII)
0005 
0006 macro(kimageformats_read_tests)
0007     cmake_parse_arguments(KIF_RT "" "FUZZ" "" ${ARGN})
0008     set(_fuzzarg)
0009     if (KIF_RT_FUZZ)
0010         set(_fuzzarg -f ${KIF_RT_FUZZ})
0011     endif()
0012 
0013     if (NOT TARGET readtest)
0014         add_executable(readtest readtest.cpp)
0015         target_link_libraries(readtest Qt6::Gui)
0016         target_compile_definitions(readtest
0017             PRIVATE IMAGEDIR="${CMAKE_CURRENT_SOURCE_DIR}/read")
0018         ecm_mark_as_test(readtest)
0019     endif()
0020 
0021     foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS})
0022         add_test(
0023             NAME kimageformats-read-${_testname}
0024             COMMAND readtest ${_fuzzarg} ${_testname}
0025         )
0026     endforeach(_testname)
0027 endmacro()
0028 
0029 macro(kimageformats_write_tests)
0030     cmake_parse_arguments(KIF_RT "" "FUZZ" "" ${ARGN})
0031     set(_fuzzarg)
0032     if (KIF_RT_FUZZ)
0033         set(_fuzzarg -f ${KIF_RT_FUZZ})
0034     endif()
0035 
0036     if (NOT TARGET writetest)
0037         add_executable(writetest writetest.cpp)
0038         target_link_libraries(writetest Qt6::Gui)
0039         target_compile_definitions(writetest
0040             PRIVATE IMAGEDIR="${CMAKE_CURRENT_SOURCE_DIR}/write")
0041         ecm_mark_as_test(writetest)
0042     endif()
0043     foreach(_testname ${KIF_RT_UNPARSED_ARGUMENTS})
0044         string(REGEX MATCH "-lossless$" _is_lossless "${_testname}")
0045         string(REGEX MATCH "-nodatacheck" _is_no_data_check "${_testname}")
0046         unset(lossless_arg)
0047         unset(no_data_check_arg)
0048         if (_is_lossless)
0049             set(lossless_arg "--lossless")
0050             string(REGEX REPLACE "-lossless$" "" _testname "${_testname}")
0051         endif()
0052         if (_is_no_data_check)
0053             set(no_data_check_arg "--no-data-check")
0054             string(REGEX REPLACE "-nodatacheck$" "" _testname "${_testname}")
0055         endif()
0056         add_test(
0057             NAME kimageformats-write-${_testname}
0058             COMMAND writetest ${lossless_arg} ${no_data_check_arg} ${_fuzzarg} ${_testname}
0059         )
0060     endforeach(_testname)
0061 endmacro()
0062 
0063 # Basic read tests
0064 # Loads each <format> image in read/<format>/, and compares the
0065 # result against the data read from the corresponding png file
0066 kimageformats_read_tests(
0067     hdr
0068     pcx
0069     psd
0070     qoi
0071     ras
0072     rgb
0073     tga
0074 )
0075 
0076 if (KF6Archive_FOUND)
0077     kimageformats_read_tests(
0078         kra
0079         ora
0080     )
0081 endif()
0082 
0083 if (TARGET avif)
0084     kimageformats_read_tests(
0085         avif
0086     )
0087     kimageformats_write_tests(
0088         avif-nodatacheck-lossless
0089     )
0090 endif()
0091 
0092 if (LibHeif_FOUND)
0093     kimageformats_read_tests(
0094         heif
0095     )
0096     # because the plug-ins use RGB->YUV conversion which sometimes results in 1 value difference.
0097     kimageformats_write_tests(FUZZ 1
0098         heif-nodatacheck-lossless
0099     )
0100 
0101     if (LibHeif_VERSION VERSION_GREATER_EQUAL "1.17.0")
0102         kimageformats_read_tests(FUZZ 1
0103             hej2
0104         )
0105     endif()
0106 endif()
0107 
0108 if (LibJXL_FOUND AND LibJXLThreads_FOUND)
0109     kimageformats_read_tests(
0110         jxl
0111     )
0112     kimageformats_write_tests(
0113         jxl-nodatacheck-lossless
0114     )
0115 endif()
0116 
0117 # Allow some fuzziness when reading this formats, to allow for
0118 # rounding errors (eg: in alpha blending).
0119 kimageformats_read_tests(FUZZ 1
0120     xcf
0121 )
0122 
0123 # Basic write tests
0124 # Loads each png image in write/, writes the data out
0125 # as a <format> image, and compares the result against the
0126 # the corresponding <format> file.
0127 # You can append -lossless to the format to indicate that
0128 # reading back the image data will result in an identical image.
0129 kimageformats_write_tests(
0130     pcx-lossless
0131     pic-lossless
0132     qoi-lossless
0133     rgb-lossless
0134     tga # fixme: the alpha images appear not to be written properly
0135 )
0136 
0137 # EPS read tests depend on the vagaries of GhostScript
0138 # which we cannot even guarantee to find, so disable them for now
0139 #if (BUILD_EPS_PLUGIN)
0140 #    kimageformats_read_tests(eps)
0141 #    kimageformats_write_tests(eps)
0142 #endif()
0143 if (OpenEXR_FOUND)
0144     kimageformats_read_tests(
0145         exr
0146     )
0147     # Color space conversions from sRGB to linear on saving and
0148     # from linear to sRGB on loading result in some rounding errors.
0149     kimageformats_write_tests(FUZZ 5
0150         exr-nodatacheck-lossless
0151     )
0152 endif()
0153 
0154 if (LibRaw_FOUND)
0155     kimageformats_read_tests(
0156         raw
0157     )
0158 endif()
0159 
0160 find_package(Qt6Test ${REQUIRED_QT_VERSION} CONFIG QUIET)
0161 
0162 if(NOT TARGET Qt6::Test)
0163     message(STATUS "Qt6Test not found, some autotests will not be built.")
0164     return()
0165 endif()
0166 
0167 add_executable(pictest pictest.cpp)
0168 target_link_libraries(pictest Qt6::Gui Qt6::Test)
0169 ecm_mark_as_test(pictest)
0170 add_test(NAME kimageformats-pic COMMAND pictest)
0171 
0172 add_executable(anitest anitest.cpp)
0173 target_link_libraries(anitest Qt6::Gui Qt6::Test)
0174 ecm_mark_as_test(anitest)
0175 add_test(NAME kimageformats-ani COMMAND anitest)