when'd i last commit this pos?

This commit is contained in:
Thomas Ales [M S E]
2026-02-09 14:40:34 -06:00
parent fc43fbe4b0
commit 23f6331ba2
94 changed files with 14427 additions and 12178 deletions
+126
View File
@@ -0,0 +1,126 @@
#!/usr/bin/env python3
"""
Test script for camera integration with the scan wizard.
Tests the camera driver and integration with the UI.
"""
import sys
from PyQt6 import QtWidgets
def test_camera_import():
"""Test that the camera driver can be imported"""
print("Testing camera driver import...")
try:
from uc480_camera import UC480Camera, CameraStreamThread
print("✓ Camera driver imported successfully")
return True
except ImportError as e:
print(f"✗ Failed to import camera driver: {e}")
return False
def test_camera_class():
"""Test that the camera class can be instantiated"""
print("\nTesting camera class instantiation...")
try:
from uc480_camera import UC480Camera
camera = UC480Camera(camera_id=0)
print("✓ Camera class instantiated successfully")
print(f" Camera handle: {camera.h_cam}")
print(f" Initialized: {camera.is_initialized}")
return True
except Exception as e:
print(f"✗ Failed to instantiate camera class: {e}")
return False
def test_scanengine_import():
"""Test that the scanengine app can be imported with camera integration"""
print("\nTesting scanengine app import...")
try:
from scanengine_app import NewScanWizard, MainLauncher
print("✓ Scanengine app imported successfully")
return True
except ImportError as e:
print(f"✗ Failed to import scanengine app: {e}")
return False
def test_wizard_with_camera():
"""Test that the wizard can be created with camera integration"""
print("\nTesting wizard with camera integration...")
try:
app = QtWidgets.QApplication(sys.argv)
from scanengine_app import NewScanWizard
wizard = NewScanWizard()
print("✓ Wizard created successfully")
print(f" Camera object: {wizard.camera}")
print(f" Camera stream thread: {wizard.camera_stream_thread}")
print(f" CCD scene: {wizard.ccd_scene}")
# Check if camera methods exist
assert hasattr(wizard, 'initialize_camera'), "Missing initialize_camera method"
assert hasattr(wizard, 'start_camera_stream'), "Missing start_camera_stream method"
assert hasattr(wizard, 'stop_camera_stream'), "Missing stop_camera_stream method"
assert hasattr(wizard, 'cleanup_camera'), "Missing cleanup_camera method"
print("✓ All camera methods present")
# Test page change triggers
print("\nTesting page change behavior...")
current_page = wizard.stackedWidget.currentIndex()
print(f" Current page: {current_page}")
# Simulate page navigation to focus page (index 1)
print(" Navigating to focus page (index 1)...")
wizard.stackedWidget.setCurrentIndex(1)
print(f" Current page after navigation: {wizard.stackedWidget.currentIndex()}")
# Navigate back to first page
print(" Navigating back to page 0...")
wizard.stackedWidget.setCurrentIndex(0)
print(f" Current page after navigation: {wizard.stackedWidget.currentIndex()}")
# Cleanup
wizard.cleanup_camera()
print("✓ Camera cleanup successful")
return True
except Exception as e:
print(f"✗ Failed to test wizard with camera: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Run all tests"""
print("=" * 60)
print("Camera Integration Test Suite")
print("=" * 60)
results = []
# Run tests
results.append(("Camera Import", test_camera_import()))
results.append(("Camera Class", test_camera_class()))
results.append(("Scanengine Import", test_scanengine_import()))
results.append(("Wizard Integration", test_wizard_with_camera()))
# Print summary
print("\n" + "=" * 60)
print("Test Summary")
print("=" * 60)
for test_name, passed in results:
status = "PASS" if passed else "FAIL"
symbol = "✓" if passed else "✗"
print(f"{symbol} {test_name}: {status}")
all_passed = all(result[1] for result in results)
print("\n" + "=" * 60)
if all_passed:
print("All tests passed!")
else:
print("Some tests failed.")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == "__main__":
sys.exit(main())