fixed commetn from songxiao
This commit is contained in:
@@ -247,11 +247,27 @@ class _StuckWorker(RecordSinkMixin):
|
||||
#: Zeroing requests, and the confirmation callback the window installs.
|
||||
self.reset_requests = 0
|
||||
self.on_reset_applied = None
|
||||
#: Pause state, so the window's Pause button has something to drive. The real
|
||||
#: worker's contract: pause stops computing and keeps the device open.
|
||||
self.is_paused = False
|
||||
self.pause_requests = 0
|
||||
#: Filters handed over before a session, and what the fake device reports
|
||||
#: as in effect (this stub has no ``configure``, so it reports nothing).
|
||||
self.filter_settings_value = FilterSettings()
|
||||
self.filter_state_value: dict = {}
|
||||
|
||||
def pause(self) -> None:
|
||||
self.is_paused = True
|
||||
self.pause_requests += 1
|
||||
|
||||
def resume(self) -> None:
|
||||
self.is_paused = False
|
||||
self.pause_requests += 1
|
||||
|
||||
@property
|
||||
def paused(self) -> bool:
|
||||
return bool(self.is_paused)
|
||||
|
||||
def set_filter_settings(self, settings) -> None:
|
||||
self.filter_settings_value = settings
|
||||
|
||||
@@ -1072,10 +1088,18 @@ def main() -> int:
|
||||
window.toolbar.btn_run.objectName() == "primaryButton",
|
||||
f"idle Run is not the filled primary: {window.toolbar.btn_run.objectName()!r}",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_run.text() == t("toolbar.run_label"),
|
||||
f"the idle transport does not say it runs: {window.toolbar.btn_run.text()!r}",
|
||||
)
|
||||
check(
|
||||
not window.toolbar.btn_record.isEnabled(),
|
||||
"recording is offered without a session",
|
||||
)
|
||||
check(
|
||||
not window.toolbar.btn_stop.isEnabled(),
|
||||
"Stop is offered before a session exists",
|
||||
)
|
||||
|
||||
stuck = _StuckWorker()
|
||||
window._ensure_workers = lambda: None
|
||||
@@ -1084,22 +1108,62 @@ def main() -> int:
|
||||
window.toolbar.btn_run.setChecked(True)
|
||||
app.processEvents()
|
||||
check(
|
||||
window.toolbar.btn_run.objectName() == "dangerButton",
|
||||
window.toolbar.btn_run.text() == t("toolbar.pause"),
|
||||
f"the acquiring transport does not offer pause: "
|
||||
f"{window.toolbar.btn_run.text()!r}",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_stop.objectName() == "dangerButton",
|
||||
"Cancel is not the filled action while a connect hangs",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_stop.text() == t("toolbar.cancel_label"),
|
||||
f"the connecting Stop does not advertise cancel: "
|
||||
f"{window.toolbar.btn_stop.text()!r}",
|
||||
)
|
||||
stuck.emit(_fake_packet(1))
|
||||
window._on_run_tick()
|
||||
app.processEvents()
|
||||
check(window._session_phase == "running", "the session never reached running")
|
||||
check(
|
||||
window.toolbar.btn_run.objectName() == "dangerOutline",
|
||||
f"Stop competes with the record action: "
|
||||
f"{window.toolbar.btn_run.objectName()!r}",
|
||||
window.toolbar.btn_stop.objectName() == "dangerOutline",
|
||||
f"Stop stays filled while a session merely acquires: "
|
||||
f"{window.toolbar.btn_stop.objectName()!r}",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_stop.text() == t("toolbar.stop_label"),
|
||||
f"Stop lost its label once the connect returned: "
|
||||
f"{window.toolbar.btn_stop.text()!r}",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_record.objectName() == "primaryButton",
|
||||
"the record action is not the filled primary while acquiring",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_run.objectName() == "ghostButton",
|
||||
f"the transport competes with the filled record action: "
|
||||
f"{window.toolbar.btn_run.objectName()!r}",
|
||||
)
|
||||
# Unchecking the transport pauses the session; it must not end it, and it must
|
||||
# leave the way out (the red Stop) exactly where it was.
|
||||
window.toolbar.btn_run.setChecked(False)
|
||||
app.processEvents()
|
||||
check(
|
||||
window.toolbar.btn_run.text() == t("toolbar.resume_label"),
|
||||
f"the paused transport does not offer resume: {window.toolbar.btn_run.text()!r}",
|
||||
)
|
||||
check(
|
||||
window._session_phase == "running"
|
||||
and window.toolbar.btn_stop.isEnabled()
|
||||
and window.toolbar.btn_reset.isEnabled(),
|
||||
"pausing the transport did not leave a running, stoppable session",
|
||||
)
|
||||
window.toolbar.btn_run.setChecked(True)
|
||||
app.processEvents()
|
||||
check(
|
||||
window.toolbar.btn_run.text() == t("toolbar.pause"),
|
||||
f"the resumed transport does not offer pause: {window.toolbar.btn_run.text()!r}",
|
||||
)
|
||||
check(
|
||||
window._calibration_summary() == t("status.calibrated_all"),
|
||||
f"a fully calibrated packet is not reported as such: "
|
||||
@@ -1112,7 +1176,8 @@ def main() -> int:
|
||||
"stopping the recording is not the filled danger",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_run.objectName() == "dangerOutline",
|
||||
window.toolbar.btn_run.objectName() not in ("primaryButton", "dangerButton")
|
||||
and window.toolbar.btn_stop.objectName() not in ("primaryButton", "dangerButton"),
|
||||
"two filled actions share the rail while recording",
|
||||
)
|
||||
|
||||
@@ -1183,22 +1248,22 @@ def main() -> int:
|
||||
|
||||
check(window._session_phase == "connecting", "run did not enter the connecting phase")
|
||||
check(
|
||||
window.toolbar.btn_run.isEnabled(),
|
||||
window.toolbar.btn_stop.isEnabled(),
|
||||
"Stop is disabled while connecting — a hung connect could not be cancelled",
|
||||
)
|
||||
check(window.toolbar.btn_run.isChecked(), "run button did not latch into the stop state")
|
||||
check(window.toolbar.btn_run.isChecked(), "the transport does not show acquiring")
|
||||
check(
|
||||
window.toolbar.btn_run.text() == t("toolbar.cancel_label"),
|
||||
f"connecting label is not the cancel label: {window.toolbar.btn_run.text()!r}",
|
||||
window.toolbar.btn_stop.text() == t("toolbar.cancel_label"),
|
||||
f"connecting label is not the cancel label: {window.toolbar.btn_stop.text()!r}",
|
||||
)
|
||||
check(
|
||||
window.toolbar.btn_run.toolTip() == t("toolbar.cancel_tip"),
|
||||
window.toolbar.btn_stop.toolTip() == t("toolbar.cancel_tip"),
|
||||
"connecting tooltip does not explain how to cancel",
|
||||
)
|
||||
check(window.act_stop.isEnabled(), "Stop shortcut is disabled while connecting")
|
||||
|
||||
started = time.perf_counter()
|
||||
window.toolbar.btn_run.setChecked(False)
|
||||
window.toolbar.btn_stop.click()
|
||||
elapsed = time.perf_counter() - started
|
||||
check(elapsed < 0.5, f"Stop blocked the GUI for {elapsed:.2f}s on a hung connect")
|
||||
check(not window._running, "session stayed active after Stop")
|
||||
@@ -3140,17 +3205,22 @@ def main() -> int:
|
||||
)
|
||||
check(replay_window.toolbar.btn_run.isEnabled(), "the replay has no transport")
|
||||
|
||||
# The replay view offers an unconditional stop (the rail's second button), because
|
||||
# the transport is a play/pause toggle and "which one is stuck?" is not a question
|
||||
# to ask an operator in front of a frozen picture.
|
||||
# The replay view stops through the rail's own Stop button — the same control the
|
||||
# live view uses — because the transport is a play/pause toggle and "which one is
|
||||
# stuck?" is not a question to ask an operator in front of a frozen picture. The
|
||||
# tracker reset owns no device here, so it is disabled rather than repurposed.
|
||||
check(
|
||||
replay_window.toolbar.reset_role() == "stop",
|
||||
"the replay view has no stop button",
|
||||
not replay_window.toolbar.btn_reset.isEnabled(),
|
||||
"the replay view offers to zero a device tracker it has not got",
|
||||
)
|
||||
check(
|
||||
replay_window.toolbar.btn_reset.text() == t("toolbar.stop_playback"),
|
||||
f"the stop button is not labelled as one: "
|
||||
f"{replay_window.toolbar.btn_reset.text()!r}",
|
||||
replay_window.toolbar.btn_stop.text() == t("toolbar.stop_label"),
|
||||
f"the replay's stop button is not labelled as one: "
|
||||
f"{replay_window.toolbar.btn_stop.text()!r}",
|
||||
)
|
||||
check(
|
||||
not replay_window.toolbar.btn_stop.isEnabled(),
|
||||
"a stop is offered while nothing is running",
|
||||
)
|
||||
# Start playing so there is something to stop, then stop it with that button.
|
||||
replay_window.toolbar.btn_run.setChecked(True)
|
||||
@@ -3160,10 +3230,10 @@ def main() -> int:
|
||||
"the playback did not start, so the stop check would prove nothing",
|
||||
)
|
||||
check(
|
||||
replay_window.toolbar.btn_reset.isEnabled(),
|
||||
replay_window.toolbar.btn_stop.isEnabled(),
|
||||
"the stop is not offered while the transport is playing",
|
||||
)
|
||||
replay_window.toolbar.btn_reset.click()
|
||||
replay_window.toolbar.btn_stop.click()
|
||||
app.processEvents()
|
||||
check(
|
||||
not replay_window.toolbar.btn_run.isChecked(),
|
||||
|
||||
Reference in New Issue
Block a user