-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests to core using Google Test (#49)
Add unit tests for MediaProcessor using Google Test - Implement an initial set of unit tests for various components under `MediaProcessor` - Improve test coverage for file certain utilities - Ensure test configurations are properly loaded in tests - Refactor test names to follow gtest naming conventions - Resolve minor code issues identified during testing --------- Co-authored-by: Nikhil <[email protected]> Co-authored-by: Nikhil <[email protected]>
- Loading branch information
1 parent
e043132
commit c67b3a4
Showing
22 changed files
with
767 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# CMake configuration for building the main MediaProcessor executable | ||
|
||
add_executable(MediaProcessor | ||
${CMAKE_SOURCE_DIR}/src/main.cpp | ||
${CMAKE_SOURCE_DIR}/src/ConfigManager.cpp | ||
${CMAKE_SOURCE_DIR}/src/AudioProcessor.cpp | ||
${CMAKE_SOURCE_DIR}/src/VideoProcessor.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
${CMAKE_SOURCE_DIR}/src/HardwareUtils.cpp | ||
${CMAKE_SOURCE_DIR}/src/FFmpegSettingsManager.cpp | ||
) | ||
|
||
target_link_libraries(MediaProcessor PRIVATE Threads::Threads) | ||
target_link_libraries(MediaProcessor PRIVATE ${CMAKE_SOURCE_DIR}/lib/libdf.so) | ||
target_link_libraries(MediaProcessor PRIVATE ${SNDFILE_LIBRARIES}) | ||
|
||
set_target_properties(MediaProcessor PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
include(FetchContent) | ||
cmake_policy(SET CMP0135 NEW) # Use the latest policy for FetchContent consistency | ||
|
||
find_package(GTest QUIET) | ||
if(NOT GTEST_FOUND) | ||
# Fetch GTest if not found | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/5376968f6948923e2411081fd9372e71a59d8e77.zip | ||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE | ||
) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
endif() | ||
|
||
# Setup test media directory | ||
set(TEST_MEDIA_DIR "${CMAKE_SOURCE_DIR}/tests/TestMedia" CACHE PATH "Path to test media files") | ||
|
||
# Common libraries for all test targets | ||
set(COMMON_LIBRARIES gtest_main ${CMAKE_SOURCE_DIR}/lib/libdf.so ${SNDFILE_LIBRARIES}) | ||
|
||
# Macro for adding a test executable | ||
macro(add_test_executable name) | ||
add_executable(${name} ${ARGN}) | ||
target_compile_definitions(${name} PRIVATE TEST_MEDIA_DIR="${TEST_MEDIA_DIR}") | ||
target_link_libraries(${name} PRIVATE ${COMMON_LIBRARIES}) | ||
add_test(NAME ${name} COMMAND ${name}) | ||
endmacro() | ||
|
||
# Add test executables using the macro | ||
add_test_executable(ConfigManagerTester | ||
${CMAKE_SOURCE_DIR}/tests/ConfigManagerTester.cpp | ||
${CMAKE_SOURCE_DIR}/src/ConfigManager.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
${CMAKE_SOURCE_DIR}/src/HardwareUtils.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
${CMAKE_SOURCE_DIR}/tests/TestUtils.cpp | ||
) | ||
|
||
add_test_executable(UtilsTester | ||
${CMAKE_SOURCE_DIR}/tests/UtilsTester.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
) | ||
|
||
add_test_executable(AudioProcessorTester | ||
${CMAKE_SOURCE_DIR}/tests/AudioProcessorTester.cpp | ||
${CMAKE_SOURCE_DIR}/src/AudioProcessor.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
${CMAKE_SOURCE_DIR}/src/HardwareUtils.cpp | ||
${CMAKE_SOURCE_DIR}/src/ConfigManager.cpp | ||
${CMAKE_SOURCE_DIR}/tests/TestUtils.cpp | ||
) | ||
|
||
add_test_executable(VideoProcessorTester | ||
${CMAKE_SOURCE_DIR}/tests/VideoProcessorTester.cpp | ||
${CMAKE_SOURCE_DIR}/src/VideoProcessor.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
${CMAKE_SOURCE_DIR}/src/ConfigManager.cpp | ||
${CMAKE_SOURCE_DIR}/src/HardwareUtils.cpp | ||
${CMAKE_SOURCE_DIR}/tests/TestUtils.cpp | ||
) | ||
|
||
add_test_executable(CommandBuilderTester | ||
${CMAKE_SOURCE_DIR}/tests/CommandBuilderTester.cpp | ||
${CMAKE_SOURCE_DIR}/src/CommandBuilder.cpp | ||
${CMAKE_SOURCE_DIR}/src/Utils.cpp | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.