2026-08-04 15:46:12 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
2026-08-17 12:22:55 -07:00
|
|
|
func testDisplay(t *testing.T) *display {
|
|
|
|
|
t.Helper()
|
2026-08-13 07:10:39 -07:00
|
|
|
d := &display{}
|
|
|
|
|
for _, spec := range []struct {
|
|
|
|
|
dst **textFace
|
|
|
|
|
bold bool
|
|
|
|
|
size float64
|
|
|
|
|
}{
|
2026-08-17 12:22:55 -07:00
|
|
|
{&d.huge, true, 40},
|
|
|
|
|
{&d.big, true, 36},
|
|
|
|
|
{&d.text, false, 22},
|
|
|
|
|
{&d.textB, true, 22},
|
|
|
|
|
{&d.small, false, 17},
|
2026-08-13 07:10:39 -07:00
|
|
|
} {
|
|
|
|
|
face, err := loadFace(spec.bold, spec.size)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
*spec.dst = face
|
|
|
|
|
}
|
2026-08-17 12:22:55 -07:00
|
|
|
return d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPanelFitsScreen(t *testing.T) {
|
|
|
|
|
d := testDisplay(t)
|
2026-08-13 07:10:39 -07:00
|
|
|
if err := d.layout(600, 1024); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
2026-08-17 12:22:55 -07:00
|
|
|
if d.cellW < 6 {
|
|
|
|
|
t.Errorf("heat cells %dpx wide, want at least 6", d.cellW)
|
|
|
|
|
}
|
|
|
|
|
if end := d.cellsX + d.cellsW; end > d.resetX {
|
|
|
|
|
t.Errorf("heat cells run to %d, past the reset column at %d", end, d.resetX)
|
|
|
|
|
}
|
|
|
|
|
if last := d.rowYs[len(d.rowYs)-1] + rowH; last > d.resetBtn.y {
|
|
|
|
|
t.Errorf("rows end at %d, past the footer at %d", last, d.resetBtn.y)
|
2026-08-13 07:10:39 -07:00
|
|
|
}
|
2026-08-17 12:22:55 -07:00
|
|
|
t.Logf("cells %dpx wide, rows end at %d, footer at %d",
|
|
|
|
|
d.cellW, d.axisY+d.small.lineH, d.resetBtn.y)
|
2026-08-13 07:10:39 -07:00
|
|
|
}
|