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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
22#include <filesystem>
23#include <memory>
24
25#include <cli/exit_codes.h>
27#include <pcbnew_jobs_handler.h>
29
30#include <wx/string.h>
31
32
33BOOST_AUTO_TEST_CASE( ExportPdfSingleDocumentOutputPath )
34{
35 PCBNEW_JOBS_HANDLER handler( nullptr );
36
37 const std::filesystem::path boardPath =
38 std::filesystem::path( KI_TEST::GetPcbnewTestDataDir() ) / "api_kitchen_sink.kicad_pcb";
39
40 BOOST_REQUIRE( std::filesystem::exists( boardPath ) );
41
42 const std::filesystem::path outputRoot =
43 std::filesystem::temp_directory_path() / "kicad_pdf_single_doc_test";
44 const std::filesystem::path outputPath =
45 outputRoot / "Assembly" / "Assembly_output.pdf";
46
47 if( std::filesystem::exists( outputRoot ) )
48 std::filesystem::remove_all( outputRoot );
49
50 auto pdfJob = std::make_unique<JOB_EXPORT_PCB_PDF>();
51 pdfJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
52 pdfJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
53 pdfJob->m_plotDrawingSheet = false;
54 pdfJob->m_pdfSingle = true;
56 pdfJob->m_plotLayerSequence = LSEQ( { F_Cu } );
57
58 int result = handler.JobExportPdf( pdfJob.get() );
60
61 BOOST_CHECK( std::filesystem::exists( outputPath ) );
62 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
63
64 const std::filesystem::path nestedPdf =
65 outputPath / ( boardPath.stem().string() + ".pdf" );
66 BOOST_CHECK( !std::filesystem::exists( nestedPdf ) );
67
68 std::filesystem::remove_all( outputRoot );
69}
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:60
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")