test: inline smoke check for the wheel guard

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-08 18:42:14 +02:00
co-authored by Claude Fable 5
parent 7b547309e2
commit 64a71a9ec7
+34
View File
@@ -46,3 +46,37 @@ class WheelValueGuard(QObject):
QApplication.sendEvent(area.viewport(), relayed)
return True
return super().eventFilter(obj, event)
if __name__ == "__main__":
# ponytail: smallest check that fails if the guard logic breaks
import os
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
from PySide6.QtCore import QPoint, QPointF
app = QApplication([])
guard = WheelValueGuard()
app.installEventFilter(guard)
slider = QSlider(Qt.Orientation.Horizontal)
slider.setRange(0, 100)
slider.setValue(50)
slider.show()
def wheel(buttons):
return QWheelEvent(
QPointF(5, 5),
QPointF(5, 5),
QPoint(0, 0),
QPoint(0, 120),
buttons,
Qt.KeyboardModifier.NoModifier,
Qt.ScrollPhase.NoScrollPhase,
False,
)
QApplication.sendEvent(slider, wheel(Qt.MouseButton.NoButton))
assert slider.value() == 50, "bare wheel must not adjust the slider"
QApplication.sendEvent(slider, wheel(Qt.MouseButton.RightButton))
assert slider.value() != 50, "right-button + wheel must adjust the slider"
print("gude")