重构 Autocal 采集页:单一队列与控制器驱动的主按钮
选点、对准、加载与录像分散在两个面板,状态靠隐藏相位判断。现改由不依赖 Qt 的采集控制器驱动,并加入录像选项、汇总平铺副本、保持到时自动结束、会话结束回到空闲,以及无设备时的模拟采集。已运行 Autocal 非 Qt 测试并通过范围内门禁;界面测试待 Windows 复核,未做实机验收。
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
"""Opening a session folder in the platform file manager.
|
||||
|
||||
The operator needs the folder the recording is in, not a dialog that only shows a
|
||||
path string. The launch is mocked here, because the test must assert the exact
|
||||
argument the platform file manager receives — ``explorer /select,<file>`` is a
|
||||
single argument whose comma and quoting are the part that breaks silently.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from orisys_autocal.ui import reveal as reveal_module
|
||||
|
||||
|
||||
def _capture_launch(monkeypatch) -> list:
|
||||
calls: list = []
|
||||
monkeypatch.setattr(reveal_module.subprocess, "Popen", lambda command: calls.append(command))
|
||||
return calls
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("platform", "executable"),
|
||||
[("win32", "explorer"), ("linux", "xdg-open"), ("darwin", "open")],
|
||||
)
|
||||
def test_revealing_a_folder_uses_the_platform_file_manager(
|
||||
tmp_path, monkeypatch, platform, executable
|
||||
):
|
||||
folder = tmp_path / "session"
|
||||
folder.mkdir()
|
||||
monkeypatch.setattr(reveal_module.sys, "platform", platform)
|
||||
calls = _capture_launch(monkeypatch)
|
||||
|
||||
assert reveal_module.reveal(folder) is True
|
||||
|
||||
assert calls == [[executable, str(folder)]]
|
||||
|
||||
|
||||
def test_a_selected_file_is_highlighted_with_explorer(tmp_path, monkeypatch):
|
||||
folder = tmp_path / "session"
|
||||
folder.mkdir()
|
||||
video = folder / "raw_0001.mp4"
|
||||
video.write_bytes(b"video")
|
||||
monkeypatch.setattr(reveal_module.sys, "platform", "win32")
|
||||
calls = _capture_launch(monkeypatch)
|
||||
|
||||
assert reveal_module.reveal(folder, select=video) is True
|
||||
|
||||
# One command-line string: the comma belongs to the switch and the path is
|
||||
# quoted, which is what explorer expects for a path with spaces.
|
||||
assert calls == [f'explorer /select,"{video}"']
|
||||
|
||||
|
||||
def test_a_selected_file_that_is_gone_falls_back_to_the_folder(tmp_path, monkeypatch):
|
||||
folder = tmp_path / "session"
|
||||
folder.mkdir()
|
||||
missing = folder / "raw_0001.mp4"
|
||||
monkeypatch.setattr(reveal_module.sys, "platform", "win32")
|
||||
calls = _capture_launch(monkeypatch)
|
||||
|
||||
assert reveal_module.reveal(folder, select=missing) is True
|
||||
|
||||
assert calls == [["explorer", str(folder)]]
|
||||
|
||||
|
||||
def test_a_missing_path_is_not_opened(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(reveal_module.sys, "platform", "win32")
|
||||
calls = _capture_launch(monkeypatch)
|
||||
|
||||
assert reveal_module.reveal(tmp_path / "gone") is False
|
||||
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_no_path_is_not_opened(monkeypatch):
|
||||
calls = _capture_launch(monkeypatch)
|
||||
|
||||
assert reveal_module.reveal(None) is False
|
||||
assert reveal_module.reveal("") is False
|
||||
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_a_failed_launch_is_reported_instead_of_raised(tmp_path, monkeypatch):
|
||||
folder = tmp_path / "session"
|
||||
folder.mkdir()
|
||||
monkeypatch.setattr(reveal_module.sys, "platform", "win32")
|
||||
|
||||
def fail(command):
|
||||
raise OSError("no file manager")
|
||||
|
||||
monkeypatch.setattr(reveal_module.subprocess, "Popen", fail)
|
||||
|
||||
assert reveal_module.reveal(folder) is False
|
||||
Reference in New Issue
Block a user