geopro/tests/CMakeLists.txt

115 lines
6.4 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 单元测试(设计 §12。M1 spike 阶段先放一个 gtest 冒烟用例,
# 验证 gtest 经 vcpkg 接入、ctest 可跑;随 core/data/algo 实现补充真实用例。
find_package(GTest CONFIG REQUIRED)
add_executable(geopro_tests smoke_test.cpp)
target_link_libraries(geopro_tests PRIVATE GTest::gtest GTest::gtest_main)
include(GoogleTest)
# PROJ 运行时需要数据目录proj.db 等。vcpkg 把数据装在 share/proj 下。
# 通过测试环境变量 PROJ_DATA 注入,使 `ctest -R CrsTransform` 无需调用方手动 set。
file(GLOB _proj_data_dirs
"${CMAKE_BINARY_DIR}/vcpkg_installed/*/share/proj"
)
# DISCOVERY_MODE PRE_TEST把用例枚举推迟到 ctest 运行时执行,而非构建后立即跑
# exe。因 geopro_data 链 Qt6::Core构建期发现会因 Qt6Core.dll 尚未拷贝到 exe 旁而
# 失败0xc0000135推迟到运行期时 POST_BUILD 已把运行时 DLL 拷到位。
if(_proj_data_dirs)
list(GET _proj_data_dirs 0 GEOPRO_PROJ_DATA)
gtest_discover_tests(geopro_tests
DISCOVERY_MODE PRE_TEST
PROPERTIES ENVIRONMENT "PROJ_DATA=${GEOPRO_PROJ_DATA}")
else()
gtest_discover_tests(geopro_tests DISCOVERY_MODE PRE_TEST)
endif()
target_sources(geopro_tests PRIVATE core/test_local_frame.cpp)
target_sources(geopro_tests PRIVATE core/test_model.cpp)
target_sources(geopro_tests PRIVATE core/test_color_scale.cpp)
target_sources(geopro_tests PRIVATE core/test_idw.cpp)
target_sources(geopro_tests PRIVATE core/test_crs_transform.cpp)
target_sources(geopro_tests PRIVATE core/test_model_data.cpp)
target_sources(geopro_tests PRIVATE core/test_geo_frame.cpp)
target_link_libraries(geopro_tests PRIVATE geopro_core)
target_sources(geopro_tests PRIVATE data/test_parsers.cpp)
target_sources(geopro_tests PRIVATE data/test_local_repo.cpp)
target_sources(geopro_tests PRIVATE data/test_nav_dto.cpp)
target_sources(geopro_tests PRIVATE data/test_dataset_chart_dto.cpp)
target_sources(geopro_tests PRIVATE data/test_dataset_load_handles.cpp)
# NavRequest 离线单测QVariant payload: done/failed/abort 闸门)。
target_sources(geopro_tests PRIVATE data/test_nav_request.cpp)
target_link_libraries(geopro_tests PRIVATE geopro_data)
# net 层RSA 加密器。测试需直接用 OpenSSL 生成/解密密钥,故显式 find_package
# 并链接 OpenSSLgeopro_net 的 PUBLIC 链接通常已传递,这里显式以防头文件找不到)。
find_package(OpenSSL REQUIRED)
find_package(Qt6 COMPONENTS Core Network Test REQUIRED)
target_sources(geopro_tests PRIVATE net/test_rsa.cpp)
# 端到端登录连通测试ApiClient + AuthService需 Qt6::Core/Network 与事件循环。
target_sources(geopro_tests PRIVATE net/test_auth.cpp)
# ApiBatch 离线单测QSignalSpy 需 Qt6::Test
target_sources(geopro_tests PRIVATE net/test_api_batch.cpp)
# ApiChain 离线单测(顺序依赖链:顺序/失败短路/abort闸门/工厂抛异常)。
target_sources(geopro_tests PRIVATE net/test_api_chain.cpp)
# AuthLoads 离线单测CaptchaLoad/LoginLoad 句柄done/failed/abort 闸门)。
target_sources(geopro_tests PRIVATE net/test_auth_loads.cpp)
target_link_libraries(geopro_tests PRIVATE geopro_net OpenSSL::SSL OpenSSL::Crypto Qt6::Core Qt6::Network Qt6::Test)
# geopro_data 链 Qt6::Core测试 exe 运行(含 gtest 发现)需要 Qt6Core.dll 等运行时
# DLL 在旁。复用 app 同样的 TARGET_RUNTIME_DLLS POST_BUILD 拷贝。
if(WIN32)
add_custom_command(TARGET geopro_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:geopro_tests> $<TARGET_FILE_DIR:geopro_tests>
COMMAND_EXPAND_LISTS)
endif()
# render 层ColorLutBuildercore ColorScale -> vtkLookupTable
# 需 vtkLookupTableVTK::CommonCoregeopro_render 已 PUBLIC 传递其余 VTK 组件。
find_package(VTK REQUIRED COMPONENTS CommonCore CommonDataModel RenderingCore)
target_sources(geopro_tests PRIVATE render/test_color_lut.cpp)
target_sources(geopro_tests PRIVATE render/test_contour_bands.cpp)
# dd_voxelbuildVoxel(ScalarVolume->vtkImageData->GPU 体绘制) 构建不崩 + dims 正确。
target_sources(geopro_tests PRIVATE render/test_voxel_build.cpp)
# dd_voxel 回归buildVoxelFromScatters(散点 projX/Y -EPSG:4547-> 世界系 + IDW) 配准+充填(需 PROJ_DATA)。
target_sources(geopro_tests PRIVATE render/test_voxel_register.cpp)
# CurtainbuildCurtain(Grid+GeoLocalFrame->vtkStructuredGrid 帘面) 非空 actor + 点数=nx*ny。
target_sources(geopro_tests PRIVATE render/test_curtain.cpp)
# Scatter(#17)buildScatter(ScatterField+ColorScale->vtkPolyData 彩色散点) 点数/verts/上色/y取负。
target_sources(geopro_tests PRIVATE render/test_scatter.cpp)
# AnomalybuildAnomalies(markType 点/线/面 -> vtkActor) 几何/闭合/颜色/y取负/空跳过。
target_sources(geopro_tests PRIVATE render/test_anomaly.cpp)
# ElectrodebuildElectrodes(剖面顶边朝下三角 ▼) 三角数/顶点位置/空安全。
target_sources(geopro_tests PRIVATE render/test_electrode.cpp)
# TerrainbuildTerrain(GDAL 读 dem/image + 重投影 → warp 面+纹理) 非空/缺文件安全(需 PROJ_DATA)。
target_sources(geopro_tests PRIVATE render/test_terrain.cpp)
target_link_libraries(geopro_tests PRIVATE geopro_render ${VTK_LIBRARIES})
vtk_module_autoinit(TARGETS geopro_tests MODULES ${VTK_LIBRARIES})
# Qwt 集成冒烟(仅当 qwt 目标存在,即 external/qwt-src 已拉取)。
if(TARGET qwt)
target_sources(geopro_tests PRIVATE render/test_qwt_smoke.cpp)
target_link_libraries(geopro_tests PRIVATE qwt)
endif()
target_include_directories(geopro_tests PRIVATE ${CMAKE_SOURCE_DIR}/src/app)
# tests/ 在 include 路径net/test_api_batch.cpp 用 #include "net/FakeApiCall.hpp"。
target_include_directories(geopro_tests PRIVATE ${CMAKE_SOURCE_DIR}/tests)
target_sources(geopro_tests PRIVATE app/test_chart_strategy_registry.cpp)
# ColorMapService 测试geopro_desktop 是可执行文件,直接把源加入测试目标)
target_sources(geopro_tests PRIVATE
app/test_colormap_service.cpp
${CMAKE_SOURCE_DIR}/src/app/panels/chart/ColorMapService.cpp
)
# controller 层DatasetDetailController 编排集成测试QSignalSpy 验证 chartReady/loadFailed
find_package(Qt6 COMPONENTS Test REQUIRED)
target_sources(geopro_tests PRIVATE controller/test_dataset_detail_controller.cpp)
target_sources(geopro_tests PRIVATE controller/test_workbench_nav_controller.cpp)
target_link_libraries(geopro_tests PRIVATE geopro_controller Qt6::Test)
add_subdirectory(spike) # spike S3: banded contour 渲染验证