Files
SimpleRemoter/test/CMakeLists.txt
T
yuanyuanxianganddeepseek-flash 5f40f3726c Fix: React to slow-frame congestion and keep remote audio recoverable
The adaptive quality controller counted only complete frames per second, so when
a single frame took several seconds to arrive the sample was 0 fps and the
throughput criterion abstained forever: Ultra and High kept flipping while a
foreground video played. The audio watchdog had the opposite problem: it rebuilt
the WASAPI capture every three seconds on an idle endpoint, and its sleep
detector measured the whole loop including a blocking send.

Sample the last ten seconds in a ring buffer and feed the criterion a windowed
rate, guarded so a scroll burst, a stale window or a few KB clock patch is not
mistaken for congestion. Apply the same per-frame floor to the one-second
fallback and to the post-downgrade local-bottleneck probe. Normalize delayed
timer ticks by real elapsed milliseconds, and make the 40 second
upgrade-failure window outlast the resolution cooldown it has to cross.

On the client, rebuild only when an audio session is actually rendering, and
rebuild immediately when the captured endpoint is no longer the default output;
refresh the sleep timestamps on failed as well as successful init.

Tests cover the window and fallback helpers directly; the full suite passes
845/845, and both the Debug server and Debug client build.

Co-Authored-By: deepseek-flash
2026-11-08 11:45:19 +01:00

430 lines
11 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.
# SimpleRemoter 测试构建配置
cmake_minimum_required(VERSION 3.14)
project(SimpleRemoterTests)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# MSVC 编码设置
if(MSVC)
add_compile_options(/utf-8)
endif()
# 选项:是否构建测试
option(BUILD_TESTING "Build tests" ON)
if(NOT BUILD_TESTING)
return()
endif()
# 使用 FetchContent 获取 Google Test
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# Windows 下避免覆盖 /MT /MD 设置
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
# 包含项目头文件目录
include_directories(${CMAKE_SOURCE_DIR}/..)
include_directories(${CMAKE_SOURCE_DIR}/../client)
include_directories(${CMAKE_SOURCE_DIR}/../server/2015Remote)
include_directories(${CMAKE_SOURCE_DIR}/../common)
# ============================================
# 客户端 Buffer 测试
# ============================================
add_executable(client_buffer_test
unit/client/BufferTest.cpp
)
# 测试文件内联包含了 Buffer 实现的测试版本
# 无需链接原始源文件,支持跨平台测试
target_link_libraries(client_buffer_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(client_buffer_test PRIVATE _WIN32)
endif()
# ============================================
# 服务端 Buffer 测试
# ============================================
add_executable(server_buffer_test
unit/server/BufferTest.cpp
)
# 测试文件内联包含了 Buffer 实现的测试版本
# 支持跨平台测试
target_link_libraries(server_buffer_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(server_buffer_test PRIVATE _WIN32)
endif()
# Linux 需要 pthread
if(UNIX)
find_package(Threads REQUIRED)
target_link_libraries(client_buffer_test Threads::Threads)
target_link_libraries(server_buffer_test Threads::Threads)
endif()
# ============================================
# 协议测试 (Phase 1)
# ============================================
add_executable(protocol_test
unit/protocol/PacketTest.cpp
unit/protocol/PathUtilsTest.cpp
)
target_link_libraries(protocol_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(protocol_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(protocol_test Threads::Threads)
endif()
# ============================================
# 文件传输测试 (Phase 2)
# ============================================
add_executable(file_transfer_test
unit/file/FileTransferV2Test.cpp
)
target_link_libraries(file_transfer_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(file_transfer_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(file_transfer_test Threads::Threads)
endif()
# ============================================
# 分块管理测试 (Phase 2)
# ============================================
add_executable(chunk_manager_test
unit/file/ChunkManagerTest.cpp
)
target_link_libraries(chunk_manager_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(chunk_manager_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(chunk_manager_test Threads::Threads)
endif()
# ============================================
# SHA-256 校验测试 (Phase 2)
# ============================================
add_executable(sha256_verify_test
unit/file/SHA256VerifyTest.cpp
)
target_link_libraries(sha256_verify_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(sha256_verify_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(sha256_verify_test Threads::Threads)
endif()
# ============================================
# 断点续传状态测试 (Phase 2)
# ============================================
add_executable(resume_state_test
unit/file/ResumeStateTest.cpp
)
target_link_libraries(resume_state_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(resume_state_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(resume_state_test Threads::Threads)
endif()
# ============================================
# 协议头验证测试 (Phase 3)
# ============================================
add_executable(header_test
unit/network/HeaderTest.cpp
)
target_link_libraries(header_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(header_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(header_test Threads::Threads)
endif()
# ============================================
# 粘包/分包测试 (Phase 3)
# ============================================
add_executable(packet_fragment_test
unit/network/PacketFragmentTest.cpp
)
target_link_libraries(packet_fragment_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(packet_fragment_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(packet_fragment_test Threads::Threads)
endif()
# ============================================
# HTTP 伪装测试 (Phase 3)
# ============================================
add_executable(http_mask_test
unit/network/HttpMaskTest.cpp
)
target_link_libraries(http_mask_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(http_mask_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(http_mask_test Threads::Threads)
endif()
# ============================================
# 差分算法测试 (Phase 4)
# ============================================
add_executable(diff_algorithm_test
unit/screen/DiffAlgorithmTest.cpp
)
target_link_libraries(diff_algorithm_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(diff_algorithm_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(diff_algorithm_test Threads::Threads)
endif()
# ============================================
# RGB565 压缩测试 (Phase 4)
# ============================================
add_executable(rgb565_test
unit/screen/RGB565Test.cpp
)
target_link_libraries(rgb565_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(rgb565_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(rgb565_test Threads::Threads)
endif()
# ============================================
# 滚动检测测试 (Phase 4)
# ============================================
add_executable(scroll_detector_test
unit/screen/ScrollDetectorTest.cpp
)
target_link_libraries(scroll_detector_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(scroll_detector_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(scroll_detector_test Threads::Threads)
endif()
# ============================================
# 质量自适应测试 (Phase 4)
# ============================================
add_executable(quality_adaptive_test
unit/screen/QualityAdaptiveTest.cpp
)
target_link_libraries(quality_adaptive_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(quality_adaptive_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(quality_adaptive_test Threads::Threads)
endif()
# ============================================
# 吞吐判据测试(自适应质量的双判据)
# 直接 include 真实 commands.h,不复制实现,所以需要把 common/ 加进头文件搜索路径
# ============================================
add_executable(quality_load_test
unit/screen/QualityLoadTest.cpp
)
target_include_directories(quality_load_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/..
)
target_link_libraries(quality_load_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(quality_load_test PRIVATE _WIN32)
endif()
if(MSVC)
# CMake 默认给所有目标加 /D_WINDOWS,commands.h 见到它就 include <afxwin.h>;
# 测试用 /MD 又没定义 _AFXDLL,于是直接编译失败(这个目标因此一直没在 Windows
# 上跑起来)。判据本身不需要 MFC,去掉它不是二选一:commands.h 会退回 windows.h。
# 只对 MSVC 生效:MinGW/GCC 不认 /U_WINDOWS。
target_compile_options(quality_load_test PRIVATE /U_WINDOWS)
endif()
if(UNIX)
target_link_libraries(quality_load_test Threads::Threads)
endif()
# ============================================
# 时间验证测试 (授权模块)
# ============================================
add_executable(date_verify_test
unit/auth/DateVerifyTest.cpp
)
target_link_libraries(date_verify_test
GTest::gtest_main
)
if(WIN32)
target_compile_definitions(date_verify_test PRIVATE _WIN32)
endif()
if(UNIX)
target_link_libraries(date_verify_test Threads::Threads)
endif()
# ============================================
# IP地理位置测试 (网络API)
# ============================================
if(WIN32)
add_executable(geolocation_test
unit/network/GeoLocationTest.cpp
)
target_link_libraries(geolocation_test
GTest::gtest_main
wininet
ws2_32
)
target_compile_definitions(geolocation_test PRIVATE _WIN32)
endif()
# ============================================
# 注册表配置测试 (iniFile/binFile)
# ============================================
if(WIN32)
add_executable(registry_config_test
unit/config/RegistryConfigTest.cpp
)
target_link_libraries(registry_config_test
GTest::gtest_main
advapi32
)
target_compile_definitions(registry_config_test PRIVATE _WIN32)
endif()
# 注册测试
include(GoogleTest)
if(WIN32)
gtest_discover_tests(geolocation_test)
gtest_discover_tests(registry_config_test)
endif()
gtest_discover_tests(client_buffer_test)
gtest_discover_tests(server_buffer_test)
gtest_discover_tests(protocol_test)
gtest_discover_tests(file_transfer_test)
gtest_discover_tests(chunk_manager_test)
gtest_discover_tests(sha256_verify_test)
gtest_discover_tests(resume_state_test)
gtest_discover_tests(header_test)
gtest_discover_tests(packet_fragment_test)
gtest_discover_tests(http_mask_test)
gtest_discover_tests(diff_algorithm_test)
gtest_discover_tests(rgb565_test)
gtest_discover_tests(scroll_detector_test)
gtest_discover_tests(quality_adaptive_test)
gtest_discover_tests(quality_load_test)
gtest_discover_tests(date_verify_test)
# 自定义目标:运行所有测试
add_custom_target(run_tests
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS client_buffer_test server_buffer_test protocol_test
file_transfer_test chunk_manager_test sha256_verify_test resume_state_test
header_test packet_fragment_test http_mask_test
diff_algorithm_test rgb565_test scroll_detector_test quality_adaptive_test
quality_load_test date_verify_test
)