138 lines
3.2 KiB
GDScript
138 lines
3.2 KiB
GDScript
extends SceneTree
|
|
|
|
## Test mouse support functionality in Match3 gameplay
|
|
## This test verifies that mouse input, hover events, and tile selection work correctly
|
|
|
|
# Preloaded scenes to avoid duplication
|
|
const MATCH3_SCENE = preload("res://scenes/game/gameplays/Match3Gameplay.tscn")
|
|
const TILE_SCENE = preload("res://scenes/game/gameplays/Tile.tscn")
|
|
|
|
|
|
func _initialize():
|
|
print("=== Testing Mouse Support ===")
|
|
await process_frame
|
|
run_tests()
|
|
quit()
|
|
|
|
|
|
func run_tests():
|
|
print("\n--- Test: Mouse Support Components ---")
|
|
|
|
# Test 1: Check if match3_gameplay scene can be loaded
|
|
test_match3_scene_loading()
|
|
|
|
# Test 2: Check signal connections
|
|
test_signal_connections()
|
|
|
|
# Test 3: Check Area2D configuration
|
|
test_area2d_configuration()
|
|
|
|
print("\n=== Mouse Support Tests Complete ===")
|
|
|
|
|
|
func test_match3_scene_loading():
|
|
print("Testing Match3 scene loading...")
|
|
|
|
if not MATCH3_SCENE:
|
|
print("❌ FAILED: Could not load Match3Gameplay.tscn")
|
|
return
|
|
|
|
var match3_instance = MATCH3_SCENE.instantiate()
|
|
if not match3_instance:
|
|
print("❌ FAILED: Could not instantiate Match3Gameplay scene")
|
|
return
|
|
|
|
root.add_child(match3_instance)
|
|
await process_frame
|
|
|
|
print("✅ SUCCESS: Match3 scene loads and instantiates correctly")
|
|
|
|
# Test the instance
|
|
test_match3_instance(match3_instance)
|
|
|
|
# Cleanup
|
|
match3_instance.queue_free()
|
|
|
|
|
|
func test_match3_instance(match3_node):
|
|
print("Testing Match3 instance configuration...")
|
|
|
|
# Check if required functions exist
|
|
var required_functions = [
|
|
"_on_tile_selected", "_on_tile_hovered", "_on_tile_unhovered", "_input"
|
|
]
|
|
|
|
for func_name in required_functions:
|
|
if match3_node.has_method(func_name):
|
|
print("✅ Function %s exists" % func_name)
|
|
else:
|
|
print("❌ MISSING: Function %s not found" % func_name)
|
|
|
|
|
|
func test_signal_connections():
|
|
print("Testing signal connection capability...")
|
|
|
|
# Use preloaded tile scene
|
|
if not TILE_SCENE:
|
|
print("❌ FAILED: Could not load tile.tscn")
|
|
return
|
|
|
|
var tile = TILE_SCENE.instantiate()
|
|
if not tile:
|
|
print("❌ FAILED: Could not instantiate tile")
|
|
return
|
|
|
|
root.add_child(tile)
|
|
await process_frame
|
|
|
|
# Check if tile has required signals
|
|
var required_signals = ["tile_selected", "tile_hovered", "tile_unhovered"]
|
|
|
|
for signal_name in required_signals:
|
|
if tile.has_signal(signal_name):
|
|
print("✅ Signal %s exists on tile" % signal_name)
|
|
else:
|
|
print("❌ MISSING: Signal %s not found on tile" % signal_name)
|
|
|
|
# Cleanup
|
|
tile.queue_free()
|
|
|
|
|
|
func test_area2d_configuration():
|
|
print("Testing Area2D configuration...")
|
|
|
|
# Use preloaded tile scene
|
|
if not TILE_SCENE:
|
|
print("❌ FAILED: Could not load tile.tscn")
|
|
return
|
|
|
|
var tile = TILE_SCENE.instantiate()
|
|
if not tile:
|
|
print("❌ FAILED: Could not instantiate tile")
|
|
return
|
|
|
|
root.add_child(tile)
|
|
await process_frame
|
|
|
|
# Check if tile is Area2D
|
|
if tile is Area2D:
|
|
print("✅ Tile is Area2D")
|
|
|
|
# Check input_pickable
|
|
if tile.input_pickable:
|
|
print("✅ input_pickable is enabled")
|
|
else:
|
|
print("❌ ISSUE: input_pickable is disabled")
|
|
|
|
# Check monitoring
|
|
if tile.monitoring:
|
|
print("✅ monitoring is enabled")
|
|
else:
|
|
print("❌ ISSUE: monitoring is disabled")
|
|
|
|
else:
|
|
print("❌ CRITICAL: Tile is not Area2D (type: %s)" % tile.get_class())
|
|
|
|
# Cleanup
|
|
tile.queue_free()
|