KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_autotrax_import.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 (C) 2026 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
33
37
39
40#include <board.h>
41#include <footprint.h>
42#include <pad.h>
43#include <pcb_track.h>
44#include <pcb_shape.h>
45
46#include <wx/filename.h>
47
48
50{
52
54
55 std::string path( const std::string& aName )
56 {
57 return KI_TEST::GetPcbnewTestDataDir() + "plugins/autotrax/" + aName;
58 }
59
60 bool haveSample( const std::string& aName ) { return wxFileName::FileExists( path( aName ) ); }
61};
62
63
64BOOST_FIXTURE_TEST_SUITE( AutotraxImport, AUTOTRAX_IMPORT_FIXTURE )
65
66
67
69BOOST_AUTO_TEST_CASE( SniffRecognizesPcb )
70{
71 if( !haveSample( "PRJ.PCB" ) )
72 {
73 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
74 return;
75 }
76
77 BOOST_CHECK( m_plugin.CanReadBoard( path( "PRJ.PCB" ) ) );
78}
79
80
83BOOST_AUTO_TEST_CASE( SimpleBoardStructure )
84{
85 if( !haveSample( "PRJ.PCB" ) )
86 {
87 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
88 return;
89 }
90
91 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
92
93 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( "PRJ.PCB" ), board.get(), nullptr ) );
94 BOOST_REQUIRE( board );
95
96 BOOST_CHECK_GT( board->Footprints().size(), 0 );
97
98 int pads = 0;
99
100 for( FOOTPRINT* fp : board->Footprints() )
101 pads += fp->Pads().size();
102
103 BOOST_CHECK_GT( pads, 0 );
104 BOOST_CHECK_GT( board->Tracks().size(), 0 );
105}
106
107
111BOOST_AUTO_TEST_CASE( RichBoardStructure )
112{
113 if( !haveSample( "PRJ12.PCB" ) )
114 {
115 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
116 return;
117 }
118
119 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
120
121 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( "PRJ12.PCB" ), board.get(), nullptr ) );
122 BOOST_REQUIRE( board );
123
124 int tracks = 0;
125 int vias = 0;
126
127 for( PCB_TRACK* t : board->Tracks() )
128 {
129 if( t->Type() == PCB_VIA_T )
130 vias++;
131 else if( t->Type() == PCB_TRACE_T )
132 tracks++;
133 }
134
135 BOOST_CHECK_GT( tracks, 0 );
136 BOOST_CHECK_GT( vias, 0 );
137 BOOST_CHECK_GT( board->Footprints().size(), 0 );
138
139 int pads = 0;
140
141 for( FOOTPRINT* fp : board->Footprints() )
142 pads += fp->Pads().size();
143
144 BOOST_CHECK_GT( pads, 0 );
145}
146
147
150BOOST_AUTO_TEST_CASE( AllSamplesLoad )
151{
152 const std::vector<std::string> samples = { "PRJ.PCB", "PRJ2.PCB", "PRJ10.PCB", "PRJ12.PCB" };
153
154 bool any = false;
155
156 for( const std::string& name : samples )
157 {
158 if( !haveSample( name ) )
159 continue;
160
161 any = true;
162
163 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
164 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( name ), board.get(), nullptr ) );
165 BOOST_REQUIRE( board );
166
167 size_t items = board->Tracks().size() + board->Footprints().size() + board->Drawings().size();
168 BOOST_CHECK_GT( items, 0 );
169 }
170
171 if( !any )
172 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
173}
174
175
const char * name
General utilities for PCB file IO for QA programs.
Read-only importer for Protel Autotrax (.PCB, "PCB FILE 4") and Easytrax (.PCB, "PCB FILE 5") layout ...
A type-safe container of any type.
Definition ki_any.h:93
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::string path(const std::string &aName)
bool haveSample(const std::string &aName)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(SniffRecognizesPcb)
CanReadBoard must accept a real Autotrax file by sniffing the magic header, not just the (gEDA-shared...
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
std::string path
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93