45#include <wx/filename.h>
58 BOOST_REQUIRE_MESSAGE( wxFileName::FileExists( dataPath ),
59 "missing binary Eagle sample " + dataPath );
66 BOARD* board =
nullptr;
70 board = eaglePlugin.
LoadBoard( dataPath,
nullptr,
nullptr );
74 BOOST_FAIL(
"IO_ERROR loading binary Eagle board: " + e.
What().ToStdString() );
76 catch(
const std::exception& e )
78 BOOST_FAIL( std::string(
"Exception loading binary Eagle board: " ) + e.
what() );
86 std::vector<ZONE*> pours;
90 if( !zone->GetIsRuleArea() &&
IsCopperLayer( zone->GetFirstLayer() ) )
91 pours.push_back( zone );
109 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_b1a.brd" ) );
112 BOOST_CHECK_GT( board->Footprints().size(), 0u );
113 BOOST_CHECK_GT( board->Tracks().size(), 0u );
114 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
125 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_v1a.brd" ) );
128 BOOST_CHECK_GT( board->Footprints().size(), 0u );
129 BOOST_CHECK_GT( board->Tracks().size(), 0u );
141 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/rocketgps.brd" ) );
144 BOOST_CHECK_GT( board->Footprints().size(), 0u );
145 BOOST_CHECK_GT( board->Tracks().size(), 0u );
146 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
159 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
162 BOOST_CHECK_GT( board->Footprints().size(), 0u );
163 BOOST_CHECK_GT( board->Tracks().size(), 0u );
164 BOOST_CHECK_GT( board->GetNetInfo().GetNetCount(), 1u );
168 for(
PCB_TRACK* track : board->Tracks() )
169 BOOST_CHECK( track->GetNet() !=
nullptr );
180 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/turnemoff.brd" ) );
183 BOOST_CHECK_GT( board->Footprints().size(), 0u );
184 BOOST_CHECK_GT( board->Tracks().size(), 0u );
196 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_b1a.brd" ) );
199 std::set<wxString> texts;
204 texts.insert(
text->GetText() );
207 BOOST_CHECK( texts.count( wxS(
"blinkm.thingm.com" ) ) );
208 BOOST_CHECK( texts.count( wxS(
"BlinkM USB" ) ) );
221 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
224 std::map<int, double> ledRot;
226 for(
FOOTPRINT* fp : board->Footprints() )
230 if( fp->GetReference().StartsWith( wxS(
"LED" ) ) && fp->GetReference().Mid( 3 ).ToLong( &n ) )
231 ledRot[(int) n] = fp->GetOrientation().AsDegrees();
234 for(
int n = 1; n < 16; n++ )
236 BOOST_REQUIRE_MESSAGE( ledRot.count( n ) && ledRot.count( n + 1 ),
237 "expected ring footprints LED" << n <<
" and LED" << ( n + 1 ) );
239 double step = ledRot[n + 1] - ledRot[n];
241 while( step > 180.0 )
244 while( step <= -180.0 )
247 BOOST_CHECK_CLOSE( step, 22.5, 0.5 );
263 auto invalidLayerItems = [](
BOARD* board )
270 count += bad( item->GetLayer() );
272 for(
PCB_TRACK* track : board->Tracks() )
273 count += bad( track->GetLayer() );
275 for(
FOOTPRINT* fp : board->Footprints() )
277 for(
BOARD_ITEM* item : fp->GraphicalItems() )
278 count += bad( item->GetLayer() );
284 auto ruleAreas = [](
BOARD* board )
288 for(
ZONE* zone : board->Zones() )
289 count += zone->GetIsRuleArea();
294 for(
const char* relPath : {
"plugins/eagle_binary/boomchak.brd",
295 "plugins/eagle_binary/turnemoff.brd" } )
297 std::unique_ptr<BOARD> board( loadBoard( relPath ) );
306 std::unique_ptr<BOARD> turnemoff( loadBoard(
"plugins/eagle_binary/turnemoff.brd" ) );
309 BOOST_CHECK_GT( ruleAreas( turnemoff.get() ), 500 );
324 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/blink1_b1a.brd" ) );
327 auto footprintTexts = [&]()
329 std::set<wxString> texts;
331 for(
FOOTPRINT* fp : board->Footprints() )
333 texts.insert( fp->Value().GetText() );
335 for(
BOARD_ITEM* item : fp->GraphicalItems() )
338 texts.insert(
text->GetText() );
345 BOOST_CHECK( !footprintTexts.count( wxS(
"${VALU}" ) ) );
346 BOOST_CHECK( !footprintTexts.count( wxS(
">VALU" ) ) );
359 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/boomchak.brd" ) );
362 std::vector<ZONE*> pours = copperPours( board.get() );
364 BOOST_REQUIRE_GE( pours.size(), 2u );
368 for(
ZONE* zone : pours )
371 BOOST_CHECK_GE( zone->GetNumCorners(), 3 );
375 BOOST_CHECK( std::any_of( pours.begin(), pours.end(),
378 return aZone->GetNetname() == wxS(
"GND" );
394 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
397 BOOST_REQUIRE_GT( board->Footprints().size(), 0u );
399 int padsWithNumber = 0;
400 int padsWithoutNumber = 0;
401 int multiPinPartsWithDistinctNets = 0;
403 for(
FOOTPRINT* fp : board->Footprints() )
407 for(
PAD*
pad : fp->Pads() )
409 if(
pad->GetNumber().IsEmpty() )
414 nets.insert(
pad->GetNetCode() );
417 if( fp->Pads().size() > 1 && nets.size() > 1 )
418 multiPinPartsWithDistinctNets++;
423 BOOST_CHECK_GT( padsWithNumber, 0 );
428 BOOST_CHECK_GT( multiPinPartsWithDistinctNets, 0 );
442 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
445 auto shapeOf = [&](
const wxString& aRef ) ->
PAD_SHAPE
447 for(
FOOTPRINT* fp : board->Footprints() )
449 if( fp->GetReference() == aRef && !fp->Pads().empty() )
476 std::unique_ptr<BOARD> board( loadBoard(
"plugins/eagle_binary/issue24827_brenner57e.brd" ) );
479 auto bodyArcs = [&](
const wxString& aRef )
481 std::vector<PCB_SHAPE*> arcs;
483 for(
FOOTPRINT* fp : board->Footprints() )
485 if( fp->GetReference() != aRef )
488 for(
BOARD_ITEM* item : fp->GraphicalItems() )
493 arcs.push_back( shape );
502 for(
const wxString& ref : { wxS(
"Q2" ), wxS(
"IC3" ) } )
504 std::vector<PCB_SHAPE*> arcs = bodyArcs( ref );
505 BOOST_REQUIRE_GT( arcs.size(), 1u );
511 int dist = ( arc->GetCenter() -
center ).EuclideanNorm();
512 BOOST_CHECK_MESSAGE( dist <
pcbIUScale.mmToIU( 0.5 ),
513 ref <<
" silk arc center is " << dist / 1e6 <<
" mm off the body center" );
constexpr EDA_IU_SCALE pcbIUScale
General utilities for PCB file IO for QA programs.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const char * what() const override
std::exception interface, returned as UTF-8
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Works with Eagle 6.x XML board files and footprints to implement the Pcbnew #PLUGIN API or a portion ...
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Handle a list of polygons defining a copper zone.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
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.
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
BOARD * loadBoard(const std::string &aRelPath)
static std::vector< ZONE * > copperPours(BOARD *aBoard)
EAGLE_BINARY_IMPORT_FIXTURE()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(LoadBinaryV4V5)
Load a v4/v5 binary board (magic 0x10 0x00) which also carries the trailing free-text and DRC section...
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I