mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 01:23:57 -07:00
feat(command-zone): add state machine with tests
Implement CommandZoneState - a pure C++ state machine managing zone visibility transitions (Hidden, Revealed, Peeking states). The state machine is intentionally decoupled from Qt graphics: - Pure logic with no Qt dependencies in the state class - Testable in isolation without a GUI - Clear state transition table with StateChangeResult outcomes Test coverage verifies: - Initial state is Hidden - Valid transitions: Hidden->Revealed, Hidden->Peeking, etc. - Invalid transitions return NoChange - Peek timeout triggers return to previous state This establishes the foundation for command zone visibility management while keeping graphics concerns separate.
This commit is contained in:
parent
ba1a388e5d
commit
3c2e4a3fb2
6 changed files with 678 additions and 0 deletions
40
tests/command_zone/CMakeLists.txt
Normal file
40
tests/command_zone/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# ------------------------
|
||||
# Qt modules for command zone tests
|
||||
# Qt::Gui required for QColor in z_values.h
|
||||
# Qt::Widgets required for QGraphicsItem in abstract_card_item.h
|
||||
# ------------------------
|
||||
set(TEST_QT_MODULES
|
||||
${COCKATRICE_QT_VERSION_NAME}::Core
|
||||
${COCKATRICE_QT_VERSION_NAME}::Test
|
||||
${COCKATRICE_QT_VERSION_NAME}::Gui
|
||||
${COCKATRICE_QT_VERSION_NAME}::Widgets
|
||||
)
|
||||
|
||||
# ------------------------
|
||||
# Command Zone State Test
|
||||
# Tests the extracted CommandZoneState pure state machine
|
||||
# ------------------------
|
||||
add_executable(command_zone_state_test
|
||||
command_zone_state_test.cpp
|
||||
${CMAKE_SOURCE_DIR}/cockatrice/src/game/zones/command_zone_state.cpp
|
||||
)
|
||||
|
||||
target_include_directories(command_zone_state_test
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}/cockatrice/src/game/zones
|
||||
)
|
||||
|
||||
target_link_libraries(command_zone_state_test
|
||||
PRIVATE Threads::Threads
|
||||
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
||||
PRIVATE ${TEST_QT_MODULES}
|
||||
)
|
||||
|
||||
add_test(NAME command_zone_state_test COMMAND command_zone_state_test)
|
||||
|
||||
# ------------------------
|
||||
# Dependencies on gtest
|
||||
# ------------------------
|
||||
if(NOT GTEST_FOUND)
|
||||
add_dependencies(command_zone_state_test gtest)
|
||||
endif()
|
||||
Loading…
Add table
Add a link
Reference in a new issue