2015-07-10 13:11:19 +00:00
|
|
|
// Copyright 2015 The draw2d Authors. All rights reserved.
|
|
|
|
// created: 26/06/2015 by Stani Michiels
|
|
|
|
|
2015-07-06 22:25:24 +00:00
|
|
|
// Package draw2dpdf_test gives test coverage with the command:
|
2015-07-01 08:34:23 +00:00
|
|
|
// go test -cover ./... | grep -v "no test"
|
|
|
|
// (It should be run from its parent draw2d directory.)
|
2015-07-06 22:25:24 +00:00
|
|
|
package draw2dpdf_test
|
2015-07-01 08:34:23 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-12-13 14:35:47 +00:00
|
|
|
"gopkg.in/llgcode/draw2d.v1"
|
|
|
|
"gopkg.in/llgcode/draw2d.v1/draw2dpdf"
|
2015-07-01 08:34:23 +00:00
|
|
|
)
|
|
|
|
|
2015-07-07 21:35:03 +00:00
|
|
|
type sample func(gc draw2d.GraphicContext, ext string) (string, error)
|
|
|
|
|
|
|
|
func test(t *testing.T, draw sample) {
|
2015-07-01 08:34:23 +00:00
|
|
|
// Initialize the graphic context on an pdf document
|
2015-07-06 22:25:24 +00:00
|
|
|
dest := draw2dpdf.NewPdf("L", "mm", "A4")
|
|
|
|
gc := draw2dpdf.NewGraphicContext(dest)
|
2015-07-01 18:27:41 +00:00
|
|
|
// Draw sample
|
2015-07-10 00:07:18 +00:00
|
|
|
output, err := draw(gc, "pdf")
|
2015-07-01 08:34:23 +00:00
|
|
|
if err != nil {
|
2015-07-10 00:07:18 +00:00
|
|
|
t.Errorf("Drawing %q failed: %v", output, err)
|
2015-07-01 08:34:23 +00:00
|
|
|
return
|
|
|
|
}
|
2015-07-11 20:53:24 +00:00
|
|
|
/*
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
*/
|
2015-07-10 00:07:18 +00:00
|
|
|
err = draw2dpdf.SaveToPdfFile(output, dest)
|
2015-07-01 08:34:23 +00:00
|
|
|
if err != nil {
|
2015-07-10 00:07:18 +00:00
|
|
|
t.Errorf("Saving %q failed: %v", output, err)
|
2015-07-01 08:34:23 +00:00
|
|
|
}
|
|
|
|
}
|