fix: retain unknown startup windows and expose native dispatch errors
This commit is contained in:
1 parent
46c3e72364
commit
ffa7e84d43
4 files changed
+154
-8
No files matched your search
@@ -186,3 +186,47 @@ def test_startup_exit_does_not_hide_late_database_address(tmp_path, monkeypatch)
|
||||
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
|
||||
assert result['status'] == 'RETAINED'
|
||||
assert result['release']['addresses']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('window_class,title', [('CustomPrompt', 'Database action pending'),
|
||||
('Afx:tool', ''), ('UAC_InputIndicatorOverlayWnd', 'Unknown prompt'), ('UAC Input Indicator', ' ')])
|
||||
def test_enabled_empty_main_with_unaccounted_owned_window_is_never_closed(tmp_path, monkeypatch, window_class, title):
|
||||
import win32gui
|
||||
job, records, messages = startup_fixture(tmp_path, monkeypatch)
|
||||
monkeypatch.setattr(win32gui, 'EnumWindows', lambda fn, arg: [fn(hwnd, arg) for hwnd in (100, 200)])
|
||||
monkeypatch.setattr(win32gui, 'GetClassName', lambda hwnd: 'Afx:main' if hwnd == 100 else window_class)
|
||||
monkeypatch.setattr(win32gui, 'GetWindowText', lambda hwnd: 'Expedition PCB' if hwnd == 100 else title)
|
||||
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
|
||||
assert result['status'] == 'RETAINED' and not result['release']['safe_to_continue']
|
||||
assert messages == [] and records
|
||||
assert result['unknown_windows'] == [{'hwnd': 200, 'class': window_class, 'title': title, 'enabled': True}]
|
||||
assert json.loads((tmp_path/'startup-close.json').read_text(encoding='utf-8'))['unknown_windows'] == result['unknown_windows']
|
||||
|
||||
|
||||
def test_empty_title_known_uac_windows_are_accounted_for_before_normal_close(tmp_path, monkeypatch):
|
||||
import win32gui, win32con
|
||||
job, records, messages = startup_fixture(tmp_path, monkeypatch)
|
||||
classes = {100: 'Afx:main', 200: 'UAC_InputIndicatorOverlayWnd', 201: 'UAC Input Indicator'}
|
||||
monkeypatch.setattr(win32gui, 'EnumWindows', lambda fn, arg: [fn(hwnd, arg) for hwnd in classes])
|
||||
monkeypatch.setattr(win32gui, 'GetClassName', classes.__getitem__)
|
||||
monkeypatch.setattr(win32gui, 'GetWindowText', lambda hwnd: 'Expedition PCB' if hwnd == 100 else '')
|
||||
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
|
||||
assert result['status'] == 'CLOSED' and messages == [(100, win32con.WM_CLOSE)]
|
||||
assert result['unknown_windows'] == []
|
||||
assert [entry['hwnd'] for entry in result['benign_auxiliary_windows']] == [200, 201]
|
||||
|
||||
|
||||
def test_custom_prompt_must_disappear_before_main_close(tmp_path, monkeypatch):
|
||||
from types import SimpleNamespace
|
||||
import win32gui
|
||||
job, records, messages = startup_fixture(tmp_path, monkeypatch)
|
||||
ticks = [0.0]
|
||||
monkeypatch.setattr(win32gui, 'EnumWindows', lambda fn, arg:
|
||||
[fn(hwnd, arg) for hwnd in ((100, 200) if ticks[0] == 0 else (100,))])
|
||||
monkeypatch.setattr(win32gui, 'GetClassName', lambda hwnd: 'Afx:main' if hwnd == 100 else 'CustomPrompt')
|
||||
monkeypatch.setattr(win32gui, 'GetWindowText', lambda hwnd: 'Expedition PCB' if hwnd == 100 else 'Still processing')
|
||||
monkeypatch.setattr(failed_session, 'time', SimpleNamespace(monotonic=lambda: ticks[0],
|
||||
sleep=lambda seconds: ticks.__setitem__(0, ticks[0] + seconds)))
|
||||
result = failed_session.close_failed_startup(job, 12, timeout_seconds=1)
|
||||
assert result['status'] == 'CLOSED' and ticks[0] > 0
|
||||
assert len(messages) == 1
|
||||
Reference in new issue
Block a user