返回 DeepSeek-Reasonix
tray_loop_windows_test.go
根目录 / desktop / tray_loop_windows_test.go
1 //go:build windows
2
3 package main
4
5 import (
6 "runtime"
7 "testing"
8
9 "golang.org/x/sys/windows"
10 )
11
12 func TestDesktopTrayLoopRunsOnLockedOSThread(t *testing.T) {
13 done := make(chan struct{})
14 runDesktopTrayLoop(func() {
15 first := windows.GetCurrentThreadId()
16 for i := 0; i < 100; i++ {
17 runtime.Gosched()
18 }
19 if got := windows.GetCurrentThreadId(); got != first {
20 t.Fatalf("tray loop moved OS threads: first=%d got=%d", first, got)
21 }
22 close(done)
23 })
24
25 select {
26 case <-done:
27 default:
28 t.Fatal("tray loop did not run")
29 }
30 }
31
31 lines GO