Timer overhaul: update tests
This commit is contained in:
parent
5d41292bf6
commit
cec76b63dc
78 changed files with 521 additions and 495 deletions
|
|
@ -4,43 +4,44 @@ import mcrfpy
|
|||
from mcrfpy import automation
|
||||
from datetime import datetime
|
||||
|
||||
def run_automation_tests():
|
||||
def run_automation_tests(timer, runtime):
|
||||
"""This runs AFTER the game loop has started and rendered frames"""
|
||||
print("\n=== Automation Test Running (1 second after start) ===")
|
||||
|
||||
|
||||
# NOW we can take screenshots that will show content!
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
filename = f"WORKING_screenshot_{timestamp}.png"
|
||||
|
||||
|
||||
# Take screenshot - this should now show our red frame
|
||||
result = automation.screenshot(filename)
|
||||
print(f"Screenshot taken: {filename} - Result: {result}")
|
||||
|
||||
|
||||
# Test clicking on the frame
|
||||
automation.click(200, 200) # Click in center of red frame
|
||||
|
||||
|
||||
# Test keyboard input
|
||||
automation.typewrite("Hello from timer callback!")
|
||||
|
||||
|
||||
# Take another screenshot to show any changes
|
||||
filename2 = f"WORKING_screenshot_after_click_{timestamp}.png"
|
||||
automation.screenshot(filename2)
|
||||
print(f"Second screenshot: {filename2}")
|
||||
|
||||
|
||||
print("Test completed successfully!")
|
||||
print("\nThis works because:")
|
||||
print("1. The game loop has been running for 1 second")
|
||||
print("2. The scene has been rendered multiple times")
|
||||
print("3. The RenderTexture now contains actual rendered content")
|
||||
|
||||
|
||||
# Cancel this timer so it doesn't repeat
|
||||
mcrfpy.delTimer("automation_test")
|
||||
|
||||
timer.stop()
|
||||
|
||||
# Optional: exit after a moment
|
||||
def exit_game():
|
||||
def exit_game(t, r):
|
||||
print("Exiting...")
|
||||
mcrfpy.exit()
|
||||
mcrfpy.setTimer("exit", exit_game, 500) # Exit 500ms later
|
||||
global exit_timer
|
||||
exit_timer = mcrfpy.Timer("exit", exit_game, 500, once=True)
|
||||
|
||||
# This code runs during --exec script execution
|
||||
print("=== Setting Up Test Scene ===")
|
||||
|
|
@ -73,7 +74,7 @@ frame.on_click = frame_clicked
|
|||
print("Scene setup complete. Setting timer for automation tests...")
|
||||
|
||||
# THIS IS THE KEY: Set timer to run AFTER the game loop starts
|
||||
mcrfpy.setTimer("automation_test", run_automation_tests, 1000)
|
||||
automation_test_timer = mcrfpy.Timer("automation_test", run_automation_tests, 1000, once=True)
|
||||
|
||||
print("Timer set. Game loop will start after this script completes.")
|
||||
print("Automation tests will run 1 second later when content is visible.")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue