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, see <https://www.gnu.org/licenses/>.
18 */
19
29
33
35
36#include <board.h>
37#include <footprint.h>
38#include <pad.h>
39#include <pcb_track.h>
40#include <pcb_shape.h>
41
42#include <wx/filename.h>
43
44
46{
48
50
51 std::string path( const std::string& aName )
52 {
53 return KI_TEST::GetPcbnewTestDataDir() + "plugins/autotrax/" + aName;
54 }
55
56 bool haveSample( const std::string& aName ) { return wxFileName::FileExists( path( aName ) ); }
57};
58
59
60BOOST_FIXTURE_TEST_SUITE( AutotraxImport, AUTOTRAX_IMPORT_FIXTURE )
61
62
63
65BOOST_AUTO_TEST_CASE( SniffRecognizesPcb )
66{
67 if( !haveSample( "PRJ.PCB" ) )
68 {
69 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
70 return;
71 }
72
73 BOOST_CHECK( m_plugin.CanReadBoard( path( "PRJ.PCB" ) ) );
74}
75
76
79BOOST_AUTO_TEST_CASE( SimpleBoardStructure )
80{
81 if( !haveSample( "PRJ.PCB" ) )
82 {
83 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
84 return;
85 }
86
87 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
88
89 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( "PRJ.PCB" ), board.get(), nullptr ) );
90 BOOST_REQUIRE( board );
91
92 BOOST_CHECK_GT( board->Footprints().size(), 0 );
93
94 int pads = 0;
95
96 for( FOOTPRINT* fp : board->Footprints() )
97 pads += fp->Pads().size();
98
99 BOOST_CHECK_GT( pads, 0 );
100 BOOST_CHECK_GT( board->Tracks().size(), 0 );
101}
102
103
107BOOST_AUTO_TEST_CASE( RichBoardStructure )
108{
109 if( !haveSample( "PRJ12.PCB" ) )
110 {
111 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
112 return;
113 }
114
115 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
116
117 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( "PRJ12.PCB" ), board.get(), nullptr ) );
118 BOOST_REQUIRE( board );
119
120 int tracks = 0;
121 int vias = 0;
122
123 for( PCB_TRACK* t : board->Tracks() )
124 {
125 if( t->Type() == PCB_VIA_T )
126 vias++;
127 else if( t->Type() == PCB_TRACE_T )
128 tracks++;
129 }
130
131 BOOST_CHECK_GT( tracks, 0 );
132 BOOST_CHECK_GT( vias, 0 );
133 BOOST_CHECK_GT( board->Footprints().size(), 0 );
134
135 int pads = 0;
136
137 for( FOOTPRINT* fp : board->Footprints() )
138 pads += fp->Pads().size();
139
140 BOOST_CHECK_GT( pads, 0 );
141}
142
143
146BOOST_AUTO_TEST_CASE( AllSamplesLoad )
147{
148 const std::vector<std::string> samples = { "PRJ.PCB", "PRJ2.PCB", "PRJ10.PCB", "PRJ12.PCB" };
149
150 bool any = false;
151
152 for( const std::string& name : samples )
153 {
154 if( !haveSample( name ) )
155 continue;
156
157 any = true;
158
159 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
160 BOOST_REQUIRE_NO_THROW( m_plugin.LoadBoard( path( name ), board.get(), nullptr ) );
161 BOOST_REQUIRE( board );
162
163 size_t items = board->Tracks().size() + board->Footprints().size() + board->Drawings().size();
164 BOOST_CHECK_GT( items, 0 );
165 }
166
167 if( !any )
168 BOOST_TEST_MESSAGE( "no real autotrax sample available; load test skipped" );
169}
170
171
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:92
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:90
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89