Merge branch 'master' of http://git.zhenyangtang.com.cn/ZYT/zyt
This commit is contained in:
@@ -10,6 +10,7 @@ from PySide6.QtCore import QDate, QSize, Qt
|
||||
from PySide6.QtWidgets import QApplication, QStyle, QStyleOptionButton, QWidget
|
||||
|
||||
from doctor_workstation.ui.appointment_drawer import APPOINTMENT_DRAWER_QSS, AppointmentDrawer
|
||||
from doctor_workstation.ui.design_system import PALETTE
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
@@ -565,8 +566,39 @@ def test_keyboard_focus_has_a_visible_state(
|
||||
assert focus_target.hasFocus()
|
||||
assert application.focusWidget() is focus_target
|
||||
assert 'QPushButton[appointmentDate="true"]:focus' in APPOINTMENT_DRAWER_QSS
|
||||
assert "border-color: #8B9AD9;" in APPOINTMENT_DRAWER_QSS
|
||||
assert f"border-color: {PALETTE['focus']};" in APPOINTMENT_DRAWER_QSS
|
||||
|
||||
drawer.close()
|
||||
host.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("button_kind", ["date", "slot"])
|
||||
def test_appointment_hover_keeps_hit_target_stable_after_relayout(
|
||||
application: QApplication, button_kind: str,
|
||||
) -> None:
|
||||
"""Hovering must not move a time choice or restore a stale layout position."""
|
||||
from PySide6.QtCore import QEvent, QPoint, QPointF
|
||||
from PySide6.QtGui import QEnterEvent
|
||||
|
||||
host, drawer = _show_drawer(
|
||||
application, (1440, 900), repository=_VisualRepository(), autoload=True,
|
||||
)
|
||||
tomorrow = QDate.currentDate().addDays(1).toString("yyyy-MM-dd")
|
||||
button = drawer.date_buttons[tomorrow] if button_kind == "date" else drawer.slot_buttons["09:30-10:00"]
|
||||
original = button.geometry()
|
||||
try:
|
||||
for _ in range(3):
|
||||
application.sendEvent(button, QEnterEvent(QPointF(10, 10), QPointF(30, 34), QPointF(30, 34)))
|
||||
assert button.geometry() == original
|
||||
assert button.graphicsEffect() is None
|
||||
relocated = original.topLeft() + QPoint(12, 16)
|
||||
button.move(relocated) # A resize/reflow while the pointer stays inside.
|
||||
application.sendEvent(button, QEvent(QEvent.Type.Leave))
|
||||
assert button.pos() == relocated
|
||||
button.setGeometry(original)
|
||||
button.click()
|
||||
assert button.isChecked()
|
||||
finally:
|
||||
drawer.close()
|
||||
host.close()
|
||||
|
||||
Reference in New Issue
Block a user