20#include <boost/test/unit_test.hpp>
43 const std::filesystem::path boardPath =
50 const std::filesystem::path outputPath = outputRoot.
Path() /
"Assembly" /
"Assembly_output.pdf";
52 auto pdfJob = std::make_unique<JOB_EXPORT_PCB_PDF>();
53 pdfJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
54 pdfJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
55 pdfJob->m_plotDrawingSheet =
false;
56 pdfJob->m_pdfSingle =
true;
58 pdfJob->m_plotLayerSequence =
LSEQ( {
F_Cu } );
63 BOOST_CHECK( std::filesystem::exists( outputPath ) );
64 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
66 const std::filesystem::path nestedPdf = outputPath / ( boardPath.stem().
string() +
".pdf" );
67 BOOST_CHECK( !std::filesystem::exists( nestedPdf ) );
76 const std::filesystem::path boardPath =
82 const std::filesystem::path outputPath = outputRoot.
Path() /
"out.pdf";
84 auto pdfJob = std::make_unique<JOB_EXPORT_PCB_PDF>();
85 pdfJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
86 pdfJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
87 pdfJob->m_plotDrawingSheet =
false;
88 pdfJob->m_pdfSingle =
true;
99 std::ifstream in( outputPath, std::ios::binary );
100 std::string pdf( ( std::istreambuf_iterator<char>( in ) ), std::istreambuf_iterator<char>() );
102 size_t pageCount = 0;
104 for(
size_t pos = pdf.find(
"/Type /Page\n" ); pos != std::string::npos;
105 pos = pdf.find(
"/Type /Page\n", pos + 1 ) )
124 const std::filesystem::path outputPath = outputRoot.Path() /
"out.pdf";
126 auto pdfJob = std::make_unique<JOB_EXPORT_PCB_PDF>();
127 pdfJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
128 pdfJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
129 pdfJob->m_plotDrawingSheet =
false;
130 pdfJob->m_pdfSingle =
true;
132 pdfJob->m_plotLayerSequence =
LSEQ( { aLayer } );
135 aConfigure( pdfJob.get() );
144 std::ifstream in( outputPath, std::ios::binary );
145 pdf.assign( std::istreambuf_iterator<char>( in ), std::istreambuf_iterator<char>() );
156 std::string pdf =
plotOneLayerToPdf(
"component_classes.kicad_pcb",
F_Fab,
"kicad_pdf_popup_front_test" );
158 BOOST_CHECK( pdf.find(
"/Title (U1)" ) != std::string::npos );
159 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (R1)" ) == std::string::npos,
160 "back footprint R1 was bookmarked on a front layer page" );
161 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (C2)" ) == std::string::npos,
162 "back footprint C2 was bookmarked on a front layer page" );
170 BOOST_CHECK( pdf.find(
"/Title (R1)" ) != std::string::npos );
171 BOOST_CHECK( pdf.find(
"/Title (C2)" ) != std::string::npos );
172 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (U1)" ) == std::string::npos,
173 "front footprint U1 was bookmarked on a back layer page" );
182 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (U1)" ) == std::string::npos,
183 "U1 was bookmarked on the board outline page" );
184 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (R1)" ) == std::string::npos,
185 "R1 was bookmarked on the board outline page" );
195 aJob->m_variant = wxT(
"Variant A" );
196 aJob->m_hideDNPFPsOnFabLayers =
true;
202 BOOST_CHECK( pdf.find(
"/Title (R1)" ) != std::string::npos );
203 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (R3)" ) == std::string::npos,
204 "a hidden do not populate footprint was bookmarked on the fab page" );
214 BOOST_CHECK( pdf.find(
"/Title (R3)" ) != std::string::npos );
215 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (R1)" ) == std::string::npos,
216 "surface mount R1 was bookmarked on an inner copper page" );
217 BOOST_CHECK_MESSAGE( pdf.find(
"/Title (REF**)" ) == std::string::npos,
218 "an unplated hole was bookmarked on an inner copper page" );
General utilities for PCB file IO for QA programs.
@ ONE_PAGE_PER_LAYER_ONE_FILE
"Single Document" mode
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
int JobExportPdf(JOB *aJob)
PCB_LAYER_ID
A quick note on layer IDs:
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
static std::string plotOneLayerToPdf(const std::string &aBoardFile, PCB_LAYER_ID aLayer, const std::string &aTag, const std::function< void(JOB_EXPORT_PCB_PDF *)> &aConfigure={})
BOOST_AUTO_TEST_CASE(ExportPdfSingleDocumentOutputPath)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")