#!/usr/bin/env python3 """Test script to verify VLChan installation and basic functionality.""" import sys import time from vlchan import VLChanPlayer, SynchanController, SynchanState def test_imports(): """Test that all modules can be imported.""" print("Testing imports...") try: from vlchan import VLChanPlayer, SynchanController, SynchanState print("✓ All imports successful") return True except ImportError as e: print(f"✗ Import error: {e}") return False def test_vlc_availability(): """Test that VLC is available.""" print("Testing VLC availability...") try: import vlc instance = vlc.Instance() print("✓ VLC is available") instance.release() return True except Exception as e: print(f"✗ VLC error: {e}") print(" Make sure VLC is installed on your system") return False def test_synchan_controller(): """Test synchan controller creation.""" print("Testing synchan controller...") try: controller = SynchanController("http://localhost:3000") print("✓ Synchan controller created") return True except Exception as e: print(f"✗ Synchan controller error: {e}") return False def test_player_creation(): """Test player creation without video file.""" print("Testing player creation...") try: player = VLChanPlayer("http://localhost:3000") print("✓ Player created successfully") player.cleanup() return True except Exception as e: print(f"✗ Player creation error: {e}") return False def test_synchan_state(): """Test synchan state dataclass.""" print("Testing synchan state...") try: state = SynchanState( playing=True, currentTime=10.5, duration=120.0, loop=False, latency=0.05 ) print(f"✓ Synchan state created: {state}") return True except Exception as e: print(f"✗ Synchan state error: {e}") return False def main(): """Run all tests.""" print("VLChan Test Suite") print("=" * 40) tests = [ test_imports, test_vlc_availability, test_synchan_controller, test_player_creation, test_synchan_state, ] passed = 0 total = len(tests) for test in tests: if test(): passed += 1 print() print("=" * 40) print(f"Tests passed: {passed}/{total}") if passed == total: print("✓ All tests passed! VLChan is ready to use.") return 0 else: print("✗ Some tests failed. Please check the errors above.") return 1 if __name__ == "__main__": sys.exit(main())