Files
Reims-Go/internal/appwindow/viewer_windows_test.go

56 lines
1.6 KiB
Go

//go:build windows
package appwindow
import (
"image"
"testing"
)
func TestViewerCaptionHit(t *testing.T) {
bitmap := &viewerBitmap{
width: 800, height: 500,
shape: viewerShape{caption: image.Rect(80, 0, 736, 22)},
}
area := image.Rect(50, 50, 450, 300)
for _, tc := range []struct {
name string
point image.Point
want uintptr
}{
{"title bar", image.Pt(220, 57), viewerHTCaption},
{"traffic lights", image.Pt(78, 57), viewerHTClient},
{"right controls", image.Pt(432, 57), viewerHTClient},
{"content", image.Pt(220, 73), viewerHTClient},
{"letterbox", image.Pt(220, 40), viewerHTClient},
} {
if got := viewerCaptionHit(bitmap, area, tc.point); got != tc.want {
t.Errorf("%s: got hit %d, want %d", tc.name, got, tc.want)
}
}
}
func TestViewerResizeHit(t *testing.T) {
bounds := viewerRect{left: -900, top: -40, right: -500, bottom: 260}
for _, tc := range []struct {
name string
point viewerPoint
want uintptr
}{
{"top left", viewerPoint{-900, -40}, viewerHTTopLeft},
{"top", viewerPoint{-700, -38}, viewerHTTop},
{"top right", viewerPoint{-501, -38}, viewerHTTopRight},
{"right", viewerPoint{-501, 100}, viewerHTRight},
{"bottom right", viewerPoint{-501, 259}, viewerHTBottomRight},
{"bottom", viewerPoint{-700, 259}, viewerHTBottom},
{"bottom left", viewerPoint{-899, 259}, viewerHTBottomLeft},
{"left", viewerPoint{-899, 100}, viewerHTLeft},
{"guest title controls", viewerPoint{-879, -20}, viewerHTClient},
{"outside", viewerPoint{-901, 100}, viewerHTClient},
} {
if got := viewerResizeHit(bounds, tc.point, 8); got != tc.want {
t.Errorf("%s: got hit %d, want %d", tc.name, got, tc.want)
}
}
}