mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-10 00:33:28 +08:00
- 关闭时隐藏保活,重开复用现有进程并通过可见性版本消除竞态 - 拆分 AI 与工作台资源,使用启动状态白名单减少序列化开销 - 修复设置中心层级、Windows 前台切换及独立窗口关闭交互 - 补齐状态同步、断线重放与窗口生命周期回归测试
41 lines
987 B
Go
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")
|
|
}
|
|
}
|