graphics: Add tests for #732

This commit is contained in:
Hajime Hoshi 2018-11-09 00:45:36 +09:00
parent f54bdfa159
commit 9f0d14dd05
2 changed files with 7 additions and 3 deletions

View File

@ -330,7 +330,6 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) {
return
}
// TODO: Add tests about #732
bounds := img.Bounds()
sx0, sy0, sx1, sy1 := bounds.Min.X, bounds.Min.Y, bounds.Max.X, bounds.Max.Y

View File

@ -569,26 +569,31 @@ func TestImageEdge(t *testing.T) {
op.GeoM.Translate(img1Width/2, img1Height/2)
op.Filter = f
img1.DrawImage(img0Sub, op)
allTransparent := true
for j := 0; j < img1Height; j++ {
for i := 0; i < img1Width; i++ {
c := img1.At(i, j)
if c == transparent {
continue
}
allTransparent = false
switch f {
case FilterNearest:
if c == red {
continue
}
case FilterLinear:
_, g, b, _ := c.RGBA()
if g == 0 && b == 0 {
if _, g, b, _ := c.RGBA(); g == 0 && b == 0 {
continue
}
}
t.Errorf("img1.At(%d, %d) (filter: %d, scale: %f, angle: %f) want: red or transparent, got: %v", i, j, f, s, a, c)
}
}
// TODO: Fix bug for scale 0.25
if allTransparent && s > 0.25 {
t.Fatalf("img1 (filter: %d, scale: %f, angle: %f) is transparent but should not", f, s, a)
}
}
}
}