Files
experiment-adventure-ai/plans/cutscene_test_plan.md
2025-08-01 08:34:51 -07:00

231 lines
5.5 KiB
Markdown
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
```gdscript
# 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
```gdscript
# 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
1. Create a simple cutscene with entry → move → exit
2. Save the resource
3. Load and execute the cutscene
4. Verify all actions execute correctly
### Parallel Execution Test
1. Create a cutscene with entry → parallel group → exit
2. Add multiple actions to the parallel group
3. Save the resource
4. Load and execute the cutscene
5. Verify all parallel actions execute correctly
### Complex Flow Test
1. Create a complex cutscene with multiple branches
2. Include sequential and parallel actions
3. Save the resource
4. Load and execute the cutscene
5. Verify execution order is correct
### Parameter Validation Test
1. Create nodes with various parameter types
2. Verify parameters are stored correctly
3. Verify parameters are passed to actions correctly
### Error Handling Test
1. Create malformed resources
2. Verify appropriate error handling
3. Verify graceful failure modes
## Test Data
### Sample Cutscene Resources
#### Simple Move Cutscene
```json
{
"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
1. Create test framework
2. Implement CutsceneResource tests
3. Implement CutsceneGenerator tests
4. Implement CutsceneGraphEdit tests
### Phase 2: Integration Tests
1. Implement editor to runtime flow tests
2. Implement backward compatibility tests
### Phase 3: Functional Tests
1. Implement node type tests
2. Implement connection logic tests
3. Implement complex scenario tests
### Phase 4: Validation
1. Run all tests
2. Fix any issues
3. Verify coverage
4. Document results
## Success Criteria
1. All unit tests pass
2. All integration tests pass
3. All functional tests pass
4. Backward compatibility maintained
5. Performance acceptable
6. No critical bugs found