#!/bin/sh
# Builds the Qt settings window off screen and checks that its SVG logo renders.
set -e

export HOME="${AUTOPKGTEST_TMP:-$(mktemp -d)}"
export QT_QPA_PLATFORM=offscreen
export NGOSEN_SETTINGS_TOOLKIT=qt

dbus-run-session -- python3 - <<'EOF'
import sys

sys.path.insert(0, "/usr/share/fcitx5-ngosen/settings-gui")
import qt_api  # noqa: F401
from qtpy.QtWidgets import QApplication

app = QApplication(sys.argv)
from ui import brand
from ui.main_window import NgoSenSettingsWindow

window = NgoSenSettingsWindow()
window.show()
app.processEvents()
if brand.logo_icon().pixmap(64, 64).isNull():
    sys.exit("the logo did not render: is the Qt SVG plugin installed?")
print("settings window built, logo rendered")
EOF
