prepare testing for including samples
This commit is contained in:
parent
f5ef2c0154
commit
10796a3100
4 changed files with 34 additions and 35 deletions
|
@ -6,14 +6,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/llgcode/draw2d"
|
"github.com/llgcode/draw2d"
|
||||||
"github.com/llgcode/draw2d.samples"
|
"github.com/llgcode/draw2d/samples/android"
|
||||||
"github.com/llgcode/draw2d.samples/android"
|
"github.com/llgcode/draw2d/samples/frameimage"
|
||||||
"github.com/llgcode/draw2d.samples/frameimage"
|
"github.com/llgcode/draw2d/samples/gopher"
|
||||||
"github.com/llgcode/draw2d.samples/gopher"
|
"github.com/llgcode/draw2d/samples/helloworld"
|
||||||
"github.com/llgcode/draw2d.samples/helloworld"
|
"github.com/llgcode/draw2d/samples/line"
|
||||||
"github.com/llgcode/draw2d.samples/line"
|
"github.com/llgcode/draw2d/samples/linecapjoin"
|
||||||
"github.com/llgcode/draw2d.samples/linecapjoin"
|
"github.com/llgcode/draw2d/samples/postscript"
|
||||||
"github.com/llgcode/draw2d.samples/postscript"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSampleAndroid(t *testing.T) {
|
func TestSampleAndroid(t *testing.T) {
|
||||||
|
@ -26,9 +25,9 @@ func TestSampleGopher(t *testing.T) {
|
||||||
|
|
||||||
func TestSampleHelloWorld(t *testing.T) {
|
func TestSampleHelloWorld(t *testing.T) {
|
||||||
// Set the global folder for searching fonts
|
// Set the global folder for searching fonts
|
||||||
// The pdf backend needs for every ttf file its corresponding json
|
// The pdf backend needs for every ttf file its corresponding
|
||||||
// file which is generated by gofpdf/makefont.
|
// json/.z file which is generated by gofpdf/makefont.
|
||||||
draw2d.SetFontFolder(samples.Dir("helloworld", "../"))
|
draw2d.SetFontFolder("../resource/font")
|
||||||
test(t, helloworld.Main)
|
test(t, helloworld.Main)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package draw2dpdf_test
|
package draw2dpdf_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/llgcode/draw2d"
|
"github.com/llgcode/draw2d"
|
||||||
|
@ -18,18 +17,20 @@ func test(t *testing.T, draw sample) {
|
||||||
dest := draw2dpdf.NewPdf("L", "mm", "A4")
|
dest := draw2dpdf.NewPdf("L", "mm", "A4")
|
||||||
gc := draw2dpdf.NewGraphicContext(dest)
|
gc := draw2dpdf.NewGraphicContext(dest)
|
||||||
// Draw sample
|
// Draw sample
|
||||||
fn, err := draw(gc, "pdf")
|
output, err := draw(gc, "pdf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Drawing %q failed: %v", fn, err)
|
t.Errorf("Drawing %q failed: %v", output, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// Save to pdf only if it doesn't exist because of git
|
// Save to pdf only if it doesn't exist because of git
|
||||||
if _, err = os.Stat(fn); err == nil {
|
if _, err = os.Stat(output); err == nil {
|
||||||
t.Skipf("Saving %q skipped, as it exists already. (Git would consider it modified.)", fn)
|
t.Skipf("Saving %q skipped, as it exists already. (Git would consider it modified.)", output)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = draw2dpdf.SaveToPdfFile(fn, dest)
|
*/
|
||||||
|
err = draw2dpdf.SaveToPdfFile(output, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Saving %q failed: %v", fn, err)
|
t.Errorf("Saving %q failed: %v", output, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/llgcode/draw2d"
|
"github.com/llgcode/draw2d"
|
||||||
"github.com/llgcode/draw2d.samples"
|
"github.com/llgcode/draw2d/samples/android"
|
||||||
"github.com/llgcode/draw2d.samples/android"
|
"github.com/llgcode/draw2d/samples/frameimage"
|
||||||
"github.com/llgcode/draw2d.samples/frameimage"
|
"github.com/llgcode/draw2d/samples/gopher"
|
||||||
"github.com/llgcode/draw2d.samples/gopher"
|
"github.com/llgcode/draw2d/samples/helloworld"
|
||||||
"github.com/llgcode/draw2d.samples/helloworld"
|
"github.com/llgcode/draw2d/samples/line"
|
||||||
"github.com/llgcode/draw2d.samples/line"
|
"github.com/llgcode/draw2d/samples/linecapjoin"
|
||||||
"github.com/llgcode/draw2d.samples/linecapjoin"
|
"github.com/llgcode/draw2d/samples/postscript"
|
||||||
"github.com/llgcode/draw2d.samples/postscript"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSampleAndroid(t *testing.T) {
|
func TestSampleAndroid(t *testing.T) {
|
||||||
|
@ -26,7 +25,7 @@ func TestSampleGopher(t *testing.T) {
|
||||||
|
|
||||||
func TestSampleHelloWorld(t *testing.T) {
|
func TestSampleHelloWorld(t *testing.T) {
|
||||||
// Set the global folder for searching fonts
|
// Set the global folder for searching fonts
|
||||||
draw2d.SetFontFolder(samples.Dir("helloworld", ""))
|
draw2d.SetFontFolder("resource/font")
|
||||||
test(t, helloworld.Main)
|
test(t, helloworld.Main)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ func TestSampleLine(t *testing.T) {
|
||||||
test(t, line.Main)
|
test(t, line.Main)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSampleLineCap(t *testing.T) {
|
func TestSampleLineCapJoin(t *testing.T) {
|
||||||
test(t, linecapjoin.Main)
|
test(t, linecapjoin.Main)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,14 @@ func test(t *testing.T, draw sample) {
|
||||||
dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
|
dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
|
||||||
gc := draw2d.NewGraphicContext(dest)
|
gc := draw2d.NewGraphicContext(dest)
|
||||||
// Draw Android logo
|
// Draw Android logo
|
||||||
fn, err := draw(gc, "png")
|
output, err := draw(gc, "png")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Drawing %q failed: %v", fn, err)
|
t.Errorf("Drawing %q failed: %v", output, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Save to png
|
// Save to png
|
||||||
err = draw2d.SaveToPngFile(fn, dest)
|
err = draw2d.SaveToPngFile(output, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Saving %q failed: %v", fn, err)
|
t.Errorf("Saving %q failed: %v", output, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue