| 1 | //go:build windows |
| 2 | |
| 3 | package systray |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | "unsafe" |
| 8 | ) |
| 9 | |
| 10 | func TestNotifyIconDataMatchesWindowsABI(t *testing.T) { |
| 11 | // shellapi.h declares uTimeout/uVersion as a single UINT union. A second |
| 12 | // UINT shifts guidItem even when mocked Shell_NotifyIcon calls succeed. |
| 13 | var n notifyIconData |
| 14 | wantSize, wantGUID, wantBalloon := uintptr(956), uintptr(936), uintptr(952) |
| 15 | if unsafe.Sizeof(n.Wnd) == 8 { |
| 16 | wantSize, wantGUID, wantBalloon = 976, 952, 968 |
| 17 | } |
| 18 | if got := unsafe.Offsetof(n.InfoTitle) - unsafe.Offsetof(n.TimeoutOrVersion); got != 4 { |
| 19 | t.Fatalf("timeout/version union occupies %d bytes, want 4", got) |
| 20 | } |
| 21 | if unsafe.Sizeof(n) != wantSize || unsafe.Offsetof(n.GuidItem) != wantGUID || unsafe.Offsetof(n.BalloonIcon) != wantBalloon { |
| 22 | t.Fatalf("native layout: size=%d GUID=%d balloon=%d; want %d/%d/%d", unsafe.Sizeof(n), unsafe.Offsetof(n.GuidItem), unsafe.Offsetof(n.BalloonIcon), wantSize, wantGUID, wantBalloon) |
| 23 | } |
| 24 | } |
| 25 |