🎨 Auto-format GDScript code

Automated formatting applied by tools/run_development.py

🤖 Generated by Gitea Actions
Workflow: Continuous Integration
Run: http://server:3000/nett00n/skelly/actions/runs/90
This commit is contained in:
Gitea Actions
2025-10-01 11:05:19 +00:00
parent 3b8da89ad5
commit 1f1c394587
28 changed files with 655 additions and 1945 deletions

View File

@@ -69,17 +69,12 @@ func test_basic_functionality():
# Test that AudioManager has expected methods
var expected_methods = ["update_music_volume", "play_ui_click"]
TestHelperClass.assert_has_methods(
audio_manager, expected_methods, "AudioManager methods"
)
TestHelperClass.assert_has_methods(audio_manager, expected_methods, "AudioManager methods")
# Test that AudioManager has expected constants
TestHelperClass.assert_true("MUSIC_PATH" in audio_manager, "MUSIC_PATH constant exists")
TestHelperClass.assert_true(
"MUSIC_PATH" in audio_manager, "MUSIC_PATH constant exists"
)
TestHelperClass.assert_true(
"UI_CLICK_SOUND_PATH" in audio_manager,
"UI_CLICK_SOUND_PATH constant exists"
"UI_CLICK_SOUND_PATH" in audio_manager, "UI_CLICK_SOUND_PATH constant exists"
)
@@ -90,12 +85,9 @@ func test_audio_constants():
var music_path = audio_manager.MUSIC_PATH
var click_path = audio_manager.UI_CLICK_SOUND_PATH
TestHelperClass.assert_true(music_path.begins_with("res://"), "Music path uses res:// protocol")
TestHelperClass.assert_true(
music_path.begins_with("res://"), "Music path uses res:// protocol"
)
TestHelperClass.assert_true(
click_path.begins_with("res://"),
"Click sound path uses res:// protocol"
click_path.begins_with("res://"), "Click sound path uses res:// protocol"
)
# Test file extensions
@@ -109,17 +101,11 @@ func test_audio_constants():
if click_path.ends_with(ext):
click_has_valid_ext = true
TestHelperClass.assert_true(
music_has_valid_ext, "Music file has valid audio extension"
)
TestHelperClass.assert_true(
click_has_valid_ext, "Click sound has valid audio extension"
)
TestHelperClass.assert_true(music_has_valid_ext, "Music file has valid audio extension")
TestHelperClass.assert_true(click_has_valid_ext, "Click sound has valid audio extension")
# Test that audio files exist
TestHelperClass.assert_true(
ResourceLoader.exists(music_path), "Music file exists at path"
)
TestHelperClass.assert_true(ResourceLoader.exists(music_path), "Music file exists at path")
TestHelperClass.assert_true(
ResourceLoader.exists(click_path), "Click sound file exists at path"
)
@@ -129,12 +115,9 @@ func test_audio_player_initialization():
TestHelperClass.print_step("Audio Player Initialization")
# Test music player initialization
TestHelperClass.assert_not_null(
audio_manager.music_player, "Music player is initialized"
)
TestHelperClass.assert_not_null(audio_manager.music_player, "Music player is initialized")
TestHelperClass.assert_true(
audio_manager.music_player is AudioStreamPlayer,
"Music player is AudioStreamPlayer type"
audio_manager.music_player is AudioStreamPlayer, "Music player is AudioStreamPlayer type"
)
TestHelperClass.assert_true(
audio_manager.music_player.get_parent() == audio_manager,
@@ -142,9 +125,7 @@ func test_audio_player_initialization():
)
# Test UI click player initialization
TestHelperClass.assert_not_null(
audio_manager.ui_click_player, "UI click player is initialized"
)
TestHelperClass.assert_not_null(audio_manager.ui_click_player, "UI click player is initialized")
TestHelperClass.assert_true(
audio_manager.ui_click_player is AudioStreamPlayer,
"UI click player is AudioStreamPlayer type"
@@ -156,14 +137,10 @@ func test_audio_player_initialization():
# Test audio bus assignment
TestHelperClass.assert_equal(
"Music",
audio_manager.music_player.bus,
"Music player assigned to Music bus"
"Music", audio_manager.music_player.bus, "Music player assigned to Music bus"
)
TestHelperClass.assert_equal(
"SFX",
audio_manager.ui_click_player.bus,
"UI click player assigned to SFX bus"
"SFX", audio_manager.ui_click_player.bus, "UI click player assigned to SFX bus"
)
@@ -171,38 +148,26 @@ func test_stream_loading_and_validation():
TestHelperClass.print_step("Stream Loading and Validation")
# Test music stream loading
TestHelperClass.assert_not_null(
audio_manager.music_player.stream, "Music stream is loaded"
)
TestHelperClass.assert_not_null(audio_manager.music_player.stream, "Music stream is loaded")
if audio_manager.music_player.stream:
TestHelperClass.assert_true(
audio_manager.music_player.stream is AudioStream,
"Music stream is AudioStream type"
audio_manager.music_player.stream is AudioStream, "Music stream is AudioStream type"
)
# Test click stream loading
TestHelperClass.assert_not_null(
audio_manager.click_stream, "Click stream is loaded"
)
TestHelperClass.assert_not_null(audio_manager.click_stream, "Click stream is loaded")
if audio_manager.click_stream:
TestHelperClass.assert_true(
audio_manager.click_stream is AudioStream,
"Click stream is AudioStream type"
audio_manager.click_stream is AudioStream, "Click stream is AudioStream type"
)
# Test stream resource loading directly
var loaded_music = load(audio_manager.MUSIC_PATH)
TestHelperClass.assert_not_null(
loaded_music, "Music resource loads successfully"
)
TestHelperClass.assert_true(
loaded_music is AudioStream, "Loaded music is AudioStream type"
)
TestHelperClass.assert_not_null(loaded_music, "Music resource loads successfully")
TestHelperClass.assert_true(loaded_music is AudioStream, "Loaded music is AudioStream type")
var loaded_click = load(audio_manager.UI_CLICK_SOUND_PATH)
TestHelperClass.assert_not_null(
loaded_click, "Click resource loads successfully"
)
TestHelperClass.assert_not_null(loaded_click, "Click resource loads successfully")
TestHelperClass.assert_true(
loaded_click is AudioStream, "Loaded click sound is AudioStream type"
)
@@ -221,9 +186,7 @@ func test_audio_bus_configuration():
# Test player bus assignments match actual AudioServer buses
if music_bus_index >= 0:
TestHelperClass.assert_equal(
"Music",
audio_manager.music_player.bus,
"Music player correctly assigned to Music bus"
"Music", audio_manager.music_player.bus, "Music player correctly assigned to Music bus"
)
if sfx_bus_index >= 0:
@@ -245,27 +208,20 @@ func test_volume_management():
# Test volume update to valid range
audio_manager.update_music_volume(0.5)
TestHelperClass.assert_float_equal(
linear_to_db(0.5),
audio_manager.music_player.volume_db,
0.001,
"Music volume set correctly"
linear_to_db(0.5), audio_manager.music_player.volume_db, 0.001, "Music volume set correctly"
)
# Test volume update to zero (should stop music)
audio_manager.update_music_volume(0.0)
TestHelperClass.assert_equal(
linear_to_db(0.0),
audio_manager.music_player.volume_db,
"Zero volume set correctly"
linear_to_db(0.0), audio_manager.music_player.volume_db, "Zero volume set correctly"
)
# Note: We don't test playing state as it depends on initialization conditions
# Test volume update to maximum
audio_manager.update_music_volume(1.0)
TestHelperClass.assert_equal(
linear_to_db(1.0),
audio_manager.music_player.volume_db,
"Maximum volume set correctly"
linear_to_db(1.0), audio_manager.music_player.volume_db, "Maximum volume set correctly"
)
# Test volume range validation
@@ -292,8 +248,7 @@ func test_music_playback_control():
audio_manager.music_player, "Music player exists for playback testing"
)
TestHelperClass.assert_not_null(
audio_manager.music_player.stream,
"Music player has stream for playback testing"
audio_manager.music_player.stream, "Music player has stream for playback testing"
)
# Test playback state management
@@ -324,12 +279,8 @@ func test_ui_sound_effects():
TestHelperClass.print_step("UI Sound Effects")
# Test UI click functionality
TestHelperClass.assert_not_null(
audio_manager.ui_click_player, "UI click player exists"
)
TestHelperClass.assert_not_null(
audio_manager.click_stream, "Click stream is loaded"
)
TestHelperClass.assert_not_null(audio_manager.ui_click_player, "UI click player exists")
TestHelperClass.assert_not_null(audio_manager.click_stream, "Click stream is loaded")
# Test that play_ui_click can be called safely
var original_stream = audio_manager.ui_click_player.stream
@@ -345,9 +296,7 @@ func test_ui_sound_effects():
# Test multiple rapid clicks (should not cause errors)
for i in range(3):
audio_manager.play_ui_click()
TestHelperClass.assert_true(
true, "Rapid click %d handled safely" % (i + 1)
)
TestHelperClass.assert_true(true, "Rapid click %d handled safely" % (i + 1))
# Test click with null stream
var backup_stream = audio_manager.click_stream
@@ -366,9 +315,7 @@ func test_stream_loop_configuration():
if music_stream is AudioStreamWAV:
# For WAV files, check loop mode
var has_loop_mode = "loop_mode" in music_stream
TestHelperClass.assert_true(
has_loop_mode, "WAV stream has loop_mode property"
)
TestHelperClass.assert_true(has_loop_mode, "WAV stream has loop_mode property")
if has_loop_mode:
TestHelperClass.assert_equal(
AudioStreamWAV.LOOP_FORWARD,
@@ -378,18 +325,12 @@ func test_stream_loop_configuration():
elif music_stream is AudioStreamOggVorbis:
# For OGG files, check loop property
var has_loop = "loop" in music_stream
TestHelperClass.assert_true(
has_loop, "OGG stream has loop property"
)
TestHelperClass.assert_true(has_loop, "OGG stream has loop property")
if has_loop:
TestHelperClass.assert_true(
music_stream.loop, "OGG stream loop enabled"
)
TestHelperClass.assert_true(music_stream.loop, "OGG stream loop enabled")
# Test loop configuration for different stream types
TestHelperClass.assert_true(
true, "Stream loop configuration tested based on type"
)
TestHelperClass.assert_true(true, "Stream loop configuration tested based on type")
func test_error_handling():
@@ -400,18 +341,15 @@ func test_error_handling():
# Test that AudioManager initializes even with potential issues
TestHelperClass.assert_not_null(
audio_manager,
"AudioManager initializes despite potential resource issues"
audio_manager, "AudioManager initializes despite potential resource issues"
)
# Test that players are still created even if streams fail to load
TestHelperClass.assert_not_null(
audio_manager.music_player,
"Music player created regardless of stream loading"
audio_manager.music_player, "Music player created regardless of stream loading"
)
TestHelperClass.assert_not_null(
audio_manager.ui_click_player,
"UI click player created regardless of stream loading"
audio_manager.ui_click_player, "UI click player created regardless of stream loading"
)
# Test null stream handling in play_ui_click
@@ -420,9 +358,7 @@ func test_error_handling():
# This should not crash
audio_manager.play_ui_click()
TestHelperClass.assert_true(
true, "play_ui_click handles null stream gracefully"
)
TestHelperClass.assert_true(true, "play_ui_click handles null stream gracefully")
# Restore original stream
audio_manager.click_stream = original_click_stream

View File

@@ -57,9 +57,7 @@ func test_basic_functionality():
# Test that GameManager has expected properties
TestHelperClass.assert_has_properties(
game_manager,
["pending_gameplay_mode", "is_changing_scene"],
"GameManager properties"
game_manager, ["pending_gameplay_mode", "is_changing_scene"], "GameManager properties"
)
# Test that GameManager has expected methods
@@ -72,19 +70,13 @@ func test_basic_functionality():
"save_game",
"exit_to_main_menu"
]
TestHelperClass.assert_has_methods(
game_manager, expected_methods, "GameManager methods"
)
TestHelperClass.assert_has_methods(game_manager, expected_methods, "GameManager methods")
# Test initial state
TestHelperClass.assert_equal(
"match3",
game_manager.pending_gameplay_mode,
"Default pending gameplay mode"
)
TestHelperClass.assert_false(
game_manager.is_changing_scene, "Initial scene change flag"
"match3", game_manager.pending_gameplay_mode, "Default pending gameplay mode"
)
TestHelperClass.assert_false(game_manager.is_changing_scene, "Initial scene change flag")
func test_scene_constants():
@@ -105,23 +97,15 @@ func test_scene_constants():
TestHelperClass.assert_true(
game_path.begins_with("res://"), "Game scene path uses res:// protocol"
)
TestHelperClass.assert_true(
game_path.ends_with(".tscn"), "Game scene path has .tscn extension"
)
TestHelperClass.assert_true(game_path.ends_with(".tscn"), "Game scene path has .tscn extension")
TestHelperClass.assert_true(
main_path.begins_with("res://"), "Main scene path uses res:// protocol"
)
TestHelperClass.assert_true(
main_path.ends_with(".tscn"), "Main scene path has .tscn extension"
)
TestHelperClass.assert_true(main_path.ends_with(".tscn"), "Main scene path has .tscn extension")
# Test that scene files exist
TestHelperClass.assert_true(
ResourceLoader.exists(game_path), "Game scene file exists at path"
)
TestHelperClass.assert_true(
ResourceLoader.exists(main_path), "Main scene file exists at path"
)
TestHelperClass.assert_true(ResourceLoader.exists(game_path), "Game scene file exists at path")
TestHelperClass.assert_true(ResourceLoader.exists(main_path), "Main scene file exists at path")
func test_input_validation():
@@ -134,50 +118,38 @@ func test_input_validation():
# Test empty string validation
game_manager.start_game_with_mode("")
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Empty string mode rejected"
original_mode, game_manager.pending_gameplay_mode, "Empty string mode rejected"
)
TestHelperClass.assert_false(
game_manager.is_changing_scene,
"Scene change flag unchanged after empty mode"
game_manager.is_changing_scene, "Scene change flag unchanged after empty mode"
)
# Test null validation - GameManager expects String, so this tests the type safety
# Note: In Godot 4.4, passing null to String parameter causes script error as expected
# The function properly validates empty strings instead
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Mode preserved after empty string test"
original_mode, game_manager.pending_gameplay_mode, "Mode preserved after empty string test"
)
TestHelperClass.assert_false(
game_manager.is_changing_scene,
"Scene change flag unchanged after validation tests"
game_manager.is_changing_scene, "Scene change flag unchanged after validation tests"
)
# Test invalid mode validation
game_manager.start_game_with_mode("invalid_mode")
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Invalid mode rejected"
original_mode, game_manager.pending_gameplay_mode, "Invalid mode rejected"
)
TestHelperClass.assert_false(
game_manager.is_changing_scene,
"Scene change flag unchanged after invalid mode"
game_manager.is_changing_scene, "Scene change flag unchanged after invalid mode"
)
# Test case sensitivity
game_manager.start_game_with_mode("MATCH3")
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Case-sensitive mode validation"
original_mode, game_manager.pending_gameplay_mode, "Case-sensitive mode validation"
)
TestHelperClass.assert_false(
game_manager.is_changing_scene,
"Scene change flag unchanged after wrong case"
game_manager.is_changing_scene, "Scene change flag unchanged after wrong case"
)
@@ -193,19 +165,14 @@ func test_race_condition_protection():
# Verify second request was rejected
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Concurrent scene change blocked"
)
TestHelperClass.assert_true(
game_manager.is_changing_scene, "Scene change flag preserved"
original_mode, game_manager.pending_gameplay_mode, "Concurrent scene change blocked"
)
TestHelperClass.assert_true(game_manager.is_changing_scene, "Scene change flag preserved")
# Test exit to main menu during scene change
game_manager.exit_to_main_menu()
TestHelperClass.assert_true(
game_manager.is_changing_scene,
"Exit request blocked during scene change"
game_manager.is_changing_scene, "Exit request blocked during scene change"
)
# Reset state
@@ -224,17 +191,13 @@ func test_gameplay_mode_validation():
# Create a temporary mock to test validation
var test_mode_valid = mode in ["match3", "clickomania"]
TestHelperClass.assert_true(
test_mode_valid, "Valid mode accepted: " + mode
)
TestHelperClass.assert_true(test_mode_valid, "Valid mode accepted: " + mode)
# Test whitelist enforcement
var invalid_modes = ["puzzle", "arcade", "adventure", "rpg", "action"]
for mode in invalid_modes:
var test_mode_invalid = not (mode in ["match3", "clickomania"])
TestHelperClass.assert_true(
test_mode_invalid, "Invalid mode rejected: " + mode
)
TestHelperClass.assert_true(test_mode_invalid, "Invalid mode rejected: " + mode)
func test_scene_transition_safety():
@@ -246,20 +209,12 @@ func test_scene_transition_safety():
# Test scene resource loading
var game_scene = load(game_scene_path)
TestHelperClass.assert_not_null(
game_scene, "Game scene resource loads successfully"
)
TestHelperClass.assert_true(
game_scene is PackedScene, "Game scene is PackedScene type"
)
TestHelperClass.assert_not_null(game_scene, "Game scene resource loads successfully")
TestHelperClass.assert_true(game_scene is PackedScene, "Game scene is PackedScene type")
var main_scene = load(main_scene_path)
TestHelperClass.assert_not_null(
main_scene, "Main scene resource loads successfully"
)
TestHelperClass.assert_true(
main_scene is PackedScene, "Main scene is PackedScene type"
)
TestHelperClass.assert_not_null(main_scene, "Main scene resource loads successfully")
TestHelperClass.assert_true(main_scene is PackedScene, "Main scene is PackedScene type")
# Test that current scene exists
TestHelperClass.assert_not_null(current_scene, "Current scene exists")
@@ -279,14 +234,10 @@ func test_error_handling():
# Verify state preservation after invalid inputs
game_manager.start_game_with_mode("")
TestHelperClass.assert_equal(
original_changing,
game_manager.is_changing_scene,
"State preserved after empty mode error"
original_changing, game_manager.is_changing_scene, "State preserved after empty mode error"
)
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Mode preserved after empty mode error"
original_mode, game_manager.pending_gameplay_mode, "Mode preserved after empty mode error"
)
game_manager.start_game_with_mode("invalid")
@@ -296,9 +247,7 @@ func test_error_handling():
"State preserved after invalid mode error"
)
TestHelperClass.assert_equal(
original_mode,
game_manager.pending_gameplay_mode,
"Mode preserved after invalid mode error"
original_mode, game_manager.pending_gameplay_mode, "Mode preserved after invalid mode error"
)
@@ -314,15 +263,9 @@ func test_scene_method_validation():
var has_set_global_score = mock_scene.has_method("set_global_score")
var has_get_global_score = mock_scene.has_method("get_global_score")
TestHelperClass.assert_false(
has_set_gameplay_mode, "Mock scene lacks set_gameplay_mode method"
)
TestHelperClass.assert_false(
has_set_global_score, "Mock scene lacks set_global_score method"
)
TestHelperClass.assert_false(
has_get_global_score, "Mock scene lacks get_global_score method"
)
TestHelperClass.assert_false(has_set_gameplay_mode, "Mock scene lacks set_gameplay_mode method")
TestHelperClass.assert_false(has_set_global_score, "Mock scene lacks set_global_score method")
TestHelperClass.assert_false(has_get_global_score, "Mock scene lacks get_global_score method")
# Clean up mock scene
mock_scene.queue_free()
@@ -341,9 +284,7 @@ func test_pending_mode_management():
# This simulates what would happen in start_game_with_mode
game_manager.pending_gameplay_mode = test_mode
TestHelperClass.assert_equal(
test_mode,
game_manager.pending_gameplay_mode,
"Pending mode set correctly"
test_mode, game_manager.pending_gameplay_mode, "Pending mode set correctly"
)
# Test mode preservation during errors

View File

@@ -51,9 +51,7 @@ func setup_test_environment():
# Load Match3 scene
match3_scene = load("res://scenes/game/gameplays/Match3Gameplay.tscn")
TestHelperClass.assert_not_null(
match3_scene, "Match3 scene loads successfully"
)
TestHelperClass.assert_not_null(match3_scene, "Match3 scene loads successfully")
# Create test viewport for isolated testing
test_viewport = SubViewport.new()
@@ -64,9 +62,7 @@ func setup_test_environment():
if match3_scene:
match3_instance = match3_scene.instantiate()
test_viewport.add_child(match3_instance)
TestHelperClass.assert_not_null(
match3_instance, "Match3 instance created successfully"
)
TestHelperClass.assert_not_null(match3_instance, "Match3 instance created successfully")
# Wait for initialization
await process_frame
@@ -77,44 +73,28 @@ func test_basic_functionality():
TestHelperClass.print_step("Basic Functionality")
if not match3_instance:
TestHelperClass.assert_true(
false, "Match3 instance not available for testing"
)
TestHelperClass.assert_true(false, "Match3 instance not available for testing")
return
# Test that Match3 has expected properties
var expected_properties = [
"GRID_SIZE",
"TILE_TYPES",
"grid",
"current_state",
"selected_tile",
"cursor_position"
"GRID_SIZE", "TILE_TYPES", "grid", "current_state", "selected_tile", "cursor_position"
]
for prop in expected_properties:
TestHelperClass.assert_true(
prop in match3_instance, "Match3 has property: " + prop
)
TestHelperClass.assert_true(prop in match3_instance, "Match3 has property: " + prop)
# Test that Match3 has expected methods
var expected_methods = [
"_has_match_at",
"_check_for_matches",
"_get_match_line",
"_clear_matches"
"_has_match_at", "_check_for_matches", "_get_match_line", "_clear_matches"
]
TestHelperClass.assert_has_methods(
match3_instance, expected_methods, "Match3 gameplay methods"
)
TestHelperClass.assert_has_methods(match3_instance, expected_methods, "Match3 gameplay methods")
# Test signals
TestHelperClass.assert_true(
match3_instance.has_signal("score_changed"),
"Match3 has score_changed signal"
match3_instance.has_signal("score_changed"), "Match3 has score_changed signal"
)
TestHelperClass.assert_true(
match3_instance.has_signal("grid_state_loaded"),
"Match3 has grid_state_loaded signal"
match3_instance.has_signal("grid_state_loaded"), "Match3 has grid_state_loaded signal"
)
@@ -125,41 +105,26 @@ func test_constants_and_safety_limits():
return
# Test safety constants exist
TestHelperClass.assert_true(
"MAX_GRID_SIZE" in match3_instance, "MAX_GRID_SIZE constant exists"
)
TestHelperClass.assert_true("MAX_GRID_SIZE" in match3_instance, "MAX_GRID_SIZE constant exists")
TestHelperClass.assert_true(
"MAX_TILE_TYPES" in match3_instance, "MAX_TILE_TYPES constant exists"
)
TestHelperClass.assert_true(
"MAX_CASCADE_ITERATIONS" in match3_instance,
"MAX_CASCADE_ITERATIONS constant exists"
)
TestHelperClass.assert_true(
"MIN_GRID_SIZE" in match3_instance, "MIN_GRID_SIZE constant exists"
"MAX_CASCADE_ITERATIONS" in match3_instance, "MAX_CASCADE_ITERATIONS constant exists"
)
TestHelperClass.assert_true("MIN_GRID_SIZE" in match3_instance, "MIN_GRID_SIZE constant exists")
TestHelperClass.assert_true(
"MIN_TILE_TYPES" in match3_instance, "MIN_TILE_TYPES constant exists"
)
# Test safety limit values are reasonable
TestHelperClass.assert_equal(15, match3_instance.MAX_GRID_SIZE, "MAX_GRID_SIZE is reasonable")
TestHelperClass.assert_equal(10, match3_instance.MAX_TILE_TYPES, "MAX_TILE_TYPES is reasonable")
TestHelperClass.assert_equal(
15, match3_instance.MAX_GRID_SIZE, "MAX_GRID_SIZE is reasonable"
)
TestHelperClass.assert_equal(
10, match3_instance.MAX_TILE_TYPES, "MAX_TILE_TYPES is reasonable"
)
TestHelperClass.assert_equal(
20,
match3_instance.MAX_CASCADE_ITERATIONS,
"MAX_CASCADE_ITERATIONS prevents infinite loops"
)
TestHelperClass.assert_equal(
3, match3_instance.MIN_GRID_SIZE, "MIN_GRID_SIZE is reasonable"
)
TestHelperClass.assert_equal(
3, match3_instance.MIN_TILE_TYPES, "MIN_TILE_TYPES is reasonable"
20, match3_instance.MAX_CASCADE_ITERATIONS, "MAX_CASCADE_ITERATIONS prevents infinite loops"
)
TestHelperClass.assert_equal(3, match3_instance.MIN_GRID_SIZE, "MIN_GRID_SIZE is reasonable")
TestHelperClass.assert_equal(3, match3_instance.MIN_TILE_TYPES, "MIN_TILE_TYPES is reasonable")
# Test current values are within safety limits
TestHelperClass.assert_in_range(
@@ -183,16 +148,13 @@ func test_constants_and_safety_limits():
# Test timing constants
TestHelperClass.assert_true(
"CASCADE_WAIT_TIME" in match3_instance,
"CASCADE_WAIT_TIME constant exists"
"CASCADE_WAIT_TIME" in match3_instance, "CASCADE_WAIT_TIME constant exists"
)
TestHelperClass.assert_true(
"SWAP_ANIMATION_TIME" in match3_instance,
"SWAP_ANIMATION_TIME constant exists"
"SWAP_ANIMATION_TIME" in match3_instance, "SWAP_ANIMATION_TIME constant exists"
)
TestHelperClass.assert_true(
"TILE_DROP_WAIT_TIME" in match3_instance,
"TILE_DROP_WAIT_TIME constant exists"
"TILE_DROP_WAIT_TIME" in match3_instance, "TILE_DROP_WAIT_TIME constant exists"
)
@@ -203,12 +165,8 @@ func test_grid_initialization():
return
# Test grid structure
TestHelperClass.assert_not_null(
match3_instance.grid, "Grid array is initialized"
)
TestHelperClass.assert_true(
match3_instance.grid is Array, "Grid is Array type"
)
TestHelperClass.assert_not_null(match3_instance.grid, "Grid array is initialized")
TestHelperClass.assert_true(match3_instance.grid is Array, "Grid is Array type")
# Test grid dimensions
var expected_height = match3_instance.GRID_SIZE.y
@@ -222,9 +180,7 @@ func test_grid_initialization():
for y in range(match3_instance.grid.size()):
if y < expected_height:
TestHelperClass.assert_equal(
expected_width,
match3_instance.grid[y].size(),
"Grid row %d has correct width" % y
expected_width, match3_instance.grid[y].size(), "Grid row %d has correct width" % y
)
# Test tiles are properly instantiated
@@ -239,12 +195,10 @@ func test_grid_initialization():
if tile and is_instance_valid(tile):
valid_tile_count += 1
TestHelperClass.assert_true(
"tile_type" in tile,
"Tile at (%d,%d) has tile_type property" % [x, y]
"tile_type" in tile, "Tile at (%d,%d) has tile_type property" % [x, y]
)
TestHelperClass.assert_true(
"grid_position" in tile,
"Tile at (%d,%d) has grid_position property" % [x, y]
"grid_position" in tile, "Tile at (%d,%d) has grid_position property" % [x, y]
)
# Test tile type is within valid range
@@ -268,24 +222,15 @@ func test_grid_layout_calculation():
return
# Test tile size calculation
TestHelperClass.assert_true(match3_instance.tile_size > 0, "Tile size is positive")
TestHelperClass.assert_true(
match3_instance.tile_size > 0, "Tile size is positive"
)
TestHelperClass.assert_true(
match3_instance.tile_size <= 200,
"Tile size is reasonable (not too large)"
match3_instance.tile_size <= 200, "Tile size is reasonable (not too large)"
)
# Test grid offset
TestHelperClass.assert_not_null(
match3_instance.grid_offset, "Grid offset is set"
)
TestHelperClass.assert_true(
match3_instance.grid_offset.x >= 0, "Grid offset X is non-negative"
)
TestHelperClass.assert_true(
match3_instance.grid_offset.y >= 0, "Grid offset Y is non-negative"
)
TestHelperClass.assert_not_null(match3_instance.grid_offset, "Grid offset is set")
TestHelperClass.assert_true(match3_instance.grid_offset.x >= 0, "Grid offset X is non-negative")
TestHelperClass.assert_true(match3_instance.grid_offset.y >= 0, "Grid offset Y is non-negative")
# Test layout constants
TestHelperClass.assert_equal(
@@ -297,9 +242,7 @@ func test_grid_layout_calculation():
TestHelperClass.assert_equal(
50.0, match3_instance.GRID_LEFT_MARGIN, "Grid left margin constant"
)
TestHelperClass.assert_equal(
50.0, match3_instance.GRID_TOP_MARGIN, "Grid top margin constant"
)
TestHelperClass.assert_equal(50.0, match3_instance.GRID_TOP_MARGIN, "Grid top margin constant")
func test_state_management():
@@ -310,30 +253,23 @@ func test_state_management():
# Test GameState enum exists and has expected values
var game_state_class = match3_instance.get_script().get_global_class()
TestHelperClass.assert_true(
"GameState" in match3_instance, "GameState enum accessible"
)
TestHelperClass.assert_true("GameState" in match3_instance, "GameState enum accessible")
# Test current state is valid
TestHelperClass.assert_not_null(
match3_instance.current_state, "Current state is set"
)
TestHelperClass.assert_not_null(match3_instance.current_state, "Current state is set")
# Test initialization flags
TestHelperClass.assert_true(
"grid_initialized" in match3_instance, "Grid initialized flag exists"
)
TestHelperClass.assert_true(
match3_instance.grid_initialized, "Grid is marked as initialized"
)
TestHelperClass.assert_true(match3_instance.grid_initialized, "Grid is marked as initialized")
# Test instance ID for debugging
TestHelperClass.assert_true(
"instance_id" in match3_instance, "Instance ID exists for debugging"
)
TestHelperClass.assert_true(
match3_instance.instance_id.begins_with("Match3_"),
"Instance ID has correct format"
match3_instance.instance_id.begins_with("Match3_"), "Instance ID has correct format"
)
@@ -345,16 +281,13 @@ func test_match_detection():
# Test match detection methods exist and can be called safely
TestHelperClass.assert_true(
match3_instance.has_method("_has_match_at"),
"_has_match_at method exists"
match3_instance.has_method("_has_match_at"), "_has_match_at method exists"
)
TestHelperClass.assert_true(
match3_instance.has_method("_check_for_matches"),
"_check_for_matches method exists"
match3_instance.has_method("_check_for_matches"), "_check_for_matches method exists"
)
TestHelperClass.assert_true(
match3_instance.has_method("_get_match_line"),
"_get_match_line method exists"
match3_instance.has_method("_get_match_line"), "_get_match_line method exists"
)
# Test boundary checking with invalid positions
@@ -377,10 +310,7 @@ func test_match_detection():
)
TestHelperClass.assert_true(
is_invalid,
(
"Invalid position (%d,%d) is correctly identified as invalid"
% [pos.x, pos.y]
)
"Invalid position (%d,%d) is correctly identified as invalid" % [pos.x, pos.y]
)
# Test valid positions through public interface
@@ -394,8 +324,7 @@ func test_match_detection():
and pos.y < match3_instance.GRID_SIZE.y
)
TestHelperClass.assert_true(
is_valid,
"Valid position (%d,%d) is within grid bounds" % [x, y]
is_valid, "Valid position (%d,%d) is within grid bounds" % [x, y]
)
@@ -410,14 +339,12 @@ func test_scoring_system():
# Test that the match3 instance can handle scoring (indirectly through clearing matches)
TestHelperClass.assert_true(
match3_instance.has_method("_clear_matches"),
"Scoring system method exists"
match3_instance.has_method("_clear_matches"), "Scoring system method exists"
)
# Test that score_changed signal exists
TestHelperClass.assert_true(
match3_instance.has_signal("score_changed"),
"Score changed signal exists"
match3_instance.has_signal("score_changed"), "Score changed signal exists"
)
# Test scoring formula logic (based on the documented formula)
@@ -433,9 +360,7 @@ func test_scoring_system():
calculated_score = match_size + max(0, match_size - 2)
TestHelperClass.assert_equal(
expected_score,
calculated_score,
"Scoring formula correct for %d gems" % match_size
expected_score, calculated_score, "Scoring formula correct for %d gems" % match_size
)
@@ -450,26 +375,22 @@ func test_input_validation():
match3_instance.cursor_position, "Cursor position is initialized"
)
TestHelperClass.assert_true(
match3_instance.cursor_position is Vector2i,
"Cursor position is Vector2i type"
match3_instance.cursor_position is Vector2i, "Cursor position is Vector2i type"
)
# Test keyboard navigation flag
TestHelperClass.assert_true(
"keyboard_navigation_enabled" in match3_instance,
"Keyboard navigation flag exists"
"keyboard_navigation_enabled" in match3_instance, "Keyboard navigation flag exists"
)
TestHelperClass.assert_true(
match3_instance.keyboard_navigation_enabled is bool,
"Keyboard navigation flag is boolean"
match3_instance.keyboard_navigation_enabled is bool, "Keyboard navigation flag is boolean"
)
# Test selected tile safety
# selected_tile can be null initially, which is valid
if match3_instance.selected_tile:
TestHelperClass.assert_true(
is_instance_valid(match3_instance.selected_tile),
"Selected tile is valid if not null"
is_instance_valid(match3_instance.selected_tile), "Selected tile is valid if not null"
)
@@ -491,25 +412,20 @@ func test_memory_safety():
var tile = match3_instance.grid[y][x]
if tile:
TestHelperClass.assert_true(
is_instance_valid(tile),
"Grid tile at (%d,%d) is valid instance" % [x, y]
is_instance_valid(tile), "Grid tile at (%d,%d) is valid instance" % [x, y]
)
TestHelperClass.assert_true(
tile.get_parent() == match3_instance,
"Tile properly parented to Match3"
tile.get_parent() == match3_instance, "Tile properly parented to Match3"
)
# Test position validation
TestHelperClass.assert_true(
match3_instance.has_method("_is_valid_grid_position"),
"Position validation method exists"
match3_instance.has_method("_is_valid_grid_position"), "Position validation method exists"
)
# Test safe tile access patterns exist
# The Match3 code uses comprehensive bounds checking and null validation
TestHelperClass.assert_true(
true, "Memory safety patterns implemented in Match3 code"
)
TestHelperClass.assert_true(true, "Memory safety patterns implemented in Match3 code")
func test_performance_requirements():
@@ -533,16 +449,13 @@ func test_performance_requirements():
# Test timing constants are reasonable for 60fps gameplay
TestHelperClass.assert_true(
match3_instance.CASCADE_WAIT_TIME >= 0.05,
"Cascade wait time allows for smooth animation"
match3_instance.CASCADE_WAIT_TIME >= 0.05, "Cascade wait time allows for smooth animation"
)
TestHelperClass.assert_true(
match3_instance.SWAP_ANIMATION_TIME <= 0.5,
"Swap animation time is responsive"
match3_instance.SWAP_ANIMATION_TIME <= 0.5, "Swap animation time is responsive"
)
TestHelperClass.assert_true(
match3_instance.TILE_DROP_WAIT_TIME <= 0.3,
"Tile drop wait time is responsive"
match3_instance.TILE_DROP_WAIT_TIME <= 0.3, "Tile drop wait time is responsive"
)
# Test grid initialization performance

View File

@@ -58,9 +58,7 @@ func test_migration_compatibility():
# The checksums should be different (old system broken)
TestHelperClass.assert_not_equal(
old_checksum,
new_checksum,
"Old and new checksum formats should be different"
old_checksum, new_checksum, "Old and new checksum formats should be different"
)
print("Old checksum: %s" % old_checksum)
print("New checksum: %s" % new_checksum)
@@ -87,13 +85,9 @@ func test_migration_compatibility():
print("Consistent checksum: %s" % first_checksum)
TestHelperClass.print_step("Migration Strategy Verification")
TestHelperClass.assert_true(
true, "Version-based checksum handling implemented"
)
TestHelperClass.assert_true(true, "Version-based checksum handling implemented")
print("✓ Files without _checksum: Allow (backward compatibility)")
print(
"✓ Files with version < current: Recalculate checksum after migration"
)
print("✓ Files with version < current: Recalculate checksum after migration")
print("✓ Files with current version: Use new checksum validation")

View File

@@ -46,9 +46,7 @@ func test_scene_discovery():
for directory in scene_directories:
discover_scenes_in_directory(directory)
TestHelperClass.assert_true(
discovered_scenes.size() > 0, "Found scenes in project"
)
TestHelperClass.assert_true(discovered_scenes.size() > 0, "Found scenes in project")
print("Discovered %d scene files" % discovered_scenes.size())
# List discovered scenes for reference
@@ -91,31 +89,23 @@ func validate_scene_loading(scene_path: String):
# Check if resource exists
if not ResourceLoader.exists(scene_path):
validation_results[scene_path] = "Resource does not exist"
TestHelperClass.assert_false(
true, "%s - Resource does not exist" % scene_name
)
TestHelperClass.assert_false(true, "%s - Resource does not exist" % scene_name)
return
# Attempt to load the scene
var packed_scene = load(scene_path)
if not packed_scene:
validation_results[scene_path] = "Failed to load scene"
TestHelperClass.assert_false(
true, "%s - Failed to load scene" % scene_name
)
TestHelperClass.assert_false(true, "%s - Failed to load scene" % scene_name)
return
if not packed_scene is PackedScene:
validation_results[scene_path] = "Resource is not a PackedScene"
TestHelperClass.assert_false(
true, "%s - Resource is not a PackedScene" % scene_name
)
TestHelperClass.assert_false(true, "%s - Resource is not a PackedScene" % scene_name)
return
validation_results[scene_path] = "Loading successful"
TestHelperClass.assert_true(
true, "%s - Scene loads successfully" % scene_name
)
TestHelperClass.assert_true(true, "%s - Scene loads successfully" % scene_name)
func test_scene_instantiation():
@@ -137,15 +127,12 @@ func validate_scene_instantiation(scene_path: String):
var scene_instance = packed_scene.instantiate()
if not scene_instance:
validation_results[scene_path] = "Failed to instantiate scene"
TestHelperClass.assert_false(
true, "%s - Failed to instantiate scene" % scene_name
)
TestHelperClass.assert_false(true, "%s - Failed to instantiate scene" % scene_name)
return
# Validate the instance
TestHelperClass.assert_not_null(
scene_instance,
"%s - Scene instantiation creates valid node" % scene_name
scene_instance, "%s - Scene instantiation creates valid node" % scene_name
)
# Clean up the instance
@@ -173,15 +160,10 @@ func test_critical_scenes():
TestHelperClass.assert_equal(
"Full validation successful",
status,
(
"Critical scene %s must pass all validation"
% scene_path.get_file()
)
"Critical scene %s must pass all validation" % scene_path.get_file()
)
else:
TestHelperClass.assert_false(
true, "Critical scene missing: %s" % scene_path
)
TestHelperClass.assert_false(true, "Critical scene missing: %s" % scene_path)
func print_validation_summary():
@@ -193,10 +175,7 @@ func print_validation_summary():
for scene_path in discovered_scenes:
var status = validation_results.get(scene_path, "Not tested")
if (
status == "Full validation successful"
or status == "Loading successful"
):
if status == "Full validation successful" or status == "Loading successful":
successful_scenes += 1
else:
failed_scenes += 1

View File

@@ -64,35 +64,23 @@ func test_basic_functionality():
# Test that SettingsManager has expected methods
var expected_methods = [
"get_setting",
"set_setting",
"save_settings",
"load_settings",
"reset_settings_to_defaults"
"get_setting", "set_setting", "save_settings", "load_settings", "reset_settings_to_defaults"
]
TestHelperClass.assert_has_methods(
settings_manager, expected_methods, "SettingsManager methods"
)
# Test default settings structure
var expected_defaults = [
"master_volume", "music_volume", "sfx_volume", "language"
]
var expected_defaults = ["master_volume", "music_volume", "sfx_volume", "language"]
for key in expected_defaults:
TestHelperClass.assert_has_key(
settings_manager.default_settings,
key,
"Default setting key: " + key
settings_manager.default_settings, key, "Default setting key: " + key
)
# Test getting settings
var master_volume = settings_manager.get_setting("master_volume")
TestHelperClass.assert_not_null(
master_volume, "Can get master_volume setting"
)
TestHelperClass.assert_true(
master_volume is float, "master_volume is float type"
)
TestHelperClass.assert_not_null(master_volume, "Can get master_volume setting")
TestHelperClass.assert_true(master_volume is float, "master_volume is float type")
func test_input_validation_security():
@@ -100,56 +88,38 @@ func test_input_validation_security():
# Test NaN validation
var nan_result = settings_manager.set_setting("master_volume", NAN)
TestHelperClass.assert_false(
nan_result, "NaN values rejected for volume settings"
)
TestHelperClass.assert_false(nan_result, "NaN values rejected for volume settings")
# Test Infinity validation
var inf_result = settings_manager.set_setting("master_volume", INF)
TestHelperClass.assert_false(
inf_result, "Infinity values rejected for volume settings"
)
TestHelperClass.assert_false(inf_result, "Infinity values rejected for volume settings")
# Test negative infinity validation
var neg_inf_result = settings_manager.set_setting("master_volume", -INF)
TestHelperClass.assert_false(
neg_inf_result, "Negative infinity values rejected"
)
TestHelperClass.assert_false(neg_inf_result, "Negative infinity values rejected")
# Test range validation for volumes
var negative_volume = settings_manager.set_setting("master_volume", -0.5)
TestHelperClass.assert_false(
negative_volume, "Negative volume values rejected"
)
TestHelperClass.assert_false(negative_volume, "Negative volume values rejected")
var excessive_volume = settings_manager.set_setting("master_volume", 1.5)
TestHelperClass.assert_false(
excessive_volume, "Volume values > 1.0 rejected"
)
TestHelperClass.assert_false(excessive_volume, "Volume values > 1.0 rejected")
# Test valid volume range
var valid_volume = settings_manager.set_setting("master_volume", 0.5)
TestHelperClass.assert_true(valid_volume, "Valid volume values accepted")
TestHelperClass.assert_equal(
0.5,
settings_manager.get_setting("master_volume"),
"Volume value set correctly"
0.5, settings_manager.get_setting("master_volume"), "Volume value set correctly"
)
# Test string length validation for language
var long_language = "a".repeat(20) # Exceeds MAX_SETTING_STRING_LENGTH
var long_lang_result = settings_manager.set_setting(
"language", long_language
)
TestHelperClass.assert_false(
long_lang_result, "Excessively long language codes rejected"
)
var long_lang_result = settings_manager.set_setting("language", long_language)
TestHelperClass.assert_false(long_lang_result, "Excessively long language codes rejected")
# Test invalid characters in language code
var invalid_chars = settings_manager.set_setting("language", "en<script>")
TestHelperClass.assert_false(
invalid_chars, "Language codes with invalid characters rejected"
)
TestHelperClass.assert_false(invalid_chars, "Language codes with invalid characters rejected")
# Test valid language code
var valid_lang = settings_manager.set_setting("language", "en")
@@ -171,14 +141,10 @@ func test_file_io_security():
# Test loading with backup scenario
settings_manager.load_settings()
TestHelperClass.assert_not_null(
settings_manager.settings, "Settings loaded successfully"
)
TestHelperClass.assert_not_null(settings_manager.settings, "Settings loaded successfully")
# Test that settings file exists after save
TestHelperClass.assert_file_exists(
"user://settings.cfg", "Settings file created after save"
)
TestHelperClass.assert_file_exists("user://settings.cfg", "Settings file created after save")
func test_json_parsing_security():
@@ -191,9 +157,7 @@ func test_json_parsing_security():
temp_files.append(invalid_json_path)
# Create oversized JSON file
var large_json_content = (
'{"languages": {"' + "x".repeat(70000) + '": "test"}}'
)
var large_json_content = '{"languages": {"' + "x".repeat(70000) + '": "test"}}'
var oversized_json_path = TestHelper.create_temp_file(
"oversized_languages.json", large_json_content
)
@@ -214,15 +178,11 @@ func test_language_validation():
var supported_langs = ["en", "ru"]
for lang in supported_langs:
var result = settings_manager.set_setting("language", lang)
TestHelperClass.assert_true(
result, "Supported language accepted: " + lang
)
TestHelperClass.assert_true(result, "Supported language accepted: " + lang)
# Test unsupported language
var unsupported_result = settings_manager.set_setting("language", "xyz")
TestHelperClass.assert_false(
unsupported_result, "Unsupported language rejected"
)
TestHelperClass.assert_false(unsupported_result, "Unsupported language rejected")
# Test empty language
var empty_result = settings_manager.set_setting("language", "")
@@ -241,32 +201,26 @@ func test_volume_validation():
for setting in volume_settings:
# Test boundary values
TestHelperClass.assert_true(
settings_manager.set_setting(setting, 0.0),
"Volume 0.0 accepted for " + setting
settings_manager.set_setting(setting, 0.0), "Volume 0.0 accepted for " + setting
)
TestHelperClass.assert_true(
settings_manager.set_setting(setting, 1.0),
"Volume 1.0 accepted for " + setting
settings_manager.set_setting(setting, 1.0), "Volume 1.0 accepted for " + setting
)
# Test out of range values
TestHelperClass.assert_false(
settings_manager.set_setting(setting, -0.1),
"Negative volume rejected for " + setting
settings_manager.set_setting(setting, -0.1), "Negative volume rejected for " + setting
)
TestHelperClass.assert_false(
settings_manager.set_setting(setting, 1.1),
"Volume > 1.0 rejected for " + setting
settings_manager.set_setting(setting, 1.1), "Volume > 1.0 rejected for " + setting
)
# Test invalid types
TestHelperClass.assert_false(
settings_manager.set_setting(setting, "0.5"),
"String volume rejected for " + setting
settings_manager.set_setting(setting, "0.5"), "String volume rejected for " + setting
)
TestHelperClass.assert_false(
settings_manager.set_setting(setting, null),
"Null volume rejected for " + setting
settings_manager.set_setting(setting, null), "Null volume rejected for " + setting
)
@@ -274,12 +228,8 @@ func test_error_handling_and_recovery():
TestHelperClass.print_step("Error Handling and Recovery")
# Test unknown setting key
var unknown_result = settings_manager.set_setting(
"unknown_setting", "value"
)
TestHelperClass.assert_false(
unknown_result, "Unknown setting keys rejected"
)
var unknown_result = settings_manager.set_setting("unknown_setting", "value")
TestHelperClass.assert_false(unknown_result, "Unknown setting keys rejected")
# Test recovery from corrupted settings
# Save current state
@@ -298,18 +248,13 @@ func test_error_handling_and_recovery():
# Test fallback language loading
TestHelperClass.assert_true(
settings_manager.languages_data.has("languages"),
"Fallback languages loaded"
settings_manager.languages_data.has("languages"), "Fallback languages loaded"
)
TestHelperClass.assert_has_key(
settings_manager.languages_data["languages"],
"en",
"English fallback language available"
settings_manager.languages_data["languages"], "en", "English fallback language available"
)
TestHelperClass.assert_has_key(
settings_manager.languages_data["languages"],
"ru",
"Russian fallback language available"
settings_manager.languages_data["languages"], "ru", "Russian fallback language available"
)
@@ -336,9 +281,7 @@ func test_reset_functionality():
)
# Test that reset saves automatically
TestHelperClass.assert_file_exists(
"user://settings.cfg", "Settings file exists after reset"
)
TestHelperClass.assert_file_exists("user://settings.cfg", "Settings file exists after reset")
func test_performance_benchmarks():
@@ -347,24 +290,18 @@ func test_performance_benchmarks():
# Test settings load performance
TestHelperClass.start_performance_test("load_settings")
settings_manager.load_settings()
TestHelperClass.end_performance_test(
"load_settings", 100.0, "Settings load within 100ms"
)
TestHelperClass.end_performance_test("load_settings", 100.0, "Settings load within 100ms")
# Test settings save performance
TestHelperClass.start_performance_test("save_settings")
settings_manager.save_settings()
TestHelperClass.end_performance_test(
"save_settings", 50.0, "Settings save within 50ms"
)
TestHelperClass.end_performance_test("save_settings", 50.0, "Settings save within 50ms")
# Test validation performance
TestHelperClass.start_performance_test("validation")
for i in range(100):
settings_manager.set_setting("master_volume", 0.5)
TestHelperClass.end_performance_test(
"validation", 50.0, "100 validations within 50ms"
)
TestHelperClass.end_performance_test("validation", 50.0, "100 validations within 50ms")
func cleanup_tests():

View File

@@ -62,9 +62,7 @@ func setup_test_environment():
if tile_scene:
tile_instance = tile_scene.instantiate()
test_viewport.add_child(tile_instance)
TestHelperClass.assert_not_null(
tile_instance, "Tile instance created successfully"
)
TestHelperClass.assert_not_null(tile_instance, "Tile instance created successfully")
# Wait for initialization
await process_frame
@@ -75,9 +73,7 @@ func test_basic_functionality():
TestHelperClass.print_step("Basic Functionality")
if not tile_instance:
TestHelperClass.assert_true(
false, "Tile instance not available for testing"
)
TestHelperClass.assert_true(false, "Tile instance not available for testing")
return
# Test that Tile has expected properties
@@ -90,9 +86,7 @@ func test_basic_functionality():
"active_gem_types"
]
for prop in expected_properties:
TestHelperClass.assert_true(
prop in tile_instance, "Tile has property: " + prop
)
TestHelperClass.assert_true(prop in tile_instance, "Tile has property: " + prop)
# Test that Tile has expected methods
var expected_methods = [
@@ -102,28 +96,19 @@ func test_basic_functionality():
"remove_gem_type",
"force_reset_visual_state"
]
TestHelperClass.assert_has_methods(
tile_instance, expected_methods, "Tile component methods"
)
TestHelperClass.assert_has_methods(tile_instance, expected_methods, "Tile component methods")
# Test signals
TestHelperClass.assert_true(
tile_instance.has_signal("tile_selected"),
"Tile has tile_selected signal"
tile_instance.has_signal("tile_selected"), "Tile has tile_selected signal"
)
# Test sprite reference
TestHelperClass.assert_not_null(
tile_instance.sprite, "Sprite node is available"
)
TestHelperClass.assert_true(
tile_instance.sprite is Sprite2D, "Sprite is Sprite2D type"
)
TestHelperClass.assert_not_null(tile_instance.sprite, "Sprite node is available")
TestHelperClass.assert_true(tile_instance.sprite is Sprite2D, "Sprite is Sprite2D type")
# Test group membership
TestHelperClass.assert_true(
tile_instance.is_in_group("tiles"), "Tile is in 'tiles' group"
)
TestHelperClass.assert_true(tile_instance.is_in_group("tiles"), "Tile is in 'tiles' group")
func test_tile_constants():
@@ -133,33 +118,22 @@ func test_tile_constants():
return
# Test TILE_SIZE constant
TestHelperClass.assert_equal(
48, tile_instance.TILE_SIZE, "TILE_SIZE constant is correct"
)
TestHelperClass.assert_equal(48, tile_instance.TILE_SIZE, "TILE_SIZE constant is correct")
# Test all_gem_textures array
TestHelperClass.assert_not_null(
tile_instance.all_gem_textures, "All gem textures array exists"
)
TestHelperClass.assert_not_null(tile_instance.all_gem_textures, "All gem textures array exists")
TestHelperClass.assert_true(
tile_instance.all_gem_textures is Array,
"All gem textures is Array type"
tile_instance.all_gem_textures is Array, "All gem textures is Array type"
)
TestHelperClass.assert_equal(
8,
tile_instance.all_gem_textures.size(),
"All gem textures has expected count"
8, tile_instance.all_gem_textures.size(), "All gem textures has expected count"
)
# Test that all gem textures are valid
for i in range(tile_instance.all_gem_textures.size()):
var texture = tile_instance.all_gem_textures[i]
TestHelperClass.assert_not_null(
texture, "Gem texture %d is not null" % i
)
TestHelperClass.assert_true(
texture is Texture2D, "Gem texture %d is Texture2D type" % i
)
TestHelperClass.assert_not_null(texture, "Gem texture %d is not null" % i)
TestHelperClass.assert_true(texture is Texture2D, "Gem texture %d is Texture2D type" % i)
func test_texture_management():
@@ -173,12 +147,10 @@ func test_texture_management():
tile_instance.active_gem_types, "Active gem types is initialized"
)
TestHelperClass.assert_true(
tile_instance.active_gem_types is Array,
"Active gem types is Array type"
tile_instance.active_gem_types is Array, "Active gem types is Array type"
)
TestHelperClass.assert_true(
tile_instance.active_gem_types.size() > 0,
"Active gem types has content"
tile_instance.active_gem_types.size() > 0, "Active gem types has content"
)
# Test texture assignment for valid tile types
@@ -192,8 +164,7 @@ func test_texture_management():
if tile_instance.sprite:
TestHelperClass.assert_not_null(
tile_instance.sprite.texture,
"Sprite texture assigned for type %d" % i
tile_instance.sprite.texture, "Sprite texture assigned for type %d" % i
)
# Restore original type
@@ -213,60 +184,42 @@ func test_gem_type_management():
var test_gems = [0, 1, 2]
tile_instance.set_active_gem_types(test_gems)
TestHelperClass.assert_equal(
3,
tile_instance.get_active_gem_count(),
"Active gem count set correctly"
3, tile_instance.get_active_gem_count(), "Active gem count set correctly"
)
# Test add_gem_type
var add_result = tile_instance.add_gem_type(3)
TestHelperClass.assert_true(add_result, "Valid gem type added successfully")
TestHelperClass.assert_equal(
4,
tile_instance.get_active_gem_count(),
"Gem count increased after addition"
4, tile_instance.get_active_gem_count(), "Gem count increased after addition"
)
# Test adding duplicate gem type
var duplicate_result = tile_instance.add_gem_type(3)
TestHelperClass.assert_false(
duplicate_result, "Duplicate gem type addition rejected"
)
TestHelperClass.assert_false(duplicate_result, "Duplicate gem type addition rejected")
TestHelperClass.assert_equal(
4,
tile_instance.get_active_gem_count(),
"Gem count unchanged after duplicate"
4, tile_instance.get_active_gem_count(), "Gem count unchanged after duplicate"
)
# Test add_gem_type with invalid index
var invalid_add = tile_instance.add_gem_type(99)
TestHelperClass.assert_false(
invalid_add, "Invalid gem index addition rejected"
)
TestHelperClass.assert_false(invalid_add, "Invalid gem index addition rejected")
# Test remove_gem_type
var remove_result = tile_instance.remove_gem_type(3)
TestHelperClass.assert_true(
remove_result, "Valid gem type removed successfully"
)
TestHelperClass.assert_true(remove_result, "Valid gem type removed successfully")
TestHelperClass.assert_equal(
3,
tile_instance.get_active_gem_count(),
"Gem count decreased after removal"
3, tile_instance.get_active_gem_count(), "Gem count decreased after removal"
)
# Test removing non-existent gem type
var nonexistent_remove = tile_instance.remove_gem_type(99)
TestHelperClass.assert_false(
nonexistent_remove, "Non-existent gem type removal rejected"
)
TestHelperClass.assert_false(nonexistent_remove, "Non-existent gem type removal rejected")
# Test minimum gem types protection
tile_instance.set_active_gem_types([0, 1]) # Set to minimum
var protected_remove = tile_instance.remove_gem_type(0)
TestHelperClass.assert_false(
protected_remove, "Minimum gem types protection active"
)
TestHelperClass.assert_false(protected_remove, "Minimum gem types protection active")
TestHelperClass.assert_equal(
2, tile_instance.get_active_gem_count(), "Minimum gem count preserved"
)
@@ -287,9 +240,7 @@ func test_visual_feedback_system():
# Test selection visual feedback
tile_instance.is_selected = true
TestHelperClass.assert_true(
tile_instance.is_selected, "Selection state set correctly"
)
TestHelperClass.assert_true(tile_instance.is_selected, "Selection state set correctly")
# Wait for potential animation
await process_frame
@@ -305,29 +256,21 @@ func test_visual_feedback_system():
# Test highlight visual feedback
tile_instance.is_selected = false
tile_instance.is_highlighted = true
TestHelperClass.assert_true(
tile_instance.is_highlighted, "Highlight state set correctly"
)
TestHelperClass.assert_true(tile_instance.is_highlighted, "Highlight state set correctly")
# Wait for potential animation
await process_frame
# Test normal state
tile_instance.is_highlighted = false
TestHelperClass.assert_false(
tile_instance.is_highlighted, "Normal state restored"
)
TestHelperClass.assert_false(tile_instance.is_highlighted, "Normal state restored")
# Test force reset
tile_instance.is_selected = true
tile_instance.is_highlighted = true
tile_instance.force_reset_visual_state()
TestHelperClass.assert_false(
tile_instance.is_selected, "Force reset clears selection"
)
TestHelperClass.assert_false(
tile_instance.is_highlighted, "Force reset clears highlight"
)
TestHelperClass.assert_false(tile_instance.is_selected, "Force reset clears selection")
TestHelperClass.assert_false(tile_instance.is_highlighted, "Force reset clears highlight")
# Restore original state
tile_instance.is_selected = original_selected
@@ -341,16 +284,12 @@ func test_state_management():
return
# Test initial state
TestHelperClass.assert_true(tile_instance.tile_type >= 0, "Initial tile type is non-negative")
TestHelperClass.assert_true(
tile_instance.tile_type >= 0, "Initial tile type is non-negative"
tile_instance.grid_position is Vector2i, "Grid position is Vector2i type"
)
TestHelperClass.assert_true(
tile_instance.grid_position is Vector2i,
"Grid position is Vector2i type"
)
TestHelperClass.assert_true(
tile_instance.original_scale is Vector2,
"Original scale is Vector2 type"
tile_instance.original_scale is Vector2, "Original scale is Vector2 type"
)
# Test tile type bounds checking
@@ -385,23 +324,20 @@ func test_input_validation():
tile_instance.set_active_gem_types([])
# Should fall back to defaults or maintain previous state
TestHelperClass.assert_true(
tile_instance.get_active_gem_count() > 0,
"Empty gem array handled gracefully"
tile_instance.get_active_gem_count() > 0, "Empty gem array handled gracefully"
)
# Test null gem types array
tile_instance.set_active_gem_types(null)
TestHelperClass.assert_true(
tile_instance.get_active_gem_count() > 0,
"Null gem array handled gracefully"
tile_instance.get_active_gem_count() > 0, "Null gem array handled gracefully"
)
# Test invalid gem indices in array
tile_instance.set_active_gem_types([0, 1, 99, 2]) # 99 is invalid
# Should use fallback or filter invalid indices
TestHelperClass.assert_true(
tile_instance.get_active_gem_count() > 0,
"Invalid gem indices handled gracefully"
tile_instance.get_active_gem_count() > 0, "Invalid gem indices handled gracefully"
)
# Test negative gem indices
@@ -409,9 +345,7 @@ func test_input_validation():
TestHelperClass.assert_false(negative_add, "Negative gem index rejected")
# Test out-of-bounds gem indices
var oob_add = tile_instance.add_gem_type(
tile_instance.all_gem_textures.size()
)
var oob_add = tile_instance.add_gem_type(tile_instance.all_gem_textures.size())
TestHelperClass.assert_false(oob_add, "Out-of-bounds gem index rejected")
# Restore original state
@@ -425,15 +359,9 @@ func test_scaling_and_sizing():
return
# Test original scale calculation
TestHelperClass.assert_not_null(
tile_instance.original_scale, "Original scale is calculated"
)
TestHelperClass.assert_true(
tile_instance.original_scale.x > 0, "Original scale X is positive"
)
TestHelperClass.assert_true(
tile_instance.original_scale.y > 0, "Original scale Y is positive"
)
TestHelperClass.assert_not_null(tile_instance.original_scale, "Original scale is calculated")
TestHelperClass.assert_true(tile_instance.original_scale.x > 0, "Original scale X is positive")
TestHelperClass.assert_true(tile_instance.original_scale.y > 0, "Original scale Y is positive")
# Test that tile size is respected
if tile_instance.sprite and tile_instance.sprite.texture:
@@ -441,14 +369,11 @@ func test_scaling_and_sizing():
var scaled_size = texture_size * tile_instance.original_scale
var max_dimension = max(scaled_size.x, scaled_size.y)
TestHelperClass.assert_true(
max_dimension <= tile_instance.TILE_SIZE + 1,
"Scaled tile fits within TILE_SIZE"
max_dimension <= tile_instance.TILE_SIZE + 1, "Scaled tile fits within TILE_SIZE"
)
# Test scale animation for visual feedback
var original_scale = (
tile_instance.sprite.scale if tile_instance.sprite else Vector2.ONE
)
var original_scale = tile_instance.sprite.scale if tile_instance.sprite else Vector2.ONE
# Test selection scaling
tile_instance.is_selected = true
@@ -458,8 +383,7 @@ func test_scaling_and_sizing():
if tile_instance.sprite:
var selected_scale = tile_instance.sprite.scale
TestHelperClass.assert_true(
selected_scale.x >= original_scale.x,
"Selected tile scale is larger or equal"
selected_scale.x >= original_scale.x, "Selected tile scale is larger or equal"
)
# Reset to normal
@@ -496,8 +420,7 @@ func test_memory_safety():
# Test gem types array integrity
TestHelperClass.assert_true(
tile_instance.active_gem_types is Array,
"Active gem types maintains Array type"
tile_instance.active_gem_types is Array, "Active gem types maintains Array type"
)
# Test that gem indices are within bounds
@@ -521,16 +444,12 @@ func test_error_handling():
# Test that tile type setting handles null sprite gracefully
tile_instance.tile_type = 0 # Use public property instead
TestHelperClass.assert_true(
true, "Tile type setting handles null sprite gracefully"
)
TestHelperClass.assert_true(true, "Tile type setting handles null sprite gracefully")
# Test that scaling handles null sprite gracefully
# Force redraw to trigger scaling logic
tile_instance.queue_redraw()
TestHelperClass.assert_true(
true, "Sprite scaling handles null sprite gracefully"
)
TestHelperClass.assert_true(true, "Sprite scaling handles null sprite gracefully")
# Restore sprite
tile_instance.sprite = backup_sprite
@@ -554,10 +473,7 @@ func test_error_handling():
tile_instance.set_active_gem_types(large_gem_types)
# Should fall back to safe defaults
TestHelperClass.assert_true(
(
tile_instance.get_active_gem_count()
<= tile_instance.all_gem_textures.size()
),
tile_instance.get_active_gem_count() <= tile_instance.all_gem_textures.size(),
"Large gem array handled safely"
)

View File

@@ -55,9 +55,7 @@ func setup_test_environment():
# Load ValueStepper scene
stepper_scene = load("res://scenes/ui/components/ValueStepper.tscn")
TestHelperClass.assert_not_null(
stepper_scene, "ValueStepper scene loads successfully"
)
TestHelperClass.assert_not_null(stepper_scene, "ValueStepper scene loads successfully")
# Create test viewport for isolated testing
test_viewport = SubViewport.new()
@@ -81,23 +79,15 @@ func test_basic_functionality():
TestHelperClass.print_step("Basic Functionality")
if not stepper_instance:
TestHelperClass.assert_true(
false, "ValueStepper instance not available for testing"
)
TestHelperClass.assert_true(false, "ValueStepper instance not available for testing")
return
# Test that ValueStepper has expected properties
var expected_properties = [
"data_source",
"custom_format_function",
"values",
"display_names",
"current_index"
"data_source", "custom_format_function", "values", "display_names", "current_index"
]
for prop in expected_properties:
TestHelperClass.assert_true(
prop in stepper_instance, "ValueStepper has property: " + prop
)
TestHelperClass.assert_true(prop in stepper_instance, "ValueStepper has property: " + prop)
# Test that ValueStepper has expected methods
var expected_methods = [
@@ -115,17 +105,12 @@ func test_basic_functionality():
# Test signals
TestHelperClass.assert_true(
stepper_instance.has_signal("value_changed"),
"ValueStepper has value_changed signal"
stepper_instance.has_signal("value_changed"), "ValueStepper has value_changed signal"
)
# Test UI components
TestHelperClass.assert_not_null(
stepper_instance.left_button, "Left button is available"
)
TestHelperClass.assert_not_null(
stepper_instance.right_button, "Right button is available"
)
TestHelperClass.assert_not_null(stepper_instance.left_button, "Left button is available")
TestHelperClass.assert_not_null(stepper_instance.right_button, "Right button is available")
TestHelperClass.assert_not_null(
stepper_instance.value_display, "Value display label is available"
)
@@ -150,33 +135,24 @@ func test_data_source_loading():
# Test default language data source
TestHelperClass.assert_equal(
"language",
stepper_instance.data_source,
"Default data source is language"
"language", stepper_instance.data_source, "Default data source is language"
)
# Test that values are loaded
TestHelperClass.assert_not_null(
stepper_instance.values, "Values array is initialized"
)
TestHelperClass.assert_not_null(stepper_instance.values, "Values array is initialized")
TestHelperClass.assert_not_null(
stepper_instance.display_names, "Display names array is initialized"
)
TestHelperClass.assert_true(
stepper_instance.values is Array, "Values is Array type"
)
TestHelperClass.assert_true(stepper_instance.values is Array, "Values is Array type")
TestHelperClass.assert_true(
stepper_instance.display_names is Array, "Display names is Array type"
)
# Test that language data is loaded correctly
if stepper_instance.data_source == "language":
TestHelperClass.assert_true(stepper_instance.values.size() > 0, "Language values loaded")
TestHelperClass.assert_true(
stepper_instance.values.size() > 0, "Language values loaded"
)
TestHelperClass.assert_true(
stepper_instance.display_names.size() > 0,
"Language display names loaded"
stepper_instance.display_names.size() > 0, "Language display names loaded"
)
TestHelperClass.assert_equal(
stepper_instance.values.size(),
@@ -185,9 +161,7 @@ func test_data_source_loading():
)
# Test that current language is properly selected
var current_lang = root.get_node("SettingsManager").get_setting(
"language"
)
var current_lang = root.get_node("SettingsManager").get_setting("language")
var expected_index = stepper_instance.values.find(current_lang)
if expected_index >= 0:
TestHelperClass.assert_equal(
@@ -202,13 +176,9 @@ func test_data_source_loading():
test_viewport.add_child(resolution_stepper)
await process_frame
TestHelperClass.assert_true(
resolution_stepper.values.size() > 0, "Resolution values loaded"
)
TestHelperClass.assert_true(resolution_stepper.values.size() > 0, "Resolution values loaded")
TestHelperClass.assert_contains(
resolution_stepper.values,
"1920x1080",
"Resolution data contains expected value"
resolution_stepper.values, "1920x1080", "Resolution data contains expected value"
)
resolution_stepper.queue_free()
@@ -219,13 +189,9 @@ func test_data_source_loading():
test_viewport.add_child(difficulty_stepper)
await process_frame
TestHelperClass.assert_true(
difficulty_stepper.values.size() > 0, "Difficulty values loaded"
)
TestHelperClass.assert_true(difficulty_stepper.values.size() > 0, "Difficulty values loaded")
TestHelperClass.assert_contains(
difficulty_stepper.values,
"normal",
"Difficulty data contains expected value"
difficulty_stepper.values, "normal", "Difficulty data contains expected value"
)
TestHelperClass.assert_equal(
1, difficulty_stepper.current_index, "Difficulty defaults to normal"
@@ -248,17 +214,13 @@ func test_value_navigation():
var initial_value = stepper_instance.get_current_value()
stepper_instance.change_value(1)
var next_value = stepper_instance.get_current_value()
TestHelperClass.assert_not_equal(
initial_value, next_value, "Forward navigation changes value"
)
TestHelperClass.assert_not_equal(initial_value, next_value, "Forward navigation changes value")
# Test backward navigation
stepper_instance.change_value(-1)
var back_value = stepper_instance.get_current_value()
TestHelperClass.assert_equal(
initial_value,
back_value,
"Backward navigation returns to original value"
initial_value, back_value, "Backward navigation returns to original value"
)
# Test wrap-around forward
@@ -266,18 +228,14 @@ func test_value_navigation():
stepper_instance.current_index = max_index
stepper_instance.change_value(1)
TestHelperClass.assert_equal(
0,
stepper_instance.current_index,
"Forward navigation wraps to beginning"
0, stepper_instance.current_index, "Forward navigation wraps to beginning"
)
# Test wrap-around backward
stepper_instance.current_index = 0
stepper_instance.change_value(-1)
TestHelperClass.assert_equal(
max_index,
stepper_instance.current_index,
"Backward navigation wraps to end"
max_index, stepper_instance.current_index, "Backward navigation wraps to end"
)
# Restore original state
@@ -300,19 +258,13 @@ func test_custom_values():
var custom_values = ["apple", "banana", "cherry"]
stepper_instance.setup_custom_values(custom_values)
TestHelperClass.assert_equal(
3, stepper_instance.values.size(), "Custom values set correctly"
)
TestHelperClass.assert_equal(
"apple", stepper_instance.values[0], "First custom value correct"
)
TestHelperClass.assert_equal(3, stepper_instance.values.size(), "Custom values set correctly")
TestHelperClass.assert_equal("apple", stepper_instance.values[0], "First custom value correct")
TestHelperClass.assert_equal(
0, stepper_instance.current_index, "Index reset to 0 for custom values"
)
TestHelperClass.assert_equal(
"apple",
stepper_instance.get_current_value(),
"Current value matches first custom value"
"apple", stepper_instance.get_current_value(), "Current value matches first custom value"
)
# Test custom values with display names
@@ -320,43 +272,31 @@ func test_custom_values():
stepper_instance.setup_custom_values(custom_values, custom_display_names)
TestHelperClass.assert_equal(
3,
stepper_instance.display_names.size(),
"Custom display names set correctly"
3, stepper_instance.display_names.size(), "Custom display names set correctly"
)
TestHelperClass.assert_equal(
"Red Apple",
stepper_instance.display_names[0],
"First display name correct"
"Red Apple", stepper_instance.display_names[0], "First display name correct"
)
# Test navigation with custom values
stepper_instance.change_value(1)
TestHelperClass.assert_equal(
"banana",
stepper_instance.get_current_value(),
"Navigation works with custom values"
"banana", stepper_instance.get_current_value(), "Navigation works with custom values"
)
# Test set_current_value
stepper_instance.set_current_value("cherry")
TestHelperClass.assert_equal(
"cherry",
stepper_instance.get_current_value(),
"set_current_value works correctly"
"cherry", stepper_instance.get_current_value(), "set_current_value works correctly"
)
TestHelperClass.assert_equal(
2,
stepper_instance.current_index,
"Index updated correctly by set_current_value"
2, stepper_instance.current_index, "Index updated correctly by set_current_value"
)
# Test invalid value
stepper_instance.set_current_value("grape")
TestHelperClass.assert_equal(
"cherry",
stepper_instance.get_current_value(),
"Invalid value doesn't change current value"
"cherry", stepper_instance.get_current_value(), "Invalid value doesn't change current value"
)
# Restore original state
@@ -379,9 +319,7 @@ func test_input_handling():
var left_handled = stepper_instance.handle_input_action("move_left")
TestHelperClass.assert_true(left_handled, "Left input action handled")
TestHelperClass.assert_not_equal(
original_value,
stepper_instance.get_current_value(),
"Left action changes value"
original_value, stepper_instance.get_current_value(), "Left action changes value"
)
# Test right input action
@@ -395,18 +333,14 @@ func test_input_handling():
# Test invalid input action
var invalid_handled = stepper_instance.handle_input_action("invalid_action")
TestHelperClass.assert_false(
invalid_handled, "Invalid input action not handled"
)
TestHelperClass.assert_false(invalid_handled, "Invalid input action not handled")
# Test button press simulation
if stepper_instance.left_button:
var before_left = stepper_instance.get_current_value()
stepper_instance.handle_input_action("move_left")
TestHelperClass.assert_not_equal(
before_left,
stepper_instance.get_current_value(),
"Left button press changes value"
before_left, stepper_instance.get_current_value(), "Left button press changes value"
)
if stepper_instance.right_button:
@@ -431,12 +365,9 @@ func test_visual_feedback():
# Test highlighting
stepper_instance.set_highlighted(true)
TestHelperClass.assert_true(stepper_instance.is_highlighted, "Highlighted state set correctly")
TestHelperClass.assert_true(
stepper_instance.is_highlighted, "Highlighted state set correctly"
)
TestHelperClass.assert_true(
stepper_instance.scale.x > original_scale.x,
"Scale increased when highlighted"
stepper_instance.scale.x > original_scale.x, "Scale increased when highlighted"
)
# Test unhighlighting
@@ -445,25 +376,17 @@ func test_visual_feedback():
stepper_instance.is_highlighted, "Highlighted state cleared correctly"
)
TestHelperClass.assert_equal(
original_scale,
stepper_instance.scale,
"Scale restored when unhighlighted"
original_scale, stepper_instance.scale, "Scale restored when unhighlighted"
)
TestHelperClass.assert_equal(
original_modulate,
stepper_instance.modulate,
"Modulate restored when unhighlighted"
original_modulate, stepper_instance.modulate, "Modulate restored when unhighlighted"
)
# Test display update
if stepper_instance.value_display:
var current_text = stepper_instance.value_display.text
TestHelperClass.assert_true(
current_text.length() > 0, "Value display has text content"
)
TestHelperClass.assert_not_equal(
"N/A", current_text, "Value display shows valid content"
)
TestHelperClass.assert_true(current_text.length() > 0, "Value display has text content")
TestHelperClass.assert_not_equal("N/A", current_text, "Value display shows valid content")
func test_settings_integration():
@@ -490,17 +413,13 @@ func test_settings_integration():
# Value change is applied automatically through set_current_value
# Verify setting was updated
var updated_lang = root.get_node("SettingsManager").get_setting(
"language"
)
var updated_lang = root.get_node("SettingsManager").get_setting("language")
TestHelperClass.assert_equal(
target_lang, updated_lang, "Language setting updated correctly"
)
# Restore original language
root.get_node("SettingsManager").set_setting(
"language", original_lang
)
root.get_node("SettingsManager").set_setting("language", original_lang)
func test_boundary_conditions():
@@ -516,16 +435,12 @@ func test_boundary_conditions():
await process_frame
TestHelperClass.assert_equal(
"",
empty_stepper.get_current_value(),
"Empty values array returns empty string"
"", empty_stepper.get_current_value(), "Empty values array returns empty string"
)
# Test change_value with empty array
empty_stepper.change_value(1) # Should not crash
TestHelperClass.assert_true(
true, "change_value handles empty array gracefully"
)
TestHelperClass.assert_true(true, "change_value handles empty array gracefully")
empty_stepper.queue_free()
@@ -535,18 +450,14 @@ func test_boundary_conditions():
stepper_instance.current_index = -1
# Display updates automatically when value changes
TestHelperClass.assert_equal(
"N/A",
stepper_instance.value_display.text,
"Negative index shows N/A"
"N/A", stepper_instance.value_display.text, "Negative index shows N/A"
)
# Test out-of-bounds index handling
stepper_instance.current_index = stepper_instance.values.size()
# Display updates automatically when value changes
TestHelperClass.assert_equal(
"N/A",
stepper_instance.value_display.text,
"Out-of-bounds index shows N/A"
"N/A", stepper_instance.value_display.text, "Out-of-bounds index shows N/A"
)
# Restore valid index
@@ -576,8 +487,7 @@ func test_error_handling():
control_name.ends_with("_stepper"), "Control name has correct suffix"
)
TestHelperClass.assert_true(
control_name.begins_with(stepper_instance.data_source),
"Control name includes data source"
control_name.begins_with(stepper_instance.data_source), "Control name includes data source"
)
# Test custom values with mismatched arrays
@@ -586,22 +496,16 @@ func test_error_handling():
stepper_instance.setup_custom_values(values_3, names_2)
# Should handle gracefully - display_names should be duplicated from values
TestHelperClass.assert_equal(3, stepper_instance.values.size(), "Values array size preserved")
TestHelperClass.assert_equal(
3, stepper_instance.values.size(), "Values array size preserved"
)
TestHelperClass.assert_equal(
2,
stepper_instance.display_names.size(),
"Display names size preserved as provided"
2, stepper_instance.display_names.size(), "Display names size preserved as provided"
)
# Test navigation with mismatched arrays
stepper_instance.current_index = 2 # Index where display_names doesn't exist
# Display updates automatically when value changes
TestHelperClass.assert_equal(
"c",
stepper_instance.value_display.text,
"Falls back to value when display name missing"
"c", stepper_instance.value_display.text, "Falls back to value when display name missing"
)