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

Parameters for controlling image comparison tests. More...

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

Collaboration diagram for donner::svg::ImageComparisonParams:
[legend]

Public Member Functions

ImageComparisonParamsdisableDebugSkpOnFailure ()
 Disables saving of .skp files on test failure.
 
ImageComparisonParamsenableGoldenUpdateFromEnv ()
 Enables updating golden images based on an environment variable.
 
ImageComparisonParamssetCanvasSize (int width, int height)
 Sets a custom canvas size for rendering.
 

Static Public Member Functions

static ImageComparisonParams Skip ()
 Creates parameters to skip a test.
 
static ImageComparisonParams WithThreshold (float threshold, int maxMismatchedPixels=kDefaultMismatchedPixels)
 Creates parameters with a specific threshold and maximum mismatched pixels.
 
static ImageComparisonParams WithGoldenOverride (std::string_view filename)
 Creates parameters with an overridden golden image filename.
 

Public Attributes

float threshold = kDefaultThreshold
 Maximum allowed difference per pixel (0.0 to 1.0).
 
int maxMismatchedPixels = kDefaultMismatchedPixels
 Maximum number of pixels that can exceed the threshold.
 
bool skip = false
 If true, skip this test case.
 
bool saveDebugSkpOnFailure = true
 If true, save a .skp file for debugging when a test fails.
 
bool updateGoldenFromEnv = false
 If true, allow updating golden images via an environment variable.
 
std::optional< Vector2icanvasSize
 Optional canvas size override, which determines the size of the rendered image.
 
std::string_view overrideGoldenFilename
 Optional filename to use for the golden image, overriding the default.
 

Detailed Description

Parameters for controlling image comparison tests.

This struct allows customization of various aspects of the image comparison process, such as error thresholds, skipping tests, and overriding golden image filenames.

Member Function Documentation

◆ disableDebugSkpOnFailure()

ImageComparisonParams & donner::svg::ImageComparisonParams::disableDebugSkpOnFailure ( )
inline

Disables saving of .skp files on test failure.

Returns
Reference to this ImageComparisonParams object.

◆ enableGoldenUpdateFromEnv()

ImageComparisonParams & donner::svg::ImageComparisonParams::enableGoldenUpdateFromEnv ( )
inline

Enables updating golden images based on an environment variable.

Returns
Reference to this ImageComparisonParams object.

◆ setCanvasSize()

ImageComparisonParams & donner::svg::ImageComparisonParams::setCanvasSize ( int width,
int height )
inline

Sets a custom canvas size for rendering.

Parameters
widthThe width of the canvas.
heightThe height of the canvas.
Returns
Reference to this ImageComparisonParams object.

◆ Skip()

static ImageComparisonParams donner::svg::ImageComparisonParams::Skip ( )
inlinestatic

Creates parameters to skip a test.

Returns
ImageComparisonParams configured to skip.

◆ WithGoldenOverride()

static ImageComparisonParams donner::svg::ImageComparisonParams::WithGoldenOverride ( std::string_view filename)
inlinestatic

Creates parameters with an overridden golden image filename.

Parameters
filenameThe filename to use for the golden image.
Returns
ImageComparisonParams configured with the golden override.

◆ WithThreshold()

static ImageComparisonParams donner::svg::ImageComparisonParams::WithThreshold ( float threshold,
int maxMismatchedPixels = kDefaultMismatchedPixels )
inlinestatic

Creates parameters with a specific threshold and maximum mismatched pixels.

Parameters
thresholdThe per-pixel difference threshold.
maxMismatchedPixelsThe maximum number of pixels allowed to mismatch.
Returns
ImageComparisonParams configured with the specified thresholds.

The documentation for this struct was generated from the following file: