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

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