3e779be6f3
CI / lint (push) Failing after 13m4s
CI / test (3.11, ubuntu-latest) (push) Failing after 2m4s
CI / test (3.13, ubuntu-latest) (push) Successful in 13m30s
CI / test (3.14, ubuntu-latest) (push) Successful in 17m21s
CI / test (3.12, ubuntu-latest) (push) Successful in 17m55s
CI / discover-apps-ps (push) Successful in 1m56s
CI / test (3.9, ubuntu-latest) (push) Successful in 13m17s
CI / test (3.10, ubuntu-latest) (push) Successful in 26m21s
CI / audit (push) Successful in 13m38s
Deploy site / deploy (push) Has been cancelled
CI / test (3.14, ubuntu-24.04-arm) (push) Has been cancelled
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
# SPDX-License-Identifier: MIT
|
|
"""Tests for display detection."""
|
|
|
|
from winpodx.display.detector import desktop_environment, session_type
|
|
|
|
|
|
def test_session_type_x11(monkeypatch):
|
|
monkeypatch.setenv("XDG_SESSION_TYPE", "x11")
|
|
assert session_type() == "x11"
|
|
|
|
|
|
def test_session_type_wayland(monkeypatch):
|
|
monkeypatch.setenv("XDG_SESSION_TYPE", "wayland")
|
|
assert session_type() == "wayland"
|
|
|
|
|
|
def test_session_type_fallback_display(monkeypatch):
|
|
monkeypatch.delenv("XDG_SESSION_TYPE", raising=False)
|
|
monkeypatch.delenv("WAYLAND_DISPLAY", raising=False)
|
|
monkeypatch.setenv("DISPLAY", ":0")
|
|
assert session_type() == "x11"
|
|
|
|
|
|
def test_desktop_environment_gnome(monkeypatch):
|
|
monkeypatch.setenv("XDG_CURRENT_DESKTOP", "GNOME")
|
|
assert desktop_environment() == "gnome"
|
|
|
|
|
|
def test_desktop_environment_kde(monkeypatch):
|
|
monkeypatch.setenv("XDG_CURRENT_DESKTOP", "KDE")
|
|
assert desktop_environment() == "kde"
|
|
|
|
|
|
def test_qt_dpr_returns_none_off_main_thread():
|
|
# QGuiApplication.screens() is GUI-thread-only; calling it from a worker
|
|
# thread emits "setParent: ... different thread" and can SIGABRT the process
|
|
# (GUI InfoWorker running gather_info off-thread). The guard must short-
|
|
# circuit to None on any non-main thread so callers fall back to subprocess
|
|
# detection instead of touching Qt.
|
|
import threading
|
|
|
|
from winpodx.display.scaling import _qt_max_device_pixel_ratio
|
|
|
|
result: list[float | None] = []
|
|
|
|
def worker():
|
|
result.append(_qt_max_device_pixel_ratio())
|
|
|
|
t = threading.Thread(target=worker)
|
|
t.start()
|
|
t.join()
|
|
assert result == [None]
|