Errors.
var ( ErrRenderNotSupported = errors.New("rendering PDF files is not supported on this system") ErrImageSizeNotMatch = errors.New("image sizes don't match") )
func CombinePNGFiles(file1, file2 string) (bool, error)
CombinePNGFiles combines the specified PNG files.
func CompareImages(img1, img2 image.Image) (bool, error)
CompareImages compares the specified images at pixel level.
func ComparePNGFiles(file1, file2 string) (bool, error)
ComparePNGFiles compares the specified PNG files.
func CopyFile(src, dst string) error
CopyFile copies the `src` file to `dst`.
func CreatePNGDiff(src, dst string) (bool, string, float64, float64, error)
CreatePNGDiff creates image differences and returns differences percentage and total.
func HashFile(file string) (string, error)
HashFile generates an MD5 hash from the contents of the specified file.
func ReadPNG(file string) (image.Image, error)
ReadPNG reads and returns the specified PNG file.
func RenderPDFToPNGs(pdfPath string, dpi int, outpathTpl string) error
RenderPDFToPNGs uses ghostscript (gs) to render the specified PDF file into a set of PNG images (one per page). PNG images will be named xxx-N.png where N is the number of page, starting from 1.
func RunRenderOfficeTest(t *testing.T, pdfPath, outputDir, baselineRenderPath string, saveBaseline bool, currentHashMap *ReferenceMap, refFile *ReferenceFile, postfix string)
RunRenderOfficeTest renders the PDF file specified by `pdfPath` to the `outputDir` and compares the output PNG files to the reference files found at the `baselineRenderPath` location. If the specified PDF file is new (there are no reference files) and the `saveBaseline` parameter is set to true, the output render files are saved to the `baselineRenderPath`.
func RunRenderTest(t *testing.T, pdfPath, outputDir, baselineRenderPath string, saveBaseline bool, currentHashMap *ReferenceMap, refFile *ReferenceFile)
RunRenderTest renders the PDF file specified by `pdfPath` to the `outputDir` and compares the output PNG files to the reference files found at the `baselineRenderPath` location. If the specified PDF file is new (there are no reference files) and the `saveBaseline` parameter is set to true, the output render files are saved to the `baselineRenderPath`. RunRenderTest is intended for converted from Word documents PDF files
ReferenceEntry is the reference file single entry.
type ReferenceEntry struct { Timestamp int64 `json:"timestamp"` Value string `json:"value"` ResultSize int64 `json:"resultSize,omitempty"` DiffPercent float64 `json:"diffPercent,omitempty"` DiffTotal float64 `json:"diffValue,omitempty"` Invalid bool `json:"markedInvalid,omitempty"` }
ReferenceFile represents the reference file hash map.
type ReferenceFile struct { Timestamp time.Time `json:"timestamp"` Map *ReferenceMap `json:"map,omitempty"` // contains filtered or unexported fields }
func ReadFile(dirPath, testName string, createEmpty bool) (*ReferenceFile, error)
ReadFile reads the reference file map stored at the 'path'. The 'createEmpty' flag creates empty file if there is no reference stored at provided 'path'.
func (f *ReferenceFile) Update(currentMap *ReferenceMap) error
Update updates given reference file.
Map is the reference file map
type ReferenceMap struct { sync.Mutex // contains filtered or unexported fields }
func (m *ReferenceMap) Copy() *ReferenceMap
Copy creates a copy of given reference file map.
func (m *ReferenceMap) Keys() (keys []string)
Keys gets the keys of given map.
func (m *ReferenceMap) Len() int
Len returns the length of given map.
func (m *ReferenceMap) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (m *ReferenceMap) Read(key string) (ReferenceEntry, bool)
func (m *ReferenceMap) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
func (m *ReferenceMap) Write(key string, entry ReferenceEntry)
Write write new entry for given key value.