Skip to content

Commit

Permalink
Merge pull request #657 from ImperialCollegeLondon/add_pause_indicator
Browse files Browse the repository at this point in the history
Added 'PAUSED' to progress bar text when measurement script paused
  • Loading branch information
alexdewar authored Oct 22, 2024
2 parents 65594f4 + b8d79cb commit 9b5c78e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions finesse/gui/measure_script/script_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def _toggle_paused(self) -> None:
if self._pause_btn.text() == "Pause":
pub.sendMessage("measure_script.pause")
self._pause_btn.setText("Unpause")
self._progress_bar.setFormat("PAUSED (%p%)")
else:
pub.sendMessage("measure_script.unpause")
self._progress_bar.setFormat("%p%")
self._pause_btn.setText("Pause")

def closeEvent(self, event: QCloseEvent) -> None:
Expand Down
36 changes: 36 additions & 0 deletions tests/gui/measure_script/test_script_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,39 @@ def test_on_start_measuring(
f"Carrying out measurement {runner_measuring.current_measurement_count + 1}"
f" of {runner_measuring.current_measurement.measurements}",
)


def test_toggle_paused(
run_dialog: ScriptRunDialog,
runner: ScriptRunner,
sendmsg_mock: MagicMock,
qtbot: QtBot,
) -> None:
"""Test the widgets update correctly when paused/unpaused."""
with patch.object(run_dialog, "_progress_bar") as progress_bar_mock:
with patch.object(run_dialog, "_pause_btn") as pause_btn_mock:
pause_btn_mock.text.return_value = "Pause" # Start off in unpaused state
# Pause
run_dialog._toggle_paused()

# Check "pause" broadcast
sendmsg_mock.assert_any_call("measure_script.pause")

# Check progress bar string format is updated to display "PAUSED"
progress_bar_mock.setFormat.assert_called_with("PAUSED (%p%)")

# Check pause button text is updated
pause_btn_mock.setText.assert_called_once_with("Unpause")

pause_btn_mock.text.return_value = "Unpause" # Now in paused state
# Unpause
run_dialog._toggle_paused()

# Check "unpause" broadcast
sendmsg_mock.assert_any_call("measure_script.unpause")

# Check progress bar string format is reverted to display percentage
progress_bar_mock.setFormat.assert_called_with("%p%")

# Check pause button text is updated
pause_btn_mock.setText.assert_called_with("Pause")

0 comments on commit 9b5c78e

Please sign in to comment.