summaryrefslogtreecommitdiff
path: root/test
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
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')
-rw-r--r--test/kbtest.go2
-rw-r--r--test/main.go40
2 files changed, 39 insertions, 3 deletions
diff --git a/test/kbtest.go b/test/kbtest.go
index 8b36c4e..70ed1d7 100644
--- a/test/kbtest.go
+++ b/test/kbtest.go
@@ -73,7 +73,7 @@ func (a *keyboardArea) Key(e KeyEvent) (handled bool, repaint bool) {
return true, true
}
-var doKeyboard = flag.Bool("kb", false, "run keyboard test")
+var doKeyboard = flag.Bool("kb", false, "run keyboard test (overrides -areabounds)")
func kbTest() {
wid, ht, ah := mkkbArea()
a := NewArea(wid, ht, ah)
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")