McRogueFace/tests/unit/test_simple_callback.py

31 lines
690 B
Python
Raw Normal View History

#!/usr/bin/env python3
2026-02-09 08:15:18 -05:00
"""Very simple animation callback test"""
import mcrfpy
import sys
callback_fired = False
2026-02-09 08:15:18 -05:00
def cb(target, prop, value):
global callback_fired
callback_fired = True
# Setup scene
2026-01-03 10:59:52 -05:00
test = mcrfpy.Scene("test")
2026-02-09 08:15:18 -05:00
mcrfpy.current_scene = test
2026-02-09 08:15:18 -05:00
# Create frame and animate it
f = mcrfpy.Frame(pos=(0, 0), size=(50, 50))
test.children.append(f)
f.animate("x", 100.0, 0.1, "linear", callback=cb)
# Advance past animation duration (0.1s)
2026-02-09 08:15:18 -05:00
for _ in range(3):
mcrfpy.step(0.05)
# Verify callback fired
if callback_fired:
2026-02-09 08:15:18 -05:00
print("PASS: Callback fired", file=sys.stderr)
sys.exit(0)
else:
2026-02-09 08:15:18 -05:00
print("FAIL: Callback did not fire", file=sys.stderr)
sys.exit(1)