testutil

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPPTXImages added in v0.9.0

func ExtractPPTXImages(pptxContent []byte) ([][]byte, error)

ExtractPPTXImages returns D2's embedded slide PNGs in slide order. It rejects gaps and duplicates instead of silently comparing whichever ZIP member was encountered first.

func ValidateGIF

func ValidateGIF(gifBytes []byte, nFrames int, intervalMS int) error

ValidateGIF checks the frame count, loop behavior, dimensions, and interval of gifBytes against D2's expected GIF output.

func ValidatePPTX

func ValidatePPTX(pptxContent, template []byte, nSlides int) error

ValidatePPTX checks that pptxContent contains the structure emitted by D2's PPTX exporter for nSlides.

Types

type GIFCompareOptions added in v0.9.0

type GIFCompareOptions struct {
	RequireFrameChange bool
	Image              imagediff.Options
}

GIFCompareOptions controls exact display-pixel comparison. When RequireFrameChange is true, a constant animation is rejected even if the expected file is also accidentally constant.

type GIFComparison added in v0.9.0

type GIFComparison struct {
	Expected, Actual *GIFInspection
	FrameIndex       int
	FrameResult      *imagediff.Result
}

GIFComparison contains the frame diagnostics available on a pixel mismatch. FrameResult can be written as a self-contained HTML report.

func CompareGIF added in v0.9.0

func CompareGIF(expectedBytes, actualBytes []byte, options GIFCompareOptions) (*GIFComparison, error)

CompareGIF compares playback metadata and exact composited frame pixels. Encoded palette layout and compression may differ without failing the test.

type GIFInspection added in v0.9.0

type GIFInspection struct {
	Width, Height             int
	LoopCount                 int
	Delays                    []int
	TotalDurationCentiseconds int
	FrameHashes               [][sha256.Size]byte
	ChangedFramePairs         int
	// contains filtered or unexported fields
}

GIFInspection is the decoded, display-equivalent GIF contract used by the raster E2E suite. FrameHashes are hashes of composited NRGBA pixels in playback order, not hashes of palette indices or encoded bytes.

func InspectGIF added in v0.9.0

func InspectGIF(gifBytes []byte) (*GIFInspection, error)

InspectGIF decodes and composites GIF frames according to their disposal methods. This catches palette-only, sub-rectangle, and frame-order changes that metadata-only validation misses.

type PDFImage added in v0.9.0

type PDFImage struct {
	ObjectNumber  int
	Width, Height int
	Pixels        *image.NRGBA
}

type PDFInspection added in v0.9.0

type PDFInspection struct {
	Pages         []PDFPage
	Images        []PDFImage
	ExternalLinks []string
	InternalLinks int
}

PDFInspection is the bounded structural and raster view of PDFs emitted by D2's go-pdf/fpdf writer. It intentionally is not a general PDF parser.

func InspectD2PDF added in v0.9.0

func InspectD2PDF(content []byte) (*PDFInspection, error)

InspectD2PDF verifies page/link structure and decodes D2's embedded raster XObjects. Supported image streams are the exact FlateDecode + PNG predictor shape emitted by go-pdf/fpdf for D2's RGB/RGBA PNGs.

type PDFPage added in v0.9.0

type PDFPage struct {
	ObjectNumber  int
	Width, Height float64
	ExternalLinks []string
	InternalLinks int
}

type PagedImageComparison added in v0.9.0

type PagedImageComparison struct {
	Page   int
	Result *imagediff.Result
}

PagedImageComparison retains the first embedded-image mismatch so callers can write its self-contained HTML diagnostics.

func ComparePDFImages added in v0.9.0

func ComparePDFImages(pdfContent []byte, expectedPNGs [][]byte, options imagediff.Options) (*PagedImageComparison, error)

ComparePDFImages compares the decoded PDF XObject pixels with the supplied standalone format-equivalent PNGs.

func ComparePPTXImages added in v0.9.0

func ComparePPTXImages(pptxContent []byte, expectedPNGs [][]byte, options imagediff.Options) (*PagedImageComparison, error)

ComparePPTXImages compares each embedded slide PNG with the corresponding standalone format-equivalent PNG. Decoded dimensions and pixels are exact by default; encoded PNG metadata and compression are intentionally not.

Directories

Path Synopsis
Package imagediff compares rendered images and produces deterministic visual diagnostics suitable for test failures.
Package imagediff compares rendered images and produces deterministic visual diagnostics suitable for test failures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL