package main import "testing" func testDisplay(t *testing.T) *display { t.Helper() d := &display{} for _, spec := range []struct { dst **textFace bold bool size float64 }{ {&d.huge, true, 40}, {&d.big, true, 36}, {&d.text, false, 22}, {&d.textB, true, 22}, {&d.small, false, 17}, } { face, err := loadFace(spec.bold, spec.size) if err != nil { t.Fatal(err) } *spec.dst = face } return d } func TestPanelFitsScreen(t *testing.T) { d := testDisplay(t) if err := d.layout(600, 1024); err != nil { t.Fatal(err) } 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) } t.Logf("cells %dpx wide, rows end at %d, footer at %d", d.cellW, d.axisY+d.small.lineH, d.resetBtn.y) }