Files
scanengine-3/tests/test_smoke_apps.py
Thomas Ales d185676130 Phase 0: test scaffolding + golden fixtures
- ruff config, offscreen smoke tests for all 7 GUI apps/panels
- golden v6 .sras fixtures (complete + 4 truncation variants) generated
  by the pre-refactor writer, with expected header/frontier JSON
- golden geometry fixtures from the pre-refactor _build_scan_params
- consistency tests proving current code reproduces the goldens

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 10:01:14 -05:00

100 lines
2.3 KiB
Python

"""Offscreen smoke tests: every GUI app must construct without hardware.
These don't exercise behavior — they catch import errors, missing .ui
widgets, and constructor regressions during the refactor.
"""
import pytest
from PyQt6.QtWidgets import QApplication
@pytest.fixture(scope="session")
def qapp():
app = QApplication.instance() or QApplication([])
yield app
def _pump(qapp):
qapp.processEvents()
def test_sc3_aui_main_window(qapp):
import sc3_aui_app
win = sc3_aui_app.MainWindow()
_pump(qapp)
try:
assert win.x_start_edit.text()
assert win.windowTitle() == "Scanengine-3 AUI"
finally:
for worker, thread in (
(win._bbd_worker, win._bbd_thread),
(win._oscope_worker, win._oscope_thread),
(win._helios_worker, win._helios_thread),
):
worker.stop_worker()
thread.quit()
assert thread.wait(2000)
win._camera_win.deleteLater()
win.deleteLater()
_pump(qapp)
def test_sras_viewer_window(qapp):
import sras_viewer
win = sras_viewer.SrasViewerWindow()
_pump(qapp)
try:
assert win.windowTitle()
finally:
win.deleteLater()
_pump(qapp)
def test_helios_test_app(qapp):
import helios_test_app
win = helios_test_app.HeliosTestApp()
_pump(qapp)
try:
assert win.windowTitle()
finally:
win.deleteLater()
_pump(qapp)
def test_bbd202_test_app(qapp):
import bbd202_test_app
win = bbd202_test_app.BBD202TestApp()
_pump(qapp)
try:
assert win.windowTitle()
finally:
win.close()
_pump(qapp)
def test_camera_test_app(qapp):
import camera_test_app
win = camera_test_app.CameraTestWindow()
_pump(qapp)
try:
assert win.windowTitle()
finally:
win.deleteLater()
_pump(qapp)
def test_t3r_control_panel(qapp):
from hardware.t3r_driver import T3RDriver
from t3r_control_panel import T3RControlPanel
driver = T3RDriver()
panel = T3RControlPanel(driver)
_pump(qapp)
try:
assert panel.windowTitle()
finally:
panel.deleteLater()
_pump(qapp)
def test_sras_scan_manager_importable():
import sras_scan_manager # noqa: F401