Files
AareDAQ/tests/unit/gui/test_busy_overlay.py
duan_jandClaude Fable 5.1 2df433b33c
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
CI / lint (pull_request) Failing after 1m2s
CI / test (3.12) (pull_request) Failing after 1m5s
CI / test (3.13) (pull_request) Failing after 1m10s
CI / test (3.14) (pull_request) Failing after 1m19s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Failing after 1m19s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Failing after 1m20s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Failing after 1m25s
CI / test-with-coverage (pull_request) Failing after 1m25s
CI / coverage-analysis (pull_request) Skipped
feat: show AUTO CENTERING in the sample camera view while a loop centering runs
/status cannot tell an auto centering from a manual alignment move (both
are busy + SampleAlignment, the combo the overlay deliberately hides), so
the DAQ worker emits its own auto_centering flag: True while its own
/alc/center_loop POST is in flight (the endpoint blocks until done) or
while the automation progress reports the Center step running. The
sample camera views pass it to build_busy_overlay_style, which paints a
purple AUTO CENTERING wave text like the ROBOT MOUNTING/COOLING ones.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-08 11:35:26 +02:00

53 lines
2.0 KiB
Python

"""The Axis views' busy flag is a passive status: plain shadowed text, not
the badge pill (which reads as a button). These checks fail if the text
renderer stops painting or the video view stops routing through it."""
from aarecommon.models.models import SessionsStateEnum
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter, QPixmap
from aare.gui.widgets.busy_overlay import build_busy_overlay_style, draw_busy_status_text
from aare.gui.widgets.video_image import VideoGraphicsView
def _busy_style():
style = build_busy_overlay_style(is_busy=True, tell_state=None)
assert style is not None and style.text == "BEAMLINE BUSY"
return style
def test_status_text_paints_something(qapp):
pixmap = QPixmap(400, 300)
pixmap.fill(Qt.GlobalColor.black)
blank = pixmap.toImage()
painter = QPainter(pixmap)
draw_busy_status_text(painter, 400, 300, _busy_style())
painter.end()
assert pixmap.toImage() != blank, "busy text must actually paint"
def test_video_view_paints_busy_text(qtbot):
view = VideoGraphicsView()
qtbot.addWidget(view)
view.resize(400, 300)
idle = view.grab().toImage()
view.set_busy_overlay_style(_busy_style())
assert view.grab().toImage() != idle, "busy style must change the rendered view"
view.set_busy_overlay_style(None)
assert view.grab().toImage() == idle, "clearing the style must restore the view"
def test_auto_centering_flag_overrides_alignment_gate():
# Callers pass is_busy=False during SampleAlignment; the flag must still
# produce the overlay, and the viewing-mode badge must still win.
style = build_busy_overlay_style(is_busy=False, tell_state=None, auto_centering=True)
assert style is not None and style.text == "AUTO CENTERING"
assert build_busy_overlay_style(is_busy=False, tell_state=None) is None
viewing = build_busy_overlay_style(
is_busy=False,
tell_state=None,
session_state=SessionsStateEnum.OwnedByElse,
auto_centering=True,
)
assert viewing is not None and viewing.text.startswith("Viewing mode")