Files
MyGoNavi/internal/nativewindow/foreground_permission_windows_test.go
Syngnat fda0733f11 ️ perf(native-window): 优化 AI 独立窗口启动与交互
- 关闭时隐藏保活,重开复用现有进程并通过可见性版本消除竞态
- 拆分 AI 与工作台资源,使用启动状态白名单减少序列化开销
- 修复设置中心层级、Windows 前台切换及独立窗口关闭交互
- 补齐状态同步、断线重放与窗口生命周期回归测试
2026-07-21 23:40:17 +08:00

41 lines
987 B
Go

//go:build windows
package nativewindow
import (
"os"
"testing"
)
func TestGrantParentForegroundAccessTargetsDirectParent(t *testing.T) {
original := allowSetForegroundWindow
t.Cleanup(func() {
allowSetForegroundWindow = original
})
var processID uint32
allowSetForegroundWindow = func(candidate uint32) bool {
processID = candidate
return true
}
if err := grantParentForegroundAccess(); err != nil {
t.Fatalf("grantParentForegroundAccess error = %v", err)
}
if processID != uint32(os.Getppid()) {
t.Fatalf("foreground process ID = %d, want parent %d", processID, os.Getppid())
}
}
func TestGrantParentForegroundAccessReportsWindowsRejection(t *testing.T) {
original := allowSetForegroundWindow
t.Cleanup(func() {
allowSetForegroundWindow = original
})
allowSetForegroundWindow = func(uint32) bool { return false }
if err := grantParentForegroundAccess(); err == nil {
t.Fatal("grantParentForegroundAccess error = nil, want Windows rejection")
}
}