-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguides_test.go
52 lines (44 loc) · 1.01 KB
/
guides_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package counters
import (
"image/color"
"testing"
"github.com/fogleman/gg"
"github.com/stretchr/testify/assert"
)
func TestGuides(t *testing.T) {
sideSize := 300
testText := Text{
Settings: Settings{
FontColor: color.Black,
FontHeight: 15,
Width: sideSize,
Height: sideSize,
Margins: floatP(3),
},
String: "Guides",
}
template := CounterTemplate{
Settings: Settings{
FontPath: "assets/freesans.ttf",
Width: 100,
Height: 100,
},
DrawGuides: true,
Counters: []Counter{
{Texts: []Text{testText}},
},
}
parsedTemplate, err := template.ParsePrototype()
if assert.NoError(t, err) {
testCanvas := gg.NewContext(sideSize, sideSize)
testCanvas.Push()
testCanvas.SetColor(color.White)
testCanvas.DrawRectangle(0, 0, float64(sideSize), float64(sideSize))
testCanvas.Fill()
testCanvas.Pop()
canvas, err := parsedTemplate.Counters[0].Canvas(true)
if assert.NoError(t, err) {
TestImageContent(t, "testdata/guides_01.png", 1709, canvas)
}
}
}