"""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_camera_window_without_hardware_is_a_plain_viewer(qapp): """No stage, no scope, no auto-align button to press.""" import sc3_aui_app win = sc3_aui_app.CameraWindow() _pump(qapp) try: assert not win.uc480_auto_align_btn.isVisible() finally: win.deleteLater() _pump(qapp) def test_camera_window_auto_align_needs_every_device(qapp): """The button appears once the three devices exist, and says which one is missing rather than starting and failing on the rig.""" import sc3_aui_app from gui.qt_t3r import QtT3RAdapter win = sc3_aui_app.CameraWindow(QtT3RAdapter(), sc3_aui_app.BBD202Worker(), sc3_aui_app.OscopeWorker()) _pump(qapp) try: assert win.uc480_auto_align_btn.isVisibleTo(win) assert "oscilloscope" in win._align_prerequisite_problem() finally: win.deleteLater() _pump(qapp) def test_auto_align_window_logs_a_result(qapp): import sc3_aui_app from core.auto_align import AlignResult, Reading win = sc3_aui_app.AutoAlignWindow() _pump(qapp) try: reference = Reading(400.0, 400.0) win.set_reference(reference) win.on_reading(Reading(403.0, 397.0)) win.on_finished(AlignResult(reference=reference, final=reference)) assert "Reference" in win.log.toPlainText() assert win.close_btn.isEnabled() finally: 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_saw_check_viewer_window(qapp): import saw_check_viewer win = saw_check_viewer.SawCheckWindow() _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