#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
测试无窗口模式启动
"""

import sys
import os
from pathlib import Path

# 添加当前目录和项目根目录到Python路径
current_dir = Path(__file__).parent
project_root = current_dir.parent
sys.path.insert(0, str(current_dir))  # 添加packaging目录
sys.path.insert(0, str(project_root))  # 添加项目根目录

def test_headless_mode():
    """测试无窗口模式"""
    print("测试无窗口模式启动...")
    
    try:
        from integrated_launcher import IntegratedLauncher
        
        # 创建无窗口模式的启动器
        launcher = IntegratedLauncher(headless=True)
        
        print("✓ 启动器创建成功")
        
        # 测试日志系统
        launcher.log_and_print("测试日志消息")
        
        print("✓ 日志系统工作正常")
        
        # 测试配置检查
        config_complete = launcher.check_config_complete()
        print(f"✓ 配置检查完成: {config_complete}")
        
        print("✓ 无窗口模式测试通过")
        
    except Exception as e:
        print(f"✗ 测试失败: {e}")
        import traceback
        traceback.print_exc()
        return False
    
    return True

if __name__ == "__main__":
    success = test_headless_mode()
    sys.exit(0 if success else 1)