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
This commit is contained in:
commit
0a1c1e82ea
188 files changed
+19926
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package windows
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestIsFullscreenRect 验证覆盖判定边界(94%/95%/96%、无交集、跨屏)。
|
||||
func TestIsFullscreenRect(t *testing.T) {
|
||||
screen := MonitorRect{Left: 0, Top: 0, Right: 1920, Bottom: 1080}
|
||||
cases := []struct {
|
||||
name string
|
||||
win MonitorRect
|
||||
want bool
|
||||
}{
|
||||
{"完全覆盖", MonitorRect{0, 0, 1920, 1080}, true},
|
||||
{"无边框全屏", MonitorRect{0, 0, 1920, 1080}, true},
|
||||
{"任务栏遮挡(94%)", MonitorRect{0, 0, 1920, 1015}, false}, // 1015/1080 ≈ 93.9%
|
||||
{"任务栏遮挡(96%)", MonitorRect{0, 0, 1920, 1040}, true}, // 1040/1080 ≈ 96.3%
|
||||
{"普通窗口", MonitorRect{100, 100, 1200, 800}, false},
|
||||
{"无交集", MonitorRect{3000, 3000, 4000, 4000}, false},
|
||||
{"覆盖95%临界", MonitorRect{0, 0, 1920, 1026}, true}, // 1026/1080 = 95.0%
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := IsFullscreenRect(c.win, screen, 0); got != c.want {
|
||||
t.Errorf("%s: IsFullscreenRect = %v, want %v", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsFullscreenRectMultiMonitor 验证跨屏窗口按交集最大屏幕判定。
|
||||
func TestIsFullscreenRectMultiMonitor(t *testing.T) {
|
||||
screen := MonitorRect{Left: 1920, Top: 0, Right: 3840, Bottom: 1080}
|
||||
win := MonitorRect{Left: 1900, Top: 0, Right: 3840, Bottom: 1080} // 几乎全盖副屏
|
||||
if !IsFullscreenRect(win, screen, 0) {
|
||||
t.Fatal("near-fullscreen on secondary monitor should be true")
|
||||
}
|
||||
}
|
||||
|
||||
// TestFullscreenWatcherLifecycle 验证轮询器 Start/Stop 幂等与状态可读。
|
||||
func TestFullscreenWatcherLifecycle(t *testing.T) {
|
||||
w := NewFullscreenWatcher()
|
||||
w.Start()
|
||||
w.Start() // 幂等
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
_ = w.IsFullscreen() // 可读(值不校验:取决于会话前台窗口)
|
||||
w.Stop()
|
||||
w.Stop() // 幂等
|
||||
// 重启
|
||||
w.Start()
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
w.Stop()
|
||||
}
|
||||
Reference in new issue
Block a user