McRogueFace/tests/unit/test_headless_detection.py

38 lines
1,009 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""Test to detect if we're running in headless mode"""
import mcrfpy
from mcrfpy import automation
import sys
# Create scene
2026-01-03 10:59:52 -05:00
detect_test = mcrfpy.Scene("detect_test")
2026-02-09 08:15:18 -05:00
mcrfpy.current_scene = detect_test
2026-01-03 10:59:52 -05:00
ui = detect_test.children
# Create a frame
frame = mcrfpy.Frame(pos=(100, 100), size=(200, 200))
frame.fill_color = mcrfpy.Color(255, 100, 100, 255)
ui.append(frame)
2026-02-09 08:15:18 -05:00
# Render a frame so screenshot has content
mcrfpy.step(0.01)
try:
# Try to take a screenshot - this should work in both modes
automation.screenshot("test_screenshot.png")
print("PASS: Screenshot capability available")
2026-01-03 22:44:53 -05:00
2026-02-09 08:15:18 -05:00
# Check if we can interact with the window
try:
# In headless mode, this should still work but via the headless renderer
automation.click(200, 200)
print("PASS: Click automation available")
except Exception as e:
2026-02-09 08:15:18 -05:00
print(f"Click failed: {e}")
2026-01-03 22:44:53 -05:00
2026-02-09 08:15:18 -05:00
except Exception as e:
print(f"Screenshot failed: {e}")
2026-02-09 08:15:18 -05:00
print("Test complete")
sys.exit(0)