-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_recording.py
More file actions
62 lines (50 loc) · 1.74 KB
/
test_recording.py
File metadata and controls
62 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
"""
Test script to verify recording functionality
"""
import os
import sys
import pygame
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from demo import DemoRecorder
from main import *
def test_recording():
"""Test the recording functionality"""
print("🧪 Testing recording functionality...")
# Initialize pygame
pygame.init()
# Create a small demo
draw_info = DrawInformation(800, 600, [5, 2, 8, 1, 9])
recorder = DemoRecorder()
# Test recording
recorder.start_recording("Test Algorithm")
# Capture a few frames
for i in range(5):
draw_complete(draw_info, "Test Algorithm", True, 5)
recorder.capture_frame(draw_info.window)
time.sleep(0.1)
recorder.stop_recording()
# Check if files were created
test_dir = "recordings/test_algorithm"
if os.path.exists(test_dir):
files = os.listdir(test_dir)
png_files = [f for f in files if f.endswith('.png')]
print(f"✅ Recording test passed! Created {len(png_files)} frames")
# Test GIF creation
try:
recorder.create_gif("Test Algorithm")
gif_path = "recordings/test_algorithm.gif"
if os.path.exists(gif_path):
print("✅ GIF creation test passed!")
else:
print("❌ GIF creation test failed!")
except Exception as e:
print(f"⚠️ GIF creation test failed: {e}")
print(" (This is normal if Pillow is not installed)")
else:
print("❌ Recording test failed! No frames created")
pygame.quit()
print("🧪 Recording test completed!")
if __name__ == "__main__":
test_recording()