From 10796a3100936b3046abd2782a2a24fdc24ce133 Mon Sep 17 00:00:00 2001 From: Stani Date: Fri, 10 Jul 2015 02:07:18 +0200 Subject: [PATCH] prepare testing for including samples --- draw2dpdf/samples_test.go | 21 ++++++++++----------- draw2dpdf/test_test.go | 21 +++++++++++---------- samples_test.go | 19 +++++++++---------- test_test.go | 8 ++++---- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/draw2dpdf/samples_test.go b/draw2dpdf/samples_test.go index 5ceeb3c..ac6a4ce 100644 --- a/draw2dpdf/samples_test.go +++ b/draw2dpdf/samples_test.go @@ -6,14 +6,13 @@ import ( "testing" "github.com/llgcode/draw2d" - "github.com/llgcode/draw2d.samples" - "github.com/llgcode/draw2d.samples/android" - "github.com/llgcode/draw2d.samples/frameimage" - "github.com/llgcode/draw2d.samples/gopher" - "github.com/llgcode/draw2d.samples/helloworld" - "github.com/llgcode/draw2d.samples/line" - "github.com/llgcode/draw2d.samples/linecapjoin" - "github.com/llgcode/draw2d.samples/postscript" + "github.com/llgcode/draw2d/samples/android" + "github.com/llgcode/draw2d/samples/frameimage" + "github.com/llgcode/draw2d/samples/gopher" + "github.com/llgcode/draw2d/samples/helloworld" + "github.com/llgcode/draw2d/samples/line" + "github.com/llgcode/draw2d/samples/linecapjoin" + "github.com/llgcode/draw2d/samples/postscript" ) func TestSampleAndroid(t *testing.T) { @@ -26,9 +25,9 @@ func TestSampleGopher(t *testing.T) { func TestSampleHelloWorld(t *testing.T) { // Set the global folder for searching fonts - // The pdf backend needs for every ttf file its corresponding json - // file which is generated by gofpdf/makefont. - draw2d.SetFontFolder(samples.Dir("helloworld", "../")) + // The pdf backend needs for every ttf file its corresponding + // json/.z file which is generated by gofpdf/makefont. + draw2d.SetFontFolder("../resource/font") test(t, helloworld.Main) } diff --git a/draw2dpdf/test_test.go b/draw2dpdf/test_test.go index a763c59..88e1f43 100644 --- a/draw2dpdf/test_test.go +++ b/draw2dpdf/test_test.go @@ -4,7 +4,6 @@ package draw2dpdf_test import ( - "os" "testing" "github.com/llgcode/draw2d" @@ -18,18 +17,20 @@ func test(t *testing.T, draw sample) { dest := draw2dpdf.NewPdf("L", "mm", "A4") gc := draw2dpdf.NewGraphicContext(dest) // Draw sample - fn, err := draw(gc, "pdf") + output, err := draw(gc, "pdf") if err != nil { - t.Errorf("Drawing %q failed: %v", fn, err) + t.Errorf("Drawing %q failed: %v", output, err) return } - // Save to pdf only if it doesn't exist because of git - if _, err = os.Stat(fn); err == nil { - t.Skipf("Saving %q skipped, as it exists already. (Git would consider it modified.)", fn) - return - } - err = draw2dpdf.SaveToPdfFile(fn, dest) + /* + // Save to pdf only if it doesn't exist because of git + if _, err = os.Stat(output); err == nil { + t.Skipf("Saving %q skipped, as it exists already. (Git would consider it modified.)", output) + return + } + */ + err = draw2dpdf.SaveToPdfFile(output, dest) if err != nil { - t.Errorf("Saving %q failed: %v", fn, err) + t.Errorf("Saving %q failed: %v", output, err) } } diff --git a/samples_test.go b/samples_test.go index 2d49caf..fdf7614 100644 --- a/samples_test.go +++ b/samples_test.go @@ -6,14 +6,13 @@ import ( "testing" "github.com/llgcode/draw2d" - "github.com/llgcode/draw2d.samples" - "github.com/llgcode/draw2d.samples/android" - "github.com/llgcode/draw2d.samples/frameimage" - "github.com/llgcode/draw2d.samples/gopher" - "github.com/llgcode/draw2d.samples/helloworld" - "github.com/llgcode/draw2d.samples/line" - "github.com/llgcode/draw2d.samples/linecapjoin" - "github.com/llgcode/draw2d.samples/postscript" + "github.com/llgcode/draw2d/samples/android" + "github.com/llgcode/draw2d/samples/frameimage" + "github.com/llgcode/draw2d/samples/gopher" + "github.com/llgcode/draw2d/samples/helloworld" + "github.com/llgcode/draw2d/samples/line" + "github.com/llgcode/draw2d/samples/linecapjoin" + "github.com/llgcode/draw2d/samples/postscript" ) func TestSampleAndroid(t *testing.T) { @@ -26,7 +25,7 @@ func TestSampleGopher(t *testing.T) { func TestSampleHelloWorld(t *testing.T) { // Set the global folder for searching fonts - draw2d.SetFontFolder(samples.Dir("helloworld", "")) + draw2d.SetFontFolder("resource/font") test(t, helloworld.Main) } @@ -38,7 +37,7 @@ func TestSampleLine(t *testing.T) { test(t, line.Main) } -func TestSampleLineCap(t *testing.T) { +func TestSampleLineCapJoin(t *testing.T) { test(t, linecapjoin.Main) } diff --git a/test_test.go b/test_test.go index ca58f79..1796a9d 100644 --- a/test_test.go +++ b/test_test.go @@ -16,14 +16,14 @@ func test(t *testing.T, draw sample) { dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0)) gc := draw2d.NewGraphicContext(dest) // Draw Android logo - fn, err := draw(gc, "png") + output, err := draw(gc, "png") if err != nil { - t.Errorf("Drawing %q failed: %v", fn, err) + t.Errorf("Drawing %q failed: %v", output, err) return } // Save to png - err = draw2d.SaveToPngFile(fn, dest) + err = draw2d.SaveToPngFile(output, dest) if err != nil { - t.Errorf("Saving %q failed: %v", fn, err) + t.Errorf("Saving %q failed: %v", output, err) } }