Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::ImageComparisonTestFixture Class Reference

A Google Test fixture for tests that compare rendered SVG output against golden images. More...

#include "donner/svg/renderer/tests/ImageComparisonTestFixture.h"

Inheritance diagram for donner::svg::ImageComparisonTestFixture:
[legend]
Collaboration diagram for donner::svg::ImageComparisonTestFixture:
[legend]

Protected Member Functions

SVGDocument loadSVG (const char *filename, const std::optional< std::filesystem::path > &resourceDir=std::nullopt)
 Loads an SVG document from the given filename.
 
void renderAndCompare (SVGDocument &document, const std::filesystem::path &svgFilename, const char *goldenImageFilename)
 Renders the given SVG document and compares it against a golden image.
 
void renderAndCompare (SVGDocument &document, const std::filesystem::path &svgFilename, const char *goldenImageFilename, const ImageComparisonParams &params)
 Renders the given SVG document and compares it against a golden image using specified parameters.
 

Detailed Description

A Google Test fixture for tests that compare rendered SVG output against golden images.

This fixture is parameterized with ImageComparisonTestcase, allowing multiple SVG files to be tested with different comparison parameters. It provides helper methods for loading SVG documents and performing the rendering and comparison.

Member Function Documentation

◆ loadSVG()

SVGDocument donner::svg::ImageComparisonTestFixture::loadSVG ( const char * filename,
const std::optional< std::filesystem::path > & resourceDir = std::nullopt )
protected

Loads an SVG document from the given filename.

Parameters
filenameThe path to the SVG file.
resourceDirOptional path to a directory containing resources (e.g., external images) referenced by the SVG.
Returns
The loaded SVGDocument.

◆ renderAndCompare() [1/2]

void donner::svg::ImageComparisonTestFixture::renderAndCompare ( SVGDocument & document,
const std::filesystem::path & svgFilename,
const char * goldenImageFilename )
protected

Renders the given SVG document and compares it against a golden image.

Uses default comparison parameters.

Parameters
documentThe SVGDocument to render.
svgFilenameThe original path of the SVG file (used for naming output files).
goldenImageFilenameThe path to the golden image file.

◆ renderAndCompare() [2/2]

void donner::svg::ImageComparisonTestFixture::renderAndCompare ( SVGDocument & document,
const std::filesystem::path & svgFilename,
const char * goldenImageFilename,
const ImageComparisonParams & params )
protected

Renders the given SVG document and compares it against a golden image using specified parameters.

Parameters
documentThe SVGDocument to render.
svgFilenameThe original path of the SVG file (used for naming output files).
goldenImageFilenameThe path to the golden image file.
paramsThe ImageComparisonParams to use for the comparison.

The documentation for this class was generated from the following files: