"""Status bar layout contract: passive readouts left, operable controls right, and every operable label wears the shared hover affordance.""" from aarecommon.models.models import TokenData from PySide6.QtCore import QEvent, QPointF, Qt from PySide6.QtGui import QEnterEvent from aare.gui.widgets.status_bar import StatusBar def _bar(qtbot): bar = StatusBar(token=TokenData(sub="u", staff=True, pgroups=["p1"], session=1)) qtbot.addWidget(bar) bar.show() return bar def test_operables_share_the_hover_affordance(qtbot): bar = _bar(qtbot) for label in (bar.shutter_label, bar.state_label, bar.pgroup_label, bar.session_label): assert label.cursor().shape() == Qt.CursorShape.PointingHandCursor # Cryo is grouped with the operables but stays passive for now (TODO in # status_bar.py); the plain readouts are passive too. for label in (bar.cryo_label, bar.flux, bar.busy_label): assert label.cursor().shape() != Qt.CursorShape.PointingHandCursor # Hover underlines, leaving restores. enter = QEnterEvent(QPointF(1, 1), QPointF(1, 1), QPointF(1, 1)) bar.state_label.enterEvent(enter) assert bar.state_label.font().underline() bar.state_label.leaveEvent(QEvent(QEvent.Type.Leave)) assert not bar.state_label.font().underline() def test_passives_left_operables_right(qtbot): bar = _bar(qtbot) # QStatusBar hides only the non-permanent (left) section behind a # temporary message — probe the grouping through that behavior. bar.showMessage("probe") assert not bar.flux.isVisible() assert not bar.busy_label.isVisible() for label in ( bar.cryo_label, bar.shutter_label, bar.state_label, bar.pgroup_label, bar.session_label, ): assert label.isVisible()