|
| @@ -243,13 +243,15 @@ func TestPaletteCtrlNAndCtrlPNavigate(t *testing.T) { |
| 243 | | } | 243 | | } |
| 244 | | | 244 | | |
| 245 | | func TestPaletteModalGeometry(t *testing.T) { | 245 | | func TestPaletteModalGeometry(t *testing.T) { |
| 246 | - | auto := domain.PaletteConfig{} | 246 | + | type testCase struct { |
| 247 | - | tests := []struct { | | | |
| 248 | | name string | 247 | | name string |
| 249 | | size domain.Size | 248 | | size domain.Size |
| 250 | | cfg domain.PaletteConfig | 249 | | cfg domain.PaletteConfig |
| 251 | | want domain.Rect | 250 | | want domain.Rect |
| 252 | - | }{ | 251 | + | } |
| | | 252 | + | |
| | | 253 | + | auto := domain.PaletteConfig{} |
| | | 254 | + | tests := []testCase{ |
| 253 | | {name: "auto 95 column shelf", size: domain.Size{Cols: 95, Rows: 40}, cfg: auto, want: domain.Rect{X: 0, Y: 28, Width: 95, Height: 11}}, | 255 | | {name: "auto 95 column shelf", size: domain.Size{Cols: 95, Rows: 40}, cfg: auto, want: domain.Rect{X: 0, Y: 28, Width: 95, Height: 11}}, |
| 254 | | {name: "auto 96 column rail", size: domain.Size{Cols: 96, Rows: 40}, cfg: auto, want: domain.Rect{X: 31, Y: 28, Width: 64, Height: 11}}, | 256 | | {name: "auto 96 column rail", size: domain.Size{Cols: 96, Rows: 40}, cfg: auto, want: domain.Rect{X: 31, Y: 28, Width: 64, Height: 11}}, |
| 255 | | {name: "auto 120 column rail", size: domain.Size{Cols: 120, Rows: 40}, cfg: auto, want: domain.Rect{X: 55, Y: 28, Width: 64, Height: 11}}, | 257 | | {name: "auto 120 column rail", size: domain.Size{Cols: 120, Rows: 40}, cfg: auto, want: domain.Rect{X: 55, Y: 28, Width: 64, Height: 11}}, |
|
| @@ -258,20 +260,10 @@ func TestPaletteModalGeometry(t *testing.T) { |
| 258 | | for _, anchor := range []domain.Anchor{domain.AnchorTopLeft, domain.AnchorTop, domain.AnchorTopRight, domain.AnchorLeft, domain.AnchorCenter, domain.AnchorRight, domain.AnchorBottomLeft, domain.AnchorBottom, domain.AnchorBottomRight} { | 260 | | for _, anchor := range []domain.Anchor{domain.AnchorTopLeft, domain.AnchorTop, domain.AnchorTopRight, domain.AnchorLeft, domain.AnchorCenter, domain.AnchorRight, domain.AnchorBottomLeft, domain.AnchorBottom, domain.AnchorBottomRight} { |
| 259 | | wantX := map[domain.Anchor]int{domain.AnchorTopLeft: 1, domain.AnchorTop: 28, domain.AnchorTopRight: 55, domain.AnchorLeft: 1, domain.AnchorCenter: 28, domain.AnchorRight: 55, domain.AnchorBottomLeft: 1, domain.AnchorBottom: 28, domain.AnchorBottomRight: 55}[anchor] | 261 | | wantX := map[domain.Anchor]int{domain.AnchorTopLeft: 1, domain.AnchorTop: 28, domain.AnchorTopRight: 55, domain.AnchorLeft: 1, domain.AnchorCenter: 28, domain.AnchorRight: 55, domain.AnchorBottomLeft: 1, domain.AnchorBottom: 28, domain.AnchorBottomRight: 55}[anchor] |
| 260 | | wantY := map[domain.Anchor]int{domain.AnchorTopLeft: 1, domain.AnchorTop: 1, domain.AnchorTopRight: 1, domain.AnchorLeft: 14, domain.AnchorCenter: 14, domain.AnchorRight: 14, domain.AnchorBottomLeft: 28, domain.AnchorBottom: 28, domain.AnchorBottomRight: 28}[anchor] | 262 | | wantY := map[domain.Anchor]int{domain.AnchorTopLeft: 1, domain.AnchorTop: 1, domain.AnchorTopRight: 1, domain.AnchorLeft: 14, domain.AnchorCenter: 14, domain.AnchorRight: 14, domain.AnchorBottomLeft: 28, domain.AnchorBottom: 28, domain.AnchorBottomRight: 28}[anchor] |
| 261 | - | tests = append(tests, struct { | 263 | + | tests = append(tests, testCase{name: anchor.String(), size: domain.Size{Cols: 120, Rows: 40}, cfg: domain.PaletteConfig{Anchor: anchor, AnchorSet: true}, want: domain.Rect{X: wantX, Y: wantY, Width: 64, Height: 11}}) |
| 262 | - | name string | | | |
| 263 | - | size domain.Size | | | |
| 264 | - | cfg domain.PaletteConfig | | | |
| 265 | - | want domain.Rect | | | |
| 266 | - | }{name: anchor.String(), size: domain.Size{Cols: 120, Rows: 40}, cfg: domain.PaletteConfig{Anchor: anchor, AnchorSet: true}, want: domain.Rect{X: wantX, Y: wantY, Width: 64, Height: 11}}) | | | |
| 267 | | } | 264 | | } |
| 268 | | for _, anchor := range []domain.Anchor{domain.AnchorLeft, domain.AnchorCenter, domain.AnchorRight} { | 265 | | for _, anchor := range []domain.Anchor{domain.AnchorLeft, domain.AnchorCenter, domain.AnchorRight} { |
| 269 | - | tests = append(tests, struct { | 266 | + | tests = append(tests, testCase{name: "narrow " + anchor.String(), size: domain.Size{Cols: 95, Rows: 40}, cfg: domain.PaletteConfig{Anchor: anchor, AnchorSet: true}, want: domain.Rect{X: 0, Y: 14, Width: 95, Height: 11}}) |
| 270 | - | name string | | | |
| 271 | - | size domain.Size | | | |
| 272 | - | cfg domain.PaletteConfig | | | |
| 273 | - | want domain.Rect | | | |
| 274 | - | }{name: "narrow " + anchor.String(), size: domain.Size{Cols: 95, Rows: 40}, cfg: domain.PaletteConfig{Anchor: anchor, AnchorSet: true}, want: domain.Rect{X: 0, Y: 14, Width: 95, Height: 11}}) | | | |
| 275 | | } | 267 | | } |
| 276 | | | 268 | | |
| 277 | | for _, tt := range tests { | 269 | | for _, tt := range tests { |