summaryrefslogtreecommitdiff
path: root/test/main.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-04-09 20:44:07 -0400
committerPietro Gagliardi <[email protected]>2014-04-09 20:44:07 -0400
commit8259e6d1f849704bce9c47d86c0fd429a1db2367 (patch)
treecfd58a30b03cb737dcb1dec1d3be40f4d09ac329 /test/main.go
parenta2edde63c2b09c6d794cb139d2370595e6cdab69 (diff)
Added a test for the extremities of the Area's actual drawing area to make sure all pixels are shown on all platforms. That seems to be the case right now... Also more TODOs.
Diffstat (limited to 'test/main.go')
-rw-r--r--test/main.go40
1 files changed, 38 insertions, 2 deletions
diff --git a/test/main.go b/test/main.go
index 9df9c13..44f57a1 100644
--- a/test/main.go
+++ b/test/main.go
@@ -5,7 +5,7 @@ import (
"fmt"
"flag"
"image"
-// "image/color"
+ "image/color"
"image/draw"
_ "image/png"
"bytes"
@@ -140,7 +140,7 @@ func (a *areaHandler) Key(e KeyEvent) (bool, bool) {
return false, false
}
-var doArea = flag.Bool("area", false, "run area test instead (overrides -kb)")
+var doArea = flag.Bool("area", false, "run area test instead (overrides -kb and -areabounds)")
func areaTest() {
/*
img := [2]*image.NRGBA{}
@@ -200,6 +200,38 @@ func areaTest() {
}
}
+var areabounds = flag.Bool("areabounds", false, "run area bounds test instead")
+func areaboundsTest() {
+ img := image.NewNRGBA(image.Rect(0, 0, 320, 240))
+ a := NewArea(320, 240, &areaHandler{
+ img: img,
+ })
+ u := func(r, g, b uint8) *image.Uniform {
+ return image.NewUniform(color.NRGBA{r, g, b, 255})
+ }
+ // left border red
+ r := img.Rect
+ draw.Draw(img, r, u(255, 0, 0), image.ZP, draw.Over)
+ // bottom border green
+ r.Min.X++
+ draw.Draw(img, r, u(0, 255, 0), image.ZP, draw.Over)
+ // right border blue
+ r.Max.Y--
+ draw.Draw(img, r, u(0, 0, 255), image.ZP, draw.Over)
+ // top border fuscia
+ r.Max.X--
+ draw.Draw(img, r, u(255, 0, 255), image.ZP, draw.Over)
+ // middle purple
+ r.Min.Y++
+ draw.Draw(img, r, u(128, 0, 128), image.ZP, draw.Over)
+ w := NewWindow("Area Bounds Test", 320, 240)
+ err := w.Open(a)
+ if err != nil {
+ panic(err)
+ }
+ <-w.Closing
+}
+
func myMain() {
if *doArea {
areaTest()
@@ -209,6 +241,10 @@ func myMain() {
kbTest()
return
}
+ if *areabounds {
+ areaboundsTest()
+ return
+ }
w := NewWindow("Main Window", 320, 240)
b := NewButton("Click Me")
b2 := NewButton("Or Me")