add_library(pp_test_harness INTERFACE)
target_include_directories(pp_test_harness INTERFACE
    "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(pp_test_harness INTERFACE
    pp_project_options
    pp_project_warnings)

add_executable(pp_foundation_binary_stream_tests
    foundation/binary_stream_tests.cpp
)
target_link_libraries(pp_foundation_binary_stream_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_binary_stream_tests COMMAND pp_foundation_binary_stream_tests)
set_tests_properties(pp_foundation_binary_stream_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_foundation_event_tests
    foundation/event_tests.cpp)
target_link_libraries(pp_foundation_event_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_event_tests COMMAND pp_foundation_event_tests)
set_tests_properties(pp_foundation_event_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_foundation_log_tests
    foundation/log_tests.cpp)
target_link_libraries(pp_foundation_log_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_log_tests COMMAND pp_foundation_log_tests)
set_tests_properties(pp_foundation_log_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_foundation_parse_tests
    foundation/parse_tests.cpp)
target_link_libraries(pp_foundation_parse_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_parse_tests COMMAND pp_foundation_parse_tests)
set_tests_properties(pp_foundation_parse_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_foundation_task_queue_tests
    foundation/task_queue_tests.cpp)
target_link_libraries(pp_foundation_task_queue_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_task_queue_tests COMMAND pp_foundation_task_queue_tests)
set_tests_properties(pp_foundation_task_queue_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_foundation_trace_tests
    foundation/trace_tests.cpp)
target_link_libraries(pp_foundation_trace_tests PRIVATE
    pp_foundation
    pp_test_harness)

add_test(NAME pp_foundation_trace_tests COMMAND pp_foundation_trace_tests)
set_tests_properties(pp_foundation_trace_tests PROPERTIES
    LABELS "foundation;desktop-fast")

add_executable(pp_assets_image_format_tests
    assets/image_format_tests.cpp)
target_link_libraries(pp_assets_image_format_tests PRIVATE
    pp_assets
    pp_test_harness)

add_test(NAME pp_assets_image_format_tests COMMAND pp_assets_image_format_tests)
set_tests_properties(pp_assets_image_format_tests PROPERTIES
    LABELS "assets;desktop-fast")

add_executable(pp_assets_image_metadata_tests
    assets/image_metadata_tests.cpp)
target_link_libraries(pp_assets_image_metadata_tests PRIVATE
    pp_assets
    pp_test_harness)

add_test(NAME pp_assets_image_metadata_tests COMMAND pp_assets_image_metadata_tests)
set_tests_properties(pp_assets_image_metadata_tests PROPERTIES
    LABELS "assets;desktop-fast")

add_executable(pp_assets_ppi_header_tests
    assets/ppi_header_tests.cpp)
target_link_libraries(pp_assets_ppi_header_tests PRIVATE
    pp_assets
    pp_test_harness)

add_test(NAME pp_assets_ppi_header_tests COMMAND pp_assets_ppi_header_tests)
set_tests_properties(pp_assets_ppi_header_tests PROPERTIES
    LABELS "assets;desktop-fast")

add_executable(pp_assets_settings_document_tests
    assets/settings_document_tests.cpp)
target_link_libraries(pp_assets_settings_document_tests PRIVATE
    pp_assets
    pp_test_harness)

add_test(NAME pp_assets_settings_document_tests COMMAND pp_assets_settings_document_tests)
set_tests_properties(pp_assets_settings_document_tests PROPERTIES
    LABELS "assets;desktop-fast")

add_executable(pp_paint_brush_tests
    paint/brush_tests.cpp)
target_link_libraries(pp_paint_brush_tests PRIVATE
    pp_paint
    pp_test_harness)

add_test(NAME pp_paint_brush_tests COMMAND pp_paint_brush_tests)
set_tests_properties(pp_paint_brush_tests PROPERTIES
    LABELS "paint;desktop-fast")

add_executable(pp_paint_blend_tests
    paint/blend_tests.cpp)
target_link_libraries(pp_paint_blend_tests PRIVATE
    pp_paint
    pp_test_harness)

add_test(NAME pp_paint_blend_tests COMMAND pp_paint_blend_tests)
set_tests_properties(pp_paint_blend_tests PROPERTIES
    LABELS "paint;desktop-fast")

add_executable(pp_paint_stroke_tests
    paint/stroke_tests.cpp)
target_link_libraries(pp_paint_stroke_tests PRIVATE
    pp_paint
    pp_test_harness)

add_test(NAME pp_paint_stroke_tests COMMAND pp_paint_stroke_tests)
set_tests_properties(pp_paint_stroke_tests PROPERTIES
    LABELS "paint;desktop-fast")

add_executable(pp_paint_stroke_script_tests
    paint/stroke_script_tests.cpp)
target_link_libraries(pp_paint_stroke_script_tests PRIVATE
    pp_paint
    pp_test_harness)

add_test(NAME pp_paint_stroke_script_tests COMMAND pp_paint_stroke_script_tests)
set_tests_properties(pp_paint_stroke_script_tests PROPERTIES
    LABELS "paint;desktop-fast")

add_executable(pp_document_tests
    document/document_tests.cpp)
target_link_libraries(pp_document_tests PRIVATE
    pp_document
    pp_test_harness)

add_test(NAME pp_document_tests COMMAND pp_document_tests)
set_tests_properties(pp_document_tests PROPERTIES
    LABELS "document;desktop-fast")

add_executable(pp_renderer_api_tests
    renderer_api/renderer_api_tests.cpp)
target_link_libraries(pp_renderer_api_tests PRIVATE
    pp_renderer_api
    pp_test_harness)

add_test(NAME pp_renderer_api_tests COMMAND pp_renderer_api_tests)
set_tests_properties(pp_renderer_api_tests PROPERTIES
    LABELS "renderer;desktop-fast")

add_executable(pp_paint_renderer_compositor_tests
    paint_renderer/compositor_tests.cpp)
target_link_libraries(pp_paint_renderer_compositor_tests PRIVATE
    pp_paint_renderer
    pp_test_harness)

add_test(NAME pp_paint_renderer_compositor_tests COMMAND pp_paint_renderer_compositor_tests)
set_tests_properties(pp_paint_renderer_compositor_tests PROPERTIES
    LABELS "renderer;paint;desktop-fast")

add_executable(pp_ui_core_color_tests
    ui_core/color_tests.cpp)
target_link_libraries(pp_ui_core_color_tests PRIVATE
    pp_ui_core
    pp_test_harness)

add_test(NAME pp_ui_core_color_tests COMMAND pp_ui_core_color_tests)
set_tests_properties(pp_ui_core_color_tests PROPERTIES
    LABELS "ui;desktop-fast")

add_executable(pp_ui_core_layout_value_tests
    ui_core/layout_value_tests.cpp)
target_link_libraries(pp_ui_core_layout_value_tests PRIVATE
    pp_ui_core
    pp_test_harness)

add_test(NAME pp_ui_core_layout_value_tests COMMAND pp_ui_core_layout_value_tests)
set_tests_properties(pp_ui_core_layout_value_tests PROPERTIES
    LABELS "ui;desktop-fast")

add_executable(pp_ui_core_layout_xml_tests
    ui_core/layout_xml_tests.cpp)
target_link_libraries(pp_ui_core_layout_xml_tests PRIVATE
    pp_ui_core
    pp_test_harness)

add_test(NAME pp_ui_core_layout_xml_tests COMMAND pp_ui_core_layout_xml_tests)
set_tests_properties(pp_ui_core_layout_xml_tests PROPERTIES
    LABELS "ui;desktop-fast")

if(TARGET pano_cli)
    add_test(NAME pano_cli_create_document_smoke
        COMMAND pano_cli create-document --width 64 --height 32 --layers 2)
    set_tests_properties(pano_cli_create_document_smoke PROPERTIES
        LABELS "integration;desktop-fast")

    add_test(NAME pano_cli_create_animation_document_smoke
        COMMAND pano_cli create-document --width 64 --height 32 --layers 2 --frames 3 --frame-duration-ms 250)
    set_tests_properties(pano_cli_create_animation_document_smoke PROPERTIES
        LABELS "document;integration;desktop-fast"
        PASS_REGULAR_EXPRESSION "\"frames\":3.*\"activeFrame\":2.*\"animationDurationMs\":750")

    add_test(NAME pano_cli_inspect_image_rejects_unsupported
        COMMAND pano_cli inspect-image --path "${CMAKE_CURRENT_SOURCE_DIR}/data/images/unsupported-image.txt")
    set_tests_properties(pano_cli_inspect_image_rejects_unsupported PROPERTIES
        LABELS "assets;integration;desktop-fast"
        WILL_FAIL TRUE)

    add_test(NAME pano_cli_inspect_png_metadata_smoke
        COMMAND pano_cli inspect-image --path "${CMAKE_CURRENT_SOURCE_DIR}/data/images/tiny-rgba-header.png")
    set_tests_properties(pano_cli_inspect_png_metadata_smoke PROPERTIES
        LABELS "assets;integration;desktop-fast"
        PASS_REGULAR_EXPRESSION "\"format\":\"png\".*\"width\":320.*\"height\":240.*\"components\":4.*\"colorType\":\"rgba\"")

    add_test(NAME pano_cli_inspect_project_layout_smoke
        COMMAND pano_cli inspect-project --path "${CMAKE_CURRENT_SOURCE_DIR}/data/projects/minimal-project.ppi")
    set_tests_properties(pano_cli_inspect_project_layout_smoke PROPERTIES
        LABELS "assets;integration;desktop-fast"
        PASS_REGULAR_EXPRESSION "\"thumbnail\":\\{\"width\":128,\"height\":128,\"components\":4,\"bytes\":65536\\}.*\"body\":\\{\"offset\":65576,\"bytes\":7\\}")

    add_test(NAME pano_cli_parse_layout_smoke
        COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml")
    set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES
        LABELS "ui;integration;desktop-fast")

    add_test(NAME pano_cli_simulate_stroke_smoke
        COMMAND pano_cli simulate-stroke --x1 0 --y1 0 --x2 10 --y2 0 --spacing 2)
    set_tests_properties(pano_cli_simulate_stroke_smoke PROPERTIES
        LABELS "paint;integration;desktop-fast"
        PASS_REGULAR_EXPRESSION "\"samples\":6.*\"distance\":10")

    add_test(NAME pano_cli_simulate_stroke_script_smoke
        COMMAND pano_cli simulate-stroke-script --path "${CMAKE_CURRENT_SOURCE_DIR}/data/strokes/two-strokes.ppstroke")
    set_tests_properties(pano_cli_simulate_stroke_script_smoke PROPERTIES
        LABELS "paint;integration;desktop-fast"
        PASS_REGULAR_EXPRESSION "\"strokes\":2.*\"samples\":9.*\"distance\":20")
endif()
