McRogueFace/tests/unit/test_timer_legacy.py

28 lines
585 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""
2026-01-03 22:44:53 -05:00
Test Timer API works correctly (#173)
Replaces old legacy setTimer test
"""
import mcrfpy
import sys
count = 0
2026-01-03 22:44:53 -05:00
def timer_callback(timer, runtime):
global count
count += 1
print(f"Timer fired! Count: {count}, Runtime: {runtime}")
2026-01-03 22:44:53 -05:00
if count >= 3:
print("Test passed - timer fired 3 times")
2026-01-03 22:44:53 -05:00
print("PASS")
sys.exit(0)
# Set up the scene
2026-01-03 10:59:52 -05:00
test_scene = mcrfpy.Scene("test_scene")
test_scene.activate()
2026-01-03 22:44:53 -05:00
# Create a timer with new API
timer = mcrfpy.Timer("test_timer", timer_callback, 100)
2026-01-03 22:44:53 -05:00
print("Timer test starting...")