KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pdf_output_path.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <boost/test/unit_test.hpp>
25
26#include <filesystem>
27#include <memory>
28
29#include <cli/exit_codes.h>
31#include <pcbnew_jobs_handler.h>
33
34#include <wx/string.h>
35
36
37BOOST_AUTO_TEST_CASE( ExportPdfSingleDocumentOutputPath )
38{
39 PCBNEW_JOBS_HANDLER handler( nullptr );
40
41 const std::filesystem::path boardPath =
42 std::filesystem::path( KI_TEST::GetPcbnewTestDataDir() ) / "api_kitchen_sink.kicad_pcb";
43
44 BOOST_REQUIRE( std::filesystem::exists( boardPath ) );
45
46 const std::filesystem::path outputRoot =
47 std::filesystem::temp_directory_path() / "kicad_pdf_single_doc_test";
48 const std::filesystem::path outputPath =
49 outputRoot / "Assembly" / "Assembly_output.pdf";
50
51 if( std::filesystem::exists( outputRoot ) )
52 std::filesystem::remove_all( outputRoot );
53
54 auto pdfJob = std::make_unique<JOB_EXPORT_PCB_PDF>();
55 pdfJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
56 pdfJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
57 pdfJob->m_plotDrawingSheet = false;
58 pdfJob->m_pdfSingle = true;
60 pdfJob->m_plotLayerSequence = LSEQ( { F_Cu } );
61
62 int result = handler.JobExportPdf( pdfJob.get() );
64
65 BOOST_CHECK( std::filesystem::exists( outputPath ) );
66 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
67
68 const std::filesystem::path nestedPdf =
69 outputPath / ( boardPath.stem().string() + ".pdf" );
70 BOOST_CHECK( !std::filesystem::exists( nestedPdf ) );
71
72 std::filesystem::remove_all( outputRoot );
73}
General utilities for PCB file IO for QA programs.
@ ONE_PAGE_PER_LAYER_ONE_FILE
The most traditional output mode KiCad has had.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition lseq.h:47
@ F_Cu
Definition layer_ids.h:64
static const int OK
Definition exit_codes.h:30
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_CASE(ExportPdfSingleDocumentOutputPath)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")