2026-04-28 21:49:44 +10:00
|
|
|
################################################################################
|
|
|
|
|
# #
|
|
|
|
|
# This file is part of IfcOpenShell. #
|
|
|
|
|
# #
|
|
|
|
|
# IfcOpenShell is free software: you can redistribute it and/or modify #
|
|
|
|
|
# it under the terms of the Lesser GNU General Public License as published by #
|
|
|
|
|
# the Free Software Foundation, either version 3.0 of the License, or #
|
|
|
|
|
# (at your option) any later version. #
|
|
|
|
|
# #
|
|
|
|
|
# IfcOpenShell is distributed in the hope that it will be useful, #
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
|
# Lesser GNU General Public License for more details. #
|
|
|
|
|
# #
|
|
|
|
|
# You should have received a copy of the Lesser GNU General Public License #
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
|
|
|
|
# #
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
# Tier-1 unit tests: pure-logic modules that need neither Qt nor an OpenGL
|
|
|
|
|
# context. Each test binary compiles the production source(s) under test
|
|
|
|
|
# directly (rather than linking the IfcViewer library) so the binaries stay
|
|
|
|
|
# small and don't pull Qt6, OpenCASCADE, IfcGeom, etc. into the test build.
|
|
|
|
|
|
|
|
|
|
set(IFCVIEWER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
|
|
|
|
|
|
|
|
|
function(add_ifcviewer_unit_test name)
|
|
|
|
|
cmake_parse_arguments(T "" "" "SOURCES;LIBS" ${ARGN})
|
|
|
|
|
add_executable(${name} ${name}.cpp ${T_SOURCES})
|
|
|
|
|
target_include_directories(${name} PRIVATE ${IFCVIEWER_SRC})
|
|
|
|
|
target_link_libraries(${name} PRIVATE Catch2::Catch2WithMain ${T_LIBS})
|
|
|
|
|
catch_discover_tests(${name})
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2026-05-14 09:12:04 +10:00
|
|
|
if(WITH_MESH_OPTIMIZER)
|
|
|
|
|
add_ifcviewer_unit_test(test_lod_builder
|
|
|
|
|
SOURCES
|
|
|
|
|
${IFCVIEWER_SRC}/LodBuilder.cpp
|
|
|
|
|
LIBS meshoptimizer::meshoptimizer
|
|
|
|
|
)
|
2026-06-01 17:40:55 +10:00
|
|
|
# LodBuilder.cpp's body is guarded behind WITH_MESH_OPTIMIZER; without
|
|
|
|
|
# the define the test compiles the no-op stub and the buildLods
|
|
|
|
|
# assertions fail. The IfcViewer library propagates this define via
|
|
|
|
|
# target_compile_definitions but the test compiles LodBuilder.cpp
|
|
|
|
|
# standalone, so the test target has to set it explicitly.
|
|
|
|
|
target_compile_definitions(test_lod_builder PRIVATE -DWITH_MESH_OPTIMIZER)
|
2026-05-14 09:12:04 +10:00
|
|
|
endif()
|
2026-04-28 21:49:44 +10:00
|
|
|
|
|
|
|
|
add_ifcviewer_unit_test(test_sidecar_cache
|
|
|
|
|
SOURCES ${IFCVIEWER_SRC}/SidecarCache.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_ifcviewer_unit_test(test_instanced_geometry)
|
2026-05-01 14:41:41 +10:00
|
|
|
|
2026-06-04 11:11:14 +10:00
|
|
|
# Header-only state-machine tests for the renderer subsystems (selection,
|
|
|
|
|
# visibility). Subjects are inline in their .h files, so no SOURCES needed.
|
|
|
|
|
add_ifcviewer_unit_test(test_selection)
|
|
|
|
|
add_ifcviewer_unit_test(test_visibility)
|
|
|
|
|
|
2026-06-01 17:38:33 +10:00
|
|
|
# Federation is Qt-derived (QObject + signals). It has to pull Qt6 in
|
|
|
|
|
# directly and enable AUTOMOC for the Q_OBJECT moc-generation.
|
|
|
|
|
find_package(Qt${QT_VERSION} COMPONENTS Core Gui Test REQUIRED PATHS ${QT_DIR})
|
2026-05-01 14:41:41 +10:00
|
|
|
|
2026-05-01 15:15:37 +10:00
|
|
|
find_package(Eigen3 REQUIRED)
|
|
|
|
|
|
2026-05-01 14:41:41 +10:00
|
|
|
add_executable(test_federation
|
|
|
|
|
test_federation.cpp
|
|
|
|
|
${IFCVIEWER_SRC}/Federation.cpp
|
|
|
|
|
)
|
|
|
|
|
set_target_properties(test_federation PROPERTIES AUTOMOC ON)
|
|
|
|
|
target_include_directories(test_federation PRIVATE ${IFCVIEWER_SRC})
|
|
|
|
|
target_link_libraries(test_federation PRIVATE
|
|
|
|
|
Catch2::Catch2WithMain
|
|
|
|
|
Qt${QT_VERSION}::Core
|
|
|
|
|
Qt${QT_VERSION}::Gui # Federation::HomeView uses QVector3D from QtGui
|
|
|
|
|
Qt${QT_VERSION}::Test # QSignalSpy
|
2026-05-01 15:15:37 +10:00
|
|
|
Eigen3::Eigen # Federation.h: composed matrices use Eigen
|
2026-06-04 13:25:28 +10:00
|
|
|
# IfcUtil provides Unit::convert + Geolocation helpers
|
|
|
|
|
# (helmertMetersFromParameters, getWcs, getMapUnit) + Placement
|
|
|
|
|
# (getAxis2Placement, called from Geolocation::getWcs). Linking the
|
|
|
|
|
# static lib avoids re-compiling those .cpp files here and pulls
|
|
|
|
|
# the IfcUtil include dir + IfcParse transitively.
|
|
|
|
|
IfcUtil
|
2026-05-01 14:41:41 +10:00
|
|
|
)
|
|
|
|
|
catch_discover_tests(test_federation)
|