KiCad PCB EDA Suite
|
#include <qa_utils/pdf_test_utils.h>
#include <gal/color4d.h>
#include <wx/filename.h>
#include <wx/filefn.h>
#include <wx/ffile.h>
#include <wx/utils.h>
#include <wx/image.h>
#include <wx/imagpng.h>
#include <zlib.h>
Go to the source code of this file.
Functions | |
wxString | MakeTempPdfPath (const wxString &aPrefix) |
Make a temporary file path with .pdf extension using a given prefix. | |
TEXT_ATTRIBUTES | BuildTextAttributes (int aSizeIu, int aStrokeWidth, bool aBold, bool aItalic) |
Build a commonly used set of text attributes for plotting text in tests. | |
std::unique_ptr< KIFONT::STROKE_FONT > | LoadStrokeFontUnique () |
Load the default stroke font and return a unique_ptr for RAII deletion. | |
static void | append_decompressed_streams (std::string &aBuffer) |
bool | ReadPdfWithDecompressedStreams (const wxString &aPdfPath, std::string &aOutBuffer) |
Read a PDF file and append best-effort decompressed contents of any Flate streams to the returned buffer to make text searches easier. | |
int | CountOccurrences (const std::string &aHaystack, const std::string &aNeedle) |
Count occurrences of a substring in a string (overlapping allowed). | |
bool | RasterizePdfCountDark (const wxString &aPdfPath, int aDpi, int aNearWhiteThresh, long &aOutDarkPixels) |
Rasterize a PDF page to PNG using pdftoppm if available and count non-near-white pixels. | |
void | MaybeRemoveFile (const wxString &aPath, const wxString &aEnvVar) |
Remove a file unless the given environment variable is set (defaults to KICAD_KEEP_TEST_PDF). | |
|
static |
Definition at line 75 of file pdf_test_utils.cpp.
Referenced by ReadPdfWithDecompressedStreams().
TEXT_ATTRIBUTES BuildTextAttributes | ( | int | aSizeIu = 3000, |
int | aStrokeWidth = 300, | ||
bool | aBold = false, | ||
bool | aItalic = false ) |
Build a commonly used set of text attributes for plotting text in tests.
aSizeIu | Size in internal units (both X and Y) |
aStrokeWidth | Stroke width in internal units (0 for outline fonts) |
aBold | Bold flag |
aItalic | Italic flag |
Definition at line 55 of file pdf_test_utils.cpp.
References ANGLE_0, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_BOTTOM, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Multiline, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, and TEXT_ATTRIBUTES::m_Valign.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
int CountOccurrences | ( | const std::string & | aHaystack, |
const std::string & | aNeedle ) |
Count occurrences of a substring in a string (overlapping allowed).
Definition at line 144 of file pdf_test_utils.cpp.
Referenced by BOOST_AUTO_TEST_CASE().
std::unique_ptr< KIFONT::STROKE_FONT > LoadStrokeFontUnique | ( | ) |
Load the default stroke font and return a unique_ptr for RAII deletion.
Definition at line 70 of file pdf_test_utils.cpp.
References KIFONT::STROKE_FONT::LoadFont().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
wxString MakeTempPdfPath | ( | const wxString & | aPrefix | ) |
Make a temporary file path with .pdf extension using a given prefix.
Definition at line 36 of file pdf_test_utils.cpp.
Referenced by getTempPdfPath().
void MaybeRemoveFile | ( | const wxString & | aPath, |
const wxString & | aEnvVar ) |
Remove a file unless the given environment variable is set (defaults to KICAD_KEEP_TEST_PDF).
Definition at line 213 of file pdf_test_utils.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
bool RasterizePdfCountDark | ( | const wxString & | aPdfPath, |
int | aDpi, | ||
int | aNearWhiteThresh, | ||
long & | aOutDarkPixels ) |
Rasterize a PDF page to PNG using pdftoppm if available and count non-near-white pixels.
aPdfPath | Input PDF path. |
aDpi | Rasterization DPI. |
aNearWhiteThresh | Threshold for each RGB channel to consider white (e.g., 240). |
aOutDarkPixels | Output: number of pixels darker than threshold. |
Definition at line 164 of file pdf_test_utils.cpp.
Referenced by BOOST_AUTO_TEST_CASE().
bool ReadPdfWithDecompressedStreams | ( | const wxString & | aPdfPath, |
std::string & | aOutBuffer ) |
Read a PDF file and append best-effort decompressed contents of any Flate streams to the returned buffer to make text searches easier.
Definition at line 126 of file pdf_test_utils.cpp.
References append_decompressed_streams().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().