feat(desktop-wake): add WeCom UIA warm-tree and ship n2-wake in 1.2.3
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 29s

Expose ensure_ui_ready via DuiLib GetAccessible inject path; package x86 native helpers for host/skill consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-02 08:42:38 +08:00
parent 3dc46b0555
commit 71091e38a9
29 changed files with 3088 additions and 3 deletions

View File

@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
"""jiangchang_desktop_wake:profile / 判定逻辑(不依赖真实企微窗)。"""
from __future__ import annotations
import unittest
from jiangchang_desktop_wake.profiles import list_profiles, load_profile
from jiangchang_desktop_wake.types import ProbeResult, Profile
from jiangchang_desktop_wake.uia_backend import markers_present
class ProfileTests(unittest.TestCase):
def test_list_contains_wecom(self):
ids = list_profiles()
self.assertIn("wecom", ids)
self.assertIn("generic", ids)
def test_load_wecom(self):
p = load_profile("wecom")
self.assertEqual(p.id, "wecom")
self.assertEqual(p.window_class, "WeWorkWindow")
self.assertIn("con_op", p.warm_markers)
self.assertGreaterEqual(p.warm_min_findall, 50)
self.assertIn("native_helper", p.wake_strategies)
self.assertIn("n2-wake", p.native_args or [])
def test_unknown_profile(self):
from jiangchang_desktop_wake.errors import DesktopWakeError
with self.assertRaises(DesktopWakeError):
load_profile("no-such-app-xyz")
class MarkerTests(unittest.TestCase):
def test_markers_present(self):
found, missing = markers_present(["con_op", "foo"], ["con_op", "searchedit"])
self.assertEqual(found, ["con_op"])
self.assertEqual(missing, ["searchedit"])
class ProbeWarmLogicTests(unittest.TestCase):
def test_probe_result_dict(self):
r = ProbeResult(
hwnd=1,
profile_id="wecom",
findall_count=3,
warm=False,
uia_available=True,
)
d = r.to_dict()
self.assertEqual(d["findall_count"], 3)
self.assertFalse(d["warm"])
def test_profile_from_dict_defaults(self):
p = Profile.from_dict({"id": "x"})
self.assertEqual(p.id, "x")
self.assertTrue(p.wake_strategies)
def test_wecom_prefers_native_helper(self):
p = load_profile("wecom")
self.assertEqual(p.wake_strategies[0], "activate")
self.assertEqual(p.wake_strategies[1], "native_helper")
def test_native_exe_present(self):
from pathlib import Path
import jiangchang_desktop_wake as pkg
native = Path(pkg.__file__).resolve().parent / "native"
exe = native / "desktop-wake.exe"
dll = native / "wecom_wake.dll"
self.assertTrue(exe.is_file(), f"missing {exe}; run native_src/build.ps1")
self.assertTrue(dll.is_file(), f"missing {dll}; run native_src/build.ps1")
if __name__ == "__main__":
unittest.main()