Improved progress bar detections.

This commit is contained in:
Storm Dragon
2026-08-06 13:49:53 -04:00
parent 7593c8d0b3
commit ee441c319a
3 changed files with 129 additions and 26 deletions
+79
View File
@@ -290,3 +290,82 @@ def test_explicit_progress_delta_ignores_percentage_in_bracketed_prose():
assert not command.is_explicit_progress_delta(
"Release notes [issue #749] are 41% complete"
)
@pytest.mark.unit
def test_progress_detector_beeps_for_curl_classic_repaint_with_trailing_text():
progress_module = _load_progress_module()
command = progress_module.command()
sample = (
"53 537.8M 53 285.8M 0 0 9.48M 0 00:56 00:30 00:26 9.94M "
"Executing cabextract -q -d /home/Username/.local/wine64/dosdevices/"
"c:/windows/syswow64 -F dx8vb.dll /home/Username/.cache/winetricks/"
"dx8vb/DX81NTger.exe"
)
command.env = {
"commandBuffer": {
"progress_monitoring": True,
"lastProgressValue": -1,
"lastProgressTime": 0,
},
"runtime": {
"DebugManager": Mock(write_debug_out=Mock()),
"ScreenManager": Mock(is_screen_change=Mock(return_value=False)),
"CursorManager": Mock(is_cursor_vertical_move=Mock(return_value=False)),
},
"screen": {
"new_delta": sample,
"new_delta_is_typing": False,
"new_content_text": sample,
"old_cursor": {"x": 0, "y": 0},
"new_cursor": {"x": 0, "y": 0},
},
}
command.play_progress_tone = Mock()
assert len(sample) > 200
command.run()
command.play_progress_tone.assert_called_once_with(53.0)
assert command.env["commandBuffer"]["lastProgressValue"] == 53.0
@pytest.mark.unit
def test_progress_detector_ignores_curl_like_fields_with_mismatched_percentages():
progress_module = _load_progress_module()
command = progress_module.command()
sample = (
"53 537.8M 52 285.8M 0 0 9.48M 0 00:56 00:30 00:26 9.94M "
"ordinary numeric report with enough trailing text to cross the long "
"delta filter without representing a coherent download progress row "
"or providing trustworthy percentage information"
)
command.env = {
"commandBuffer": {
"progress_monitoring": True,
"lastProgressValue": -1,
"lastProgressTime": 0,
},
"runtime": {
"DebugManager": Mock(write_debug_out=Mock()),
"ScreenManager": Mock(is_screen_change=Mock(return_value=False)),
"CursorManager": Mock(is_cursor_vertical_move=Mock(return_value=False)),
},
"screen": {
"new_delta": sample,
"new_delta_is_typing": False,
"new_content_text": sample,
"old_cursor": {"x": 0, "y": 0},
"new_cursor": {"x": 0, "y": 0},
},
}
command.play_activity_beep = Mock()
command.play_progress_tone = Mock()
assert len(sample) > 200
command.run()
command.play_activity_beep.assert_not_called()
command.play_progress_tone.assert_not_called()