feat: 桌面启动器改 XiaoheAgent.app 形态——icns 图标、无 .command 后缀,Linux 桌面项同步带图标
This commit is contained in:
@@ -85,3 +85,55 @@ class TestSyncWorkspace:
|
||||
sync_mod.sync_workspace(workspace)
|
||||
report = sync_mod.sync_workspace(workspace, force=True)
|
||||
assert report["added"]
|
||||
|
||||
|
||||
class TestCreateLauncher:
|
||||
@pytest.fixture()
|
||||
def fake_home(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
|
||||
home = tmp_path / "home"
|
||||
(home / "Desktop").mkdir(parents=True)
|
||||
monkeypatch.setattr(Path, "home", staticmethod(lambda: home))
|
||||
return home
|
||||
|
||||
def test_macos_app_bundle_with_icon(
|
||||
self, runtime: Path, fake_home: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
(runtime / "assets" / "icon").mkdir(parents=True)
|
||||
(runtime / "assets" / "icon" / "XiaoheAgent.icns").write_bytes(b"icns")
|
||||
legacy = fake_home / "Desktop" / "XiaoheAgent.command"
|
||||
legacy.write_text("#!/bin/sh\n")
|
||||
monkeypatch.setattr(
|
||||
sync_mod.os, "uname", lambda: type("U", (), {"sysname": "Darwin"})
|
||||
)
|
||||
sync_mod._create_launcher()
|
||||
app = fake_home / "Desktop" / "XiaoheAgent.app"
|
||||
executable = app / "Contents" / "MacOS" / "XiaoheAgent"
|
||||
assert (app / "Contents" / "Info.plist").is_file()
|
||||
assert (app / "Contents" / "Resources" / "XiaoheAgent.icns").is_file()
|
||||
assert executable.stat().st_mode & 0o111
|
||||
assert "xiaohe" in executable.read_text()
|
||||
assert not legacy.exists() # superseded .command removed
|
||||
|
||||
def test_linux_desktop_entry_with_icon(
|
||||
self, runtime: Path, fake_home: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
(runtime / "assets" / "icon").mkdir(parents=True)
|
||||
(runtime / "assets" / "icon" / "xiaohe-icon-512.png").write_bytes(b"png")
|
||||
monkeypatch.setattr(
|
||||
sync_mod.os, "uname", lambda: type("U", (), {"sysname": "Linux"})
|
||||
)
|
||||
sync_mod._create_launcher()
|
||||
entry = (
|
||||
fake_home / ".local" / "share" / "applications" / "XiaoheAgent.desktop"
|
||||
)
|
||||
assert "Icon=xiaohe-agent" in entry.read_text()
|
||||
assert (
|
||||
fake_home
|
||||
/ ".local"
|
||||
/ "share"
|
||||
/ "icons"
|
||||
/ "hicolor"
|
||||
/ "512x512"
|
||||
/ "apps"
|
||||
/ "xiaohe-agent.png"
|
||||
).is_file()
|
||||
|
||||
Reference in New Issue
Block a user