|
@@ -3,6 +3,7 @@ package al
|
|
|
import "testing"
|
|
|
import "runtime"
|
|
|
import "flag"
|
|
|
+import "path/filepath"
|
|
|
import "math/rand"
|
|
|
|
|
|
|
|
@@ -25,6 +26,18 @@ const CALLBACK_RESULT = 77
|
|
|
const BMP_W = 11
|
|
|
const BMP_H = 23
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func loadBitmap(t *testing.T, name string) * Bitmap {
|
|
|
+ path := filepath.Join("testdata", name)
|
|
|
+ bmp := LoadBitmap(path)
|
|
|
+ if bmp == nil {
|
|
|
+ t.Fatalf("Could not load bitmap: %s: %d\n", path, Errno())
|
|
|
+ }
|
|
|
+ return bmp
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -252,7 +265,33 @@ func randomColor() Color {
|
|
|
return CreateColor(rand.Float32(), rand.Float32(), rand.Float32(), 1.0)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+func TestBitmaps(t *testing.T) {
|
|
|
+ InstallSystem()
|
|
|
+ defer UninstallSystem()
|
|
|
+ InitImageAddon()
|
|
|
+ defer ShutdownImageAddon()
|
|
|
+
|
|
|
+ display := makeDisplay()
|
|
|
+ if display == nil {
|
|
|
+ t.Error("Error creating display.")
|
|
|
+ }
|
|
|
+
|
|
|
+ bmp := loadBitmap(t, "gin_feather.png")
|
|
|
+ blue := CreateColor(0.0, 0.0, 1.0, 1.0)
|
|
|
+ yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
|
|
|
+ ClearToColor(blue)
|
|
|
+ bmp.DrawTinted(yellow, 20, 30, 0)
|
|
|
+ FlipDisplay()
|
|
|
+ tb := TargetBitmap()
|
|
|
+ if (!tb.Save(filepath.Join("testdata", "TestBitmaps.out.png"))) {
|
|
|
+ t.Errorf("Could not save output file.")
|
|
|
+ }
|
|
|
+ Rest(1.0)
|
|
|
+ display.Destroy()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
func TestPrimitives(t *testing.T) {
|
|
|
InstallSystem()
|
|
|
defer UninstallSystem()
|
|
@@ -277,7 +316,6 @@ func TestPrimitives(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
func BenchmarkClearToColor(b *testing.B) {
|
|
|
b.StopTimer()
|