Files
zerorigin2019 0a1c1e82ea chore: 初始化仓库(零源工具箱 0.1.0 基线)
- Go 主进程 cmd/zerorigin(托盘常驻 + 触发器/规则/动作引擎)
- Wails v3 设置进程 cmd/settings(独立 module)
- 监督进程 cmd/watchdog(-supervise 异常重启)
- 构建脚本 build.bat / NSIS 安装包 deploy/、便携版 portable/
- 架构与 MVP 计划文档 docs/、阶段 0-4 验收记录 deploy/acceptance-0-4.md
2026-08-05 00:42:45 +08:00

32 lines
840 B
Go

package windows
import (
"testing"
"time"
)
// TestBenchSwitchDesktopCOM 测量 SwitchDesktopCOM 单次耗时(诊断用,非断言)。
func TestBenchSwitchDesktopCOM(t *testing.T) {
procCoInitializeEx.Call(0, coinitMultithreaded)
defer procCoUninitialize.Call()
ids0, _, err := queryDesktopState()
if err != nil || len(ids0) < 2 {
t.Skipf("need >= 2 desktops: %v", err)
}
for i := 0; i < 3; i++ {
s := time.Now()
if err := SwitchDesktopCOM(1); err != nil {
t.Fatalf("switch: %v", err)
}
t.Logf("SwitchDesktopCOM(1) 第%d次耗时: %v", i+1, time.Since(s))
time.Sleep(200 * time.Millisecond)
s = time.Now()
if err := SwitchDesktopCOM(-1); err != nil {
t.Fatalf("switch back: %v", err)
}
t.Logf("SwitchDesktopCOM(-1) 第%d次耗时: %v", i+1, time.Since(s))
time.Sleep(200 * time.Millisecond)
}
}