Files
AareDAQ/tests/unit/gui/test_qt_override_reduction.py
T
duan_jandClaude Fable 5 809959df33 feat!: remove Playlist Mode and Automation View, unpin window minimum
Why the width shrink only worked after a Playlist Mode round-trip:
Qt auto-pins a top-level window's minimum size to its layout minimum,
and returning from Playlist Mode hid the Information dock (and every
side dock), which happened to drop that layout minimum. The main view
now gets an explicit small minimum (320x240) which disables the
auto-pin outright, so the window shrinks directly and the dock
contents clip or scroll instead.

The Playlist Mode (Ctrl+6) and Automation View (Ctrl+5) prototypes
are deleted per user decision: panels, pages, the content stack (the
standard page is the only page left), menu actions, camera fan-out to
their view copies, portrait alert interceptors (now plain runtime
notification routers), and their styles (portraitRoot, compact*
cards, COMPACT_* and FONT_HERO knobs).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-16 13:28:16 +02:00

95 lines
3.2 KiB
Python

"""Covers the code paths touched by the reduce-overwriting-qt-method
refactor: Qt-native replacements (signals, shortcuts, underMouse) for
virtual-method overrides, so the diff-coverage gate sees them executed."""
from PySide6.QtCore import QEvent, QPointF, Qt
from PySide6.QtGui import QMouseEvent
from aare.gui.panels.fluorescence_panel import FluorescencePanel
from aare.gui.widgets.baton_request_dialog import BatonPendingDialog, BatonRequestDialog
from aare.gui.widgets.value_label import ValueLabel
from aare.gui.widgets.video_image import VideoGraphicsView
def test_baton_dialogs_stop_timer_via_finished(qtbot):
"""finished.connect replaced the closeEvent overrides: the timer must
stop on accept, reject AND plain close — the path closeEvent used to
handle."""
req = BatonRequestDialog("someone")
qtbot.addWidget(req)
assert req._timer.isActive()
req._on_accept()
assert not req._timer.isActive()
req2 = BatonRequestDialog("someone")
qtbot.addWidget(req2)
req2._on_refuse()
assert not req2._timer.isActive()
# close() only delivers a close event to a SHOWN dialog — same held for
# the old closeEvent override, so showing first keeps the test honest.
pend = BatonPendingDialog("user")
qtbot.addWidget(pend)
pend.show()
qtbot.waitExposed(pend)
assert pend._timer.isActive()
pend.close()
assert not pend._timer.isActive()
def test_fluorescence_hover_snaps_to_peak(qtbot):
"""Drives a MouseMove through the viewport filter: event.position()
(the PyQt5-era hasattr fallback is gone) and the max(range) peak snap."""
panel = FluorescencePanel()
qtbot.addWidget(panel)
panel.resize(500, 400)
panel.show()
qtbot.waitExposed(panel)
panel.axis_x.setRange(0.0, 10.0)
panel.axis_y.setRange(0.0, 100.0)
for i in range(50):
panel.series.append(i * 0.2, 90.0 if i == 25 else 10.0)
plot = panel.chart.plotArea()
pos = QPointF(plot.center())
ev = QMouseEvent(
QEvent.Type.MouseMove,
pos,
panel.chart_view.viewport().mapToGlobal(pos.toPoint()),
Qt.MouseButton.NoButton,
Qt.MouseButton.NoButton,
Qt.KeyboardModifier.NoModifier,
)
assert panel.eventFilter(panel.chart_view.viewport(), ev) is False
assert "keV" in panel.chart_view.toolTip()
def test_video_view_shortcuts_replace_keypress_override(qtbot):
view = VideoGraphicsView()
qtbot.addWidget(view)
view.show()
qtbot.waitExposed(view)
# WidgetShortcut context needs real focus; offscreen grants it only
# after the window is active.
view.activateWindow()
view.setFocus()
qtbot.waitUntil(view.hasFocus, timeout=2000)
qtbot.keyClick(view, Qt.Key.Key_Plus)
assert view.zoom_factor > 1.0
qtbot.keyClick(view, Qt.Key.Key_R)
assert view.zoom_factor == 1.0
qtbot.keyClick(view, Qt.Key.Key_Minus)
assert view.zoom_factor < 1.0
qtbot.keyClick(view, Qt.Key.Key_F) # fit_to_view: just must not raise
def test_value_label_inherits_click(qtbot):
label = ValueLabel("Energy", "keV")
qtbot.addWidget(label)
label.set_value("12.4")
assert "12.4" in label.text()
with qtbot.waitSignal(label.clicked, timeout=1000):
qtbot.mousePress(label, Qt.MouseButton.LeftButton)