"""Cross-platform checks of Windows compatibility contracts.""" from __future__ import annotations from pathlib import Path from types import SimpleNamespace import pytest def test_downloaded_ffmpeg_is_discovered(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: from voice_dictation.core import compressor from voice_dictation.core.ffmpeg_setup import _EXE_NAME helper = tmp_path / ".dictate" / "bin" / _EXE_NAME helper.parent.mkdir(parents=True) helper.write_text("helper") monkeypatch.setattr(Path, "home", lambda: tmp_path) assert compressor._find_ffmpeg() == str(helper) def test_autopaste_releases_hotkey_modifiers(monkeypatch: pytest.MonkeyPatch) -> None: from voice_dictation.platform.windows import autopaste events: list[tuple[int, int, int, int]] = [] monkeypatch.setattr( autopaste.ctypes, "windll", SimpleNamespace(user32=SimpleNamespace(keybd_event=lambda *args: events.append(args))), raising=False, ) monkeypatch.setattr(autopaste.time, "sleep", lambda _: None) autopaste.WinAutoPaste().paste() assert events[:4] == [(key, 0, 2, 0) for key in (0x11, 0x12, 0x10, 0x20)] assert events[4:] == [(0x11, 0, 0, 0), (0x56, 0, 0, 0), (0x56, 0, 2, 0), (0x11, 0, 2, 0)]