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 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 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 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}"