# FILE: _St/Shared/test_shared_windows_tray.py | ROLE: 공용 Windows Tray helper 비Windows 안전·복원 이벤트 회귀
from __future__ import annotations

from Shared.windows_tray import WindowsTrayIcon


def test_windows_tray_non_windows_is_safe() -> None:
    tray = WindowsTrayIcon("TEST", "test tray")
    # CI/Linux에서는 외부 패키지 없이 import/생성/정리되어야 한다.
    if not tray.supported:
        assert tray.start() is False
        assert tray.show() is False
        tray.hide()
        tray.stop()
        assert tray.visible is False


def test_windows_tray_restore_event_is_consumed_once() -> None:
    tray = WindowsTrayIcon("TEST", "test tray")
    tray._restore_event.set()
    assert tray.poll_restore() is True
    assert tray.poll_restore() is False


def test_windows_tray_accepts_project_icon_path() -> None:
    from pathlib import Path
    st_root = Path(__file__).resolve().parent.parent
    icon = st_root / "Shared" / "assets" / "ig_styellow_tray.ico"
    tray = WindowsTrayIcon("TEST_ICON", "test icon", icon_path=icon)
    assert tray.icon_path == str(icon.resolve())
