forked from genewildish/Mainline
feat(integration): Complete feature rewrite with pipeline architecture, effects system, and display improvements
Major changes: - Pipeline architecture with capability-based dependency resolution - Effects plugin system with performance monitoring - Display abstraction with multiple backends (terminal, null, websocket) - Camera system for viewport scrolling - Sensor framework for real-time input - Command-and-control system via ntfy - WebSocket display backend for browser clients - Comprehensive test suite and documentation Issue #48: ADR for preset scripting language included This commit consolidates 110 individual commits into a single feature integration that can be reviewed and tested before further refinement.
This commit is contained in:
106
tests/test_hud.py
Normal file
106
tests/test_hud.py
Normal file
@@ -0,0 +1,106 @@
|
||||
from engine.effects.performance import PerformanceMonitor, set_monitor
|
||||
from engine.effects.types import EffectContext
|
||||
|
||||
|
||||
def test_hud_effect_adds_hud_lines():
|
||||
"""Test that HUD effect adds HUD lines to the buffer."""
|
||||
from engine.effects.plugins.hud import HudEffect
|
||||
|
||||
set_monitor(PerformanceMonitor())
|
||||
|
||||
hud = HudEffect()
|
||||
hud.config.params["display_effect"] = "noise"
|
||||
hud.config.params["display_intensity"] = 0.5
|
||||
|
||||
ctx = EffectContext(
|
||||
terminal_width=80,
|
||||
terminal_height=24,
|
||||
scroll_cam=0,
|
||||
ticker_height=24,
|
||||
mic_excess=0.0,
|
||||
grad_offset=0.0,
|
||||
frame_number=0,
|
||||
has_message=False,
|
||||
items=[],
|
||||
)
|
||||
|
||||
buf = [
|
||||
"A" * 80,
|
||||
"B" * 80,
|
||||
"C" * 80,
|
||||
]
|
||||
|
||||
result = hud.process(buf, ctx)
|
||||
|
||||
assert len(result) >= 3, f"Expected at least 3 lines, got {len(result)}"
|
||||
|
||||
first_line = result[0]
|
||||
assert "MAINLINE DEMO" in first_line, (
|
||||
f"HUD not found in first line: {first_line[:50]}"
|
||||
)
|
||||
|
||||
second_line = result[1]
|
||||
assert "EFFECT:" in second_line, f"Effect line not found: {second_line[:50]}"
|
||||
|
||||
print("First line:", result[0])
|
||||
print("Second line:", result[1])
|
||||
if len(result) > 2:
|
||||
print("Third line:", result[2])
|
||||
|
||||
|
||||
def test_hud_effect_shows_current_effect():
|
||||
"""Test that HUD displays the correct effect name."""
|
||||
from engine.effects.plugins.hud import HudEffect
|
||||
|
||||
set_monitor(PerformanceMonitor())
|
||||
|
||||
hud = HudEffect()
|
||||
hud.config.params["display_effect"] = "fade"
|
||||
hud.config.params["display_intensity"] = 0.75
|
||||
|
||||
ctx = EffectContext(
|
||||
terminal_width=80,
|
||||
terminal_height=24,
|
||||
scroll_cam=0,
|
||||
ticker_height=24,
|
||||
mic_excess=0.0,
|
||||
grad_offset=0.0,
|
||||
frame_number=0,
|
||||
has_message=False,
|
||||
items=[],
|
||||
)
|
||||
|
||||
buf = ["X" * 80]
|
||||
result = hud.process(buf, ctx)
|
||||
|
||||
second_line = result[1]
|
||||
assert "fade" in second_line, f"Effect name 'fade' not found in: {second_line}"
|
||||
|
||||
|
||||
def test_hud_effect_shows_intensity():
|
||||
"""Test that HUD displays intensity percentage."""
|
||||
from engine.effects.plugins.hud import HudEffect
|
||||
|
||||
set_monitor(PerformanceMonitor())
|
||||
|
||||
hud = HudEffect()
|
||||
hud.config.params["display_effect"] = "glitch"
|
||||
hud.config.params["display_intensity"] = 0.8
|
||||
|
||||
ctx = EffectContext(
|
||||
terminal_width=80,
|
||||
terminal_height=24,
|
||||
scroll_cam=0,
|
||||
ticker_height=24,
|
||||
mic_excess=0.0,
|
||||
grad_offset=0.0,
|
||||
frame_number=0,
|
||||
has_message=False,
|
||||
items=[],
|
||||
)
|
||||
|
||||
buf = ["Y" * 80]
|
||||
result = hud.process(buf, ctx)
|
||||
|
||||
second_line = result[1]
|
||||
assert "80%" in second_line, f"Intensity 80% not found in: {second_line}"
|
||||
Reference in New Issue
Block a user