5.5 KiB
Executable File
5.5 KiB
Executable File
Cutscene System Test Plan
Overview
This document outlines the testing approach for the updated cutscene editor system that focuses on resource management.
Test Categories
1. Unit Tests
CutsceneResource Tests
- Test node addition and removal
- Test connection addition and removal
- Test unique ID generation
- Test data validation
- Test loading from existing resources
- Test saving to new format
CutsceneGenerator Tests
- Test resource to action conversion
- Test action creation from nodes
- Test parallel group handling
- Test error handling for malformed resources
CutsceneGraphEdit Tests
- Test loading resources into editor
- Test saving resources from editor
- Test node creation and deletion
- Test connection creation and deletion
2. Integration Tests
Editor to Runtime Flow
- Create cutscene in editor
- Save resource
- Load resource in runtime
- Execute cutscene successfully
Backward Compatibility
- Load old format resources
- Convert to new format
- Execute successfully
3. Functional Tests
Node Types
- Entry node creation and behavior
- Exit node creation and behavior
- Move action node creation and parameter handling
- Dialogue action node creation and parameter handling
- Animation action node creation and parameter handling
- Turn action node creation and parameter handling
- Wait action node creation and parameter handling
- Parallel group node creation and behavior
Connection Logic
- Sequential connection flow
- Parallel connection flow
- Connection validation
- Cycle detection
Test Implementation
1. Unit Test Structure
# Example unit test for CutsceneResource
func test_add_node():
var resource = CutsceneResource.new()
var node_data = {
"id": "test_node_1",
"type": "move",
"position": {"x": 100, "y": 150},
"parameters": {
"character": "player",
"target_x": 200,
"target_y": 300,
"speed": 100
}
}
resource.add_node(node_data)
assert(resource.nodes.size() == 1)
assert(resource.nodes[0]["id"] == "test_node_1")
2. Integration Test Structure
# Example integration test
func test_editor_to_runtime_flow():
# Create cutscene in "editor"
var graph_edit = CutsceneGraphEdit.new()
var node = graph_edit.add_node("move", Vector2(100, 150))
node.node_id = "move_1"
node.set_parameter("character", "player")
node.set_parameter("target_x", 200)
node.set_parameter("target_y", 300)
node.set_parameter("speed", 100)
# Save resource
var resource = graph_edit.save_to_cutscene()
# Load in "runtime"
var generator = CutsceneGenerator.new()
var cutscene_manager = generator.generate_cutscene(resource)
# Verify actions were created correctly
assert(cutscene_manager.sequential_actions.size() == 1)
assert(cutscene_manager.sequential_actions[0] is MoveAction)
Test Scenarios
Basic Flow Test
- Create a simple cutscene with entry → move → exit
- Save the resource
- Load and execute the cutscene
- Verify all actions execute correctly
Parallel Execution Test
- Create a cutscene with entry → parallel group → exit
- Add multiple actions to the parallel group
- Save the resource
- Load and execute the cutscene
- Verify all parallel actions execute correctly
Complex Flow Test
- Create a complex cutscene with multiple branches
- Include sequential and parallel actions
- Save the resource
- Load and execute the cutscene
- Verify execution order is correct
Parameter Validation Test
- Create nodes with various parameter types
- Verify parameters are stored correctly
- Verify parameters are passed to actions correctly
Error Handling Test
- Create malformed resources
- Verify appropriate error handling
- Verify graceful failure modes
Test Data
Sample Cutscene Resources
Simple Move Cutscene
{
"version": "2.0",
"metadata": {
"created": "2023-01-01T00:00:00Z",
"modified": "2023-01-01T00:00:00Z"
},
"nodes": [
{
"id": "entry_1",
"type": "entry",
"position": {"x": 100, "y": 100},
"parameters": {}
},
{
"id": "move_1",
"type": "move",
"position": {"x": 250, "y": 100},
"parameters": {
"character": "player",
"target_x": 300,
"target_y": 200,
"speed": 100
}
},
{
"id": "exit_1",
"type": "exit",
"position": {"x": 400, "y": 100},
"parameters": {}
}
],
"connections": [
{
"id": "conn_1",
"from_node": "entry_1",
"from_port": 0,
"to_node": "move_1",
"to_port": 0
},
{
"id": "conn_2",
"from_node": "move_1",
"from_port": 0,
"to_node": "exit_1",
"to_port": 0
}
]
}
Implementation Plan
Phase 1: Unit Tests
- Create test framework
- Implement CutsceneResource tests
- Implement CutsceneGenerator tests
- Implement CutsceneGraphEdit tests
Phase 2: Integration Tests
- Implement editor to runtime flow tests
- Implement backward compatibility tests
Phase 3: Functional Tests
- Implement node type tests
- Implement connection logic tests
- Implement complex scenario tests
Phase 4: Validation
- Run all tests
- Fix any issues
- Verify coverage
- Document results
Success Criteria
- All unit tests pass
- All integration tests pass
- All functional tests pass
- Backward compatibility maintained
- Performance acceptable
- No critical bugs found