fix stop button disabled during connection
This commit is contained in:
@@ -201,6 +201,52 @@ def test_toolbar_run_button_is_labelled(make_window):
|
||||
assert window.toolbar.btn_run.text() != label
|
||||
|
||||
|
||||
def test_stop_cancels_a_hung_connect(make_window):
|
||||
"""Stop must stay live and take effect instantly while connecting."""
|
||||
import time
|
||||
|
||||
import ui_check
|
||||
from orisys_app_shared.i18n import t
|
||||
|
||||
window = _show(make_window(sensor_type="box", source_mode="camera"), (1440, 880))
|
||||
stuck = ui_check._StuckWorker()
|
||||
window._ensure_workers = lambda: None
|
||||
window._box_worker = stuck
|
||||
window._finger_worker = stuck
|
||||
|
||||
window.toolbar.btn_run.setChecked(True)
|
||||
assert window._session_phase == "connecting"
|
||||
assert window.toolbar.btn_run.isEnabled(), "Stop is disabled while connecting"
|
||||
assert window.toolbar.btn_run.text() == t("toolbar.cancel_label")
|
||||
assert window.act_stop.isEnabled()
|
||||
|
||||
started = time.perf_counter()
|
||||
window.toolbar.btn_run.setChecked(False)
|
||||
elapsed = time.perf_counter() - started
|
||||
assert elapsed < 0.5, f"Stop blocked the GUI for {elapsed:.2f}s"
|
||||
assert not window._running
|
||||
assert stuck.thread_still_owned, "Stop abandoned the still-running worker thread"
|
||||
|
||||
|
||||
def test_escape_cancels_a_hung_connect(make_window):
|
||||
import time
|
||||
|
||||
import ui_check
|
||||
|
||||
window = _show(make_window(sensor_type="box", source_mode="camera"), (1440, 880))
|
||||
stuck = ui_check._StuckWorker()
|
||||
window._ensure_workers = lambda: None
|
||||
window._box_worker = stuck
|
||||
window._finger_worker = stuck
|
||||
|
||||
window.toolbar.btn_run.setChecked(True)
|
||||
assert window.act_stop.shortcut().toString() == "Esc"
|
||||
started = time.perf_counter()
|
||||
window._on_stop_shortcut()
|
||||
assert time.perf_counter() - started < 0.5
|
||||
assert not window._running
|
||||
|
||||
|
||||
def test_theme_switch_updates_panels(make_window):
|
||||
window = _show(make_window(), (1400, 880))
|
||||
window._set_theme("light")
|
||||
|
||||
Reference in New Issue
Block a user