KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_test_utils.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
25
26#include <iostream>
27#include <filesystem>
28
29#include <wx/filename.h>
30
31#include <boost/test/unit_test.hpp>
32
33#include <board.h>
34#include <board_commit.h>
36#include <footprint.h>
37#include <kiid.h>
38#include <pad.h>
39#include <pcb_shape.h>
40#include <pcb_track.h>
41#include <zone.h>
42#include <zone_filler.h>
44#include <drc/drc_engine.h>
47#include <tool/tool_manager.h>
48
49#define CHECK_ENUM_CLASS_EQUAL( L, R ) \
50 BOOST_CHECK_EQUAL( static_cast<int>( L ), static_cast<int>( R ) )
51
52
53std::ostream& boost_test_print_type( std::ostream& os, const VIATYPE& aViaType )
54{
55 // clang-format off
56 switch( aViaType )
57 {
58 case VIATYPE::THROUGH: os << "THROUGH"; break;
59 case VIATYPE::BLIND: os << "BLIND"; break;
60 case VIATYPE::BURIED: os << "BURIED"; break;
61 case VIATYPE::MICROVIA: os << "MICROVIA"; break;
62 default:
63 os << "UNKNOWN_VIA_TYPE(" << static_cast<int>( aViaType ) << ")";
64 }
65 // clang-format on
66 return os;
67}
68
69
70namespace KI_TEST
71{
72
77
78
79void BOARD_DUMPER::DumpBoardToFile( BOARD& aBoard, const std::string& aName ) const
80{
81 if( !m_dump_boards )
82 return;
83
84 auto path = std::filesystem::temp_directory_path() / aName;
85 path += ".kicad_pcb";
86
87 BOOST_TEST_MESSAGE( "Dumping board file: " << path.string() );
88 ::KI_TEST::DumpBoardToFile( aBoard, path.string() );
89}
90
91
92void LoadBoard( SETTINGS_MANAGER& aSettingsManager, const wxString& aRelPath,
93 std::unique_ptr<BOARD>& aBoard )
94{
95 if( aBoard )
96 {
97 aBoard->SetProject( nullptr );
98 aBoard = nullptr;
99 }
100
101 std::string absPath = GetPcbnewTestDataDir() + aRelPath.ToStdString();
102 wxFileName projectFile( absPath + ".kicad_pro" );
103 wxFileName legacyProject( absPath + ".pro" );
104 std::string boardPath = absPath + ".kicad_pcb";
105 wxFileName rulesFile( absPath + ".kicad_dru" );
106
107 if( projectFile.Exists() )
108 {
109 aSettingsManager.LoadProject( projectFile.GetFullPath() );
110 BOOST_TEST_MESSAGE( "Loading project file: " << projectFile.GetFullPath() );
111 }
112 else if( legacyProject.Exists() )
113 {
114 aSettingsManager.LoadProject( legacyProject.GetFullPath() );
115 BOOST_TEST_MESSAGE( "Loading project file: " << projectFile.GetFullPath() );
116 }
117 else
118 BOOST_TEST_MESSAGE( "Could not load project: " << projectFile.GetFullPath() );
119
120 BOOST_TEST_MESSAGE( "Loading board file: " << boardPath );
121
122 try {
123 aBoard = ReadBoardFromFileOrStream( boardPath );
124 }
125 catch( const IO_ERROR& ioe )
126 {
127 BOOST_TEST_ERROR( ioe.What() );
128 }
129
130 BOOST_REQUIRE_MESSAGE( aBoard, "aBoard is null or invalid" );
131
132 if( projectFile.Exists() || legacyProject.Exists() )
133 aBoard->SetProject( &aSettingsManager.Prj() );
134
135 auto m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard.get(), &aBoard->GetDesignSettings() );
136
137 BOOST_TEST_CHECKPOINT( "Init drc engine" );
138
139 if( rulesFile.Exists() )
140 m_DRCEngine->InitEngine( rulesFile );
141 else
142 m_DRCEngine->InitEngine( wxFileName() );
143
144 aBoard->GetDesignSettings().m_DRCEngine = m_DRCEngine;
145
146 BOOST_TEST_CHECKPOINT( "Build list of nets" );
147 try
148 {
149 aBoard->BuildListOfNets();
150 }
151 catch( const std::exception& e )
152 {
153 BOOST_TEST_ERROR( "Exception in BuildListOfNets: " << e.what() );
154 return;
155 }
156
157 BOOST_TEST_CHECKPOINT( "Build connectivity" );
158 try
159 {
160 aBoard->BuildConnectivity();
161 }
162 catch( const std::exception& e )
163 {
164 BOOST_TEST_ERROR( "Exception in BuildConnectivity: " << e.what() );
165 return;
166 }
167
168 BOOST_TEST_CHECKPOINT( "Synchronize Tuning Profile Properties" );
169 try
170 {
171 aBoard->GetLengthCalculation()->SynchronizeTuningProfileProperties();
172 }
173 catch( const std::exception& e )
174 {
175 BOOST_TEST_ERROR( "Exception in SynchronizeTimeDomainProperties: " << e.what() );
176 return;
177 }
178
179 if( aBoard->GetProject() )
180 {
181 std::unordered_set<wxString> dummy;
182 BOOST_TEST_CHECKPOINT( "Synchronize Component Classes" );
183 try
184 {
185 aBoard->SynchronizeComponentClasses( dummy );
186 }
187 catch( const std::exception& e )
188 {
189 BOOST_TEST_ERROR( "Exception in SynchronizeComponentClasses: " << e.what() );
190 return;
191 }
192 }
193}
194
195
196BOARD_ITEM& RequireBoardItemWithTypeAndId( const BOARD& aBoard, KICAD_T aItemType, const KIID& aID )
197{
198 BOARD_ITEM* item = aBoard.ResolveItem( aID, true );
199
200 BOOST_REQUIRE( item );
201 BOOST_REQUIRE_EQUAL( item->Type(), aItemType );
202
203 return *item;
204}
205
206
211{
212public:
217 TEMPORARY_DIRECTORY( const std::string& aNamePrefix, const std::string aSuffix )
218 {
219 int i = 0;
220
221 // Find a unique directory name
222 while( true )
223 {
224 m_path = std::filesystem::temp_directory_path()
225 / ( aNamePrefix + std::to_string( i ) + aSuffix );
226
227 if( !std::filesystem::exists( m_path ) )
228 break;
229
230 i++;
231 }
232
233 wxASSERT( !std::filesystem::exists( m_path ) );
234 std::filesystem::create_directories( m_path );
235 }
236
237 ~TEMPORARY_DIRECTORY() { std::filesystem::remove_all( m_path ); }
238
239 const std::filesystem::path& GetPath() const { return m_path; }
240
241private:
242 std::filesystem::path m_path;
243};
244
245
246void LoadAndTestBoardFile( const wxString aRelativePath, bool aRoundtrip,
247 std::function<void( BOARD& )> aBoardTestFunction,
248 std::optional<int> aExpectedBoardVersion )
249{
250 const std::string absBoardPath =
251 KI_TEST::GetPcbnewTestDataDir() + aRelativePath.ToStdString() + ".kicad_pcb";
252
253 BOOST_TEST_MESSAGE( "Loading board to test: " << absBoardPath );
254 std::unique_ptr<BOARD> board1 = KI_TEST::ReadBoardFromFileOrStream( absBoardPath );
255
256 // Should load - if it doesn't we're done for
257 BOOST_REQUIRE( board1 );
258
259 BOOST_TEST_MESSAGE( "Testing loaded board" );
260 aBoardTestFunction( *board1 );
261
262 // If we care about the board version, check it now - but not after a roundtrip
263 // (as the version will be updated to the current version)
264 if( aExpectedBoardVersion )
265 {
266 BOOST_CHECK_EQUAL( board1->GetFileFormatVersionAtLoad(), *aExpectedBoardVersion );
267 }
268
269 if( aRoundtrip )
270 {
271 TEMPORARY_DIRECTORY tempLib( "kicad_qa_brd_roundtrip", "" );
272
273 const auto savePath = tempLib.GetPath() / ( aRelativePath.ToStdString() + ".kicad_pcb" );
274 KI_TEST::DumpBoardToFile( *board1, savePath.string() );
275
276 std::unique_ptr<BOARD> board2 = KI_TEST::ReadBoardFromFileOrStream( savePath.string() );
277
278 // Should load again
279 BOOST_REQUIRE( board2 );
280
281 BOOST_TEST_MESSAGE( "Testing roundtripped (saved/reloaded) file" );
282 aBoardTestFunction( *board2 );
283 }
284}
285
286
287void LoadAndTestFootprintFile( const wxString& aLibRelativePath, const wxString& aFpName,
288 bool aRoundtrip,
289 std::function<void( FOOTPRINT& )> aFootprintTestFunction,
290 std::optional<int> aExpectedFootprintVersion )
291{
292 const std::string absFootprintPath = KI_TEST::GetPcbnewTestDataDir()
293 + aLibRelativePath.ToStdString() + "/"
294 + aFpName.ToStdString() + ".kicad_mod";
295
296 BOOST_TEST_MESSAGE( "Loading footprint to test: " << absFootprintPath );
297 std::unique_ptr<FOOTPRINT> fp1 = KI_TEST::ReadFootprintFromFileOrStream( absFootprintPath );
298
299 // Should load - if it doesn't we're done for
300 BOOST_REQUIRE( fp1 );
301
302 BOOST_TEST_MESSAGE( "Testing loaded footprint (value: " << fp1->GetValue() << ")" );
303 aFootprintTestFunction( *fp1 );
304
305 // If we care about the board version, check it now - but not after a roundtrip
306 // (as the version will be updated to the current version)
307 if( aExpectedFootprintVersion )
308 {
309 BOOST_CHECK_EQUAL( fp1->GetFileFormatVersionAtLoad(), *aExpectedFootprintVersion );
310 }
311
312 if( aRoundtrip )
313 {
319 TEMPORARY_DIRECTORY tempLib( "kicad_qa_fp_roundtrip", ".pretty" );
320 const wxString fpFilename = fp1->GetFPID().GetLibItemName() + wxString( ".kicad_mod" );
321
322 BOOST_TEST_MESSAGE( "Resaving footprint: " << fpFilename << " in " << tempLib.GetPath() );
323
324 KI_TEST::DumpFootprintToFile( *fp1, tempLib.GetPath().string() );
325
326 const auto fp2Path = tempLib.GetPath() / fpFilename.ToStdString();
327
328 BOOST_TEST_MESSAGE( "Re-reading footprint: " << fpFilename << " in " << tempLib.GetPath() );
329
330 std::unique_ptr<FOOTPRINT> fp2 = KI_TEST::ReadFootprintFromFileOrStream( fp2Path.string() );
331
332 // Should load again
333 BOOST_REQUIRE( fp2 );
334
335 BOOST_TEST_MESSAGE( "Testing roundtripped (saved/reloaded) file" );
336 aFootprintTestFunction( *fp2 );
337 }
338}
339
340
341void FillZones( BOARD* m_board )
342{
343 BOOST_TEST_CHECKPOINT( "Filling zones" );
344
345 TOOL_MANAGER toolMgr;
346 toolMgr.SetEnvironment( m_board, nullptr, nullptr, nullptr, nullptr );
347
348 KI_TEST::DUMMY_TOOL* dummyTool = new KI_TEST::DUMMY_TOOL();
349 toolMgr.RegisterTool( dummyTool );
350
351 BOARD_COMMIT commit( dummyTool );
352 ZONE_FILLER filler( m_board, &commit );
353 std::vector<ZONE*> toFill;
354
355 for( ZONE* zone : m_board->Zones() )
356 toFill.push_back( zone );
357
358 if( filler.Fill( toFill, false, nullptr ) )
359 commit.Push( _( "Fill Zone(s)" ), SKIP_UNDO | SKIP_SET_DIRTY | ZONE_FILL_OP | SKIP_CONNECTIVITY );
360
361 BOOST_TEST_CHECKPOINT( "Building connectivity (after zone fill)" );
362 m_board->BuildConnectivity();
363}
364
365
366#define TEST( a, b ) \
367 { \
368 if( a != b ) \
369 return a < b; \
370 }
371#define TEST_PT( a, b ) \
372 { \
373 if( a.x != b.x ) \
374 return a.x < b.x; \
375 if( a.y != b.y ) \
376 return a.y < b.y; \
377 }
378
379
381{
383
384 bool operator()( const BOARD_ITEM* itemA, const BOARD_ITEM* itemB ) const
385 {
386 TEST( itemA->Type(), itemB->Type() );
387
388 if( itemA->GetLayerSet() != itemB->GetLayerSet() )
389 return itemA->GetLayerSet().Seq() < itemB->GetLayerSet().Seq();
390
391 if( itemA->Type() == PCB_TEXT_T )
392 {
393 const PCB_TEXT* textA = static_cast<const PCB_TEXT*>( itemA );
394 const PCB_TEXT* textB = static_cast<const PCB_TEXT*>( itemB );
395
396 TEST_PT( textA->GetPosition(), textB->GetPosition() );
397 TEST( textA->GetTextAngle(), textB->GetTextAngle() );
398 }
399
400 return fp_comp( itemA, itemB );
401 }
402};
403
404
406{
407 CHECK_ENUM_CLASS_EQUAL( expected->Type(), fp->Type() );
408
409 // TODO: validate those informations match the importer
410 BOOST_CHECK_EQUAL( expected->GetPosition(), fp->GetPosition() );
411 BOOST_CHECK_EQUAL( expected->GetOrientation(), fp->GetOrientation() );
412
413 BOOST_CHECK_EQUAL( expected->GetReference(), fp->GetReference() );
414 BOOST_CHECK_EQUAL( expected->GetValue(), fp->GetValue() );
415 BOOST_CHECK_EQUAL( expected->GetLibDescription(), fp->GetLibDescription() );
416 BOOST_CHECK_EQUAL( expected->GetKeywords(), fp->GetKeywords() );
417 BOOST_CHECK_EQUAL( expected->GetAttributes(), fp->GetAttributes() );
418 BOOST_CHECK_EQUAL( expected->GetFlag(), fp->GetFlag() );
419 //BOOST_CHECK_EQUAL( expected->GetProperties(), fp->GetProperties() );
420 BOOST_CHECK_EQUAL( expected->GetTypeName(), fp->GetTypeName() );
421
422 // simple test if count matches
423 BOOST_CHECK_EQUAL( expected->GetFields().size(), fp->GetFields().size() );
424 BOOST_CHECK_EQUAL( expected->Pads().size(), fp->Pads().size() );
425 BOOST_CHECK_EQUAL( expected->GraphicalItems().size(), fp->GraphicalItems().size() );
426 BOOST_CHECK_EQUAL( expected->Zones().size(), fp->Zones().size() );
427 BOOST_CHECK_EQUAL( expected->Groups().size(), fp->Groups().size() );
428 BOOST_CHECK_EQUAL( expected->Models().size(), fp->Models().size() );
429
430 std::set<PAD*, FOOTPRINT::cmp_pads> expectedPads( expected->Pads().begin(),
431 expected->Pads().end() );
432 std::set<PAD*, FOOTPRINT::cmp_pads> fpPads( fp->Pads().begin(), fp->Pads().end() );
433
434 for( auto itExpected = expectedPads.begin(), itFp = fpPads.begin();
435 itExpected != expectedPads.end() && itFp != fpPads.end(); itExpected++, itFp++ )
436 {
437 CheckFpPad( *itExpected, *itFp );
438 }
439
440 std::set<BOARD_ITEM*, kitest_cmp_drawings> expectedGraphicalItems( expected->GraphicalItems().begin(),
441 expected->GraphicalItems().end() );
442 std::set<BOARD_ITEM*, kitest_cmp_drawings> fpGraphicalItems( fp->GraphicalItems().begin(),
443 fp->GraphicalItems().end() );
444
445 for( auto itExpected = expectedGraphicalItems.begin(), itFp = fpGraphicalItems.begin();
446 itExpected != expectedGraphicalItems.end() && itFp != fpGraphicalItems.end();
447 itExpected++, itFp++ )
448 {
449 BOOST_CHECK_EQUAL( ( *itExpected )->Type(), ( *itFp )->Type() );
450
451 switch( ( *itExpected )->Type() )
452 {
453 case PCB_TEXT_T:
454 {
455 const PCB_TEXT* expectedText = static_cast<const PCB_TEXT*>( *itExpected );
456 const PCB_TEXT* text = static_cast<const PCB_TEXT*>( *itFp );
457
458 CheckFpText( expectedText, text );
459 break;
460 }
461
462 case PCB_SHAPE_T:
463 {
464 const PCB_SHAPE* expectedShape = static_cast<const PCB_SHAPE*>( *itExpected );
465 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( *itFp );
466
467 CheckFpShape( expectedShape, shape );
468 break;
469 }
470
472 case PCB_DIM_LEADER_T:
473 case PCB_DIM_CENTER_T:
474 case PCB_DIM_RADIAL_T:
476 // TODO
477 break;
478
479 case PCB_BARCODE_T:
480 // TODO
481 break;
482
483 default:
484 BOOST_ERROR( "KICAD_T not known" );
485 break;
486 }
487 }
488
489 std::set<ZONE*, FOOTPRINT::cmp_zones> expectedZones( expected->Zones().begin(),
490 expected->Zones().end() );
491 std::set<ZONE*, FOOTPRINT::cmp_zones> fpZones( fp->Zones().begin(), fp->Zones().end() );
492
493 for( auto itExpected = expectedZones.begin(), itFp = fpZones.begin();
494 itExpected != expectedZones.end() && itFp != fpZones.end(); itExpected++, itFp++ )
495 {
496 CheckFpZone( *itExpected, *itFp );
497 }
498
499 // TODO: Groups
500
501 // Use FootprintNeedsUpdate as sanity check (which should do many of the same checks as above,
502 // but neither is guaranteed to be complete).
503 WX_STRING_REPORTER reporter;
504
505 if( const_cast<FOOTPRINT*>(expected)->FootprintNeedsUpdate(fp, BOARD_ITEM::COMPARE_FLAGS::DRC, &reporter) )
506 BOOST_REQUIRE_MESSAGE( false, reporter.GetMessages() );
507}
508
509
510void CheckFpPad( const PAD* expected, const PAD* pad )
511{
512 // TODO(JE) padstacks
513 BOOST_TEST_CONTEXT( "Assert PAD with KIID=" << expected->m_Uuid.AsString() )
514 {
515 CHECK_ENUM_CLASS_EQUAL( expected->Type(), pad->Type() );
516
517 BOOST_CHECK_EQUAL( expected->GetNumber(), pad->GetNumber() );
518 CHECK_ENUM_CLASS_EQUAL( expected->GetAttribute(), pad->GetAttribute() );
519 CHECK_ENUM_CLASS_EQUAL( expected->GetProperty(), pad->GetProperty() );
521 pad->GetShape( PADSTACK::ALL_LAYERS ) );
522
523 BOOST_CHECK_EQUAL( expected->IsLocked(), pad->IsLocked() );
524
525 BOOST_CHECK_EQUAL( expected->GetPosition(), pad->GetPosition() );
527 pad->GetSize( PADSTACK::ALL_LAYERS ) );
528 BOOST_CHECK_EQUAL( expected->GetOrientation(), pad->GetOrientation() );
530 pad->GetDelta( PADSTACK::ALL_LAYERS ) );
532 pad->GetOffset( PADSTACK::ALL_LAYERS ) );
533 BOOST_CHECK_EQUAL( expected->GetDrillSize(), pad->GetDrillSize() );
534 CHECK_ENUM_CLASS_EQUAL( expected->GetDrillShape(), pad->GetDrillShape() );
535
536 BOOST_CHECK_EQUAL( expected->GetLayerSet(), pad->GetLayerSet() );
537
538 BOOST_CHECK_EQUAL( expected->GetNetCode(), pad->GetNetCode() );
539 BOOST_CHECK_EQUAL( expected->GetPinFunction(), pad->GetPinFunction() );
540 BOOST_CHECK_EQUAL( expected->GetPinType(), pad->GetPinType() );
541 BOOST_CHECK_EQUAL( expected->GetPadToDieLength(), pad->GetPadToDieLength() );
542 BOOST_CHECK_EQUAL( expected->GetPadToDieDelay(), pad->GetPadToDieDelay() );
543 BOOST_CHECK_EQUAL( expected->GetLocalSolderMaskMargin().value_or( 0 ),
544 pad->GetLocalSolderMaskMargin().value_or( 0 ) );
545 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMargin().value_or( 0 ),
546 pad->GetLocalSolderPasteMargin().value_or( 0 ) );
547 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMarginRatio().value_or( 0 ),
548 pad->GetLocalSolderPasteMarginRatio().value_or( 0 ) );
549 BOOST_CHECK_EQUAL( expected->GetLocalClearance().value_or( 0 ),
550 pad->GetLocalClearance().value_or( 0 ) );
551 CHECK_ENUM_CLASS_EQUAL( expected->GetLocalZoneConnection(), pad->GetLocalZoneConnection() );
552 BOOST_CHECK_EQUAL( expected->GetLocalThermalSpokeWidthOverride().value_or( 0 ),
553 pad->GetLocalThermalSpokeWidthOverride().value_or( 0 ) );
554 BOOST_CHECK_EQUAL( expected->GetThermalSpokeAngle(), pad->GetThermalSpokeAngle() );
555 BOOST_CHECK_EQUAL( expected->GetThermalGap(), pad->GetThermalGap() );
556 BOOST_CHECK_EQUAL( expected->GetRoundRectRadiusRatio( PADSTACK::ALL_LAYERS ),
557 pad->GetRoundRectRadiusRatio( PADSTACK::ALL_LAYERS ) );
558 BOOST_CHECK_EQUAL( expected->GetChamferRectRatio( PADSTACK::ALL_LAYERS ),
559 pad->GetChamferRectRatio( PADSTACK::ALL_LAYERS ) );
560 BOOST_CHECK_EQUAL( expected->GetChamferPositions( PADSTACK::ALL_LAYERS ),
561 pad->GetChamferPositions( PADSTACK::ALL_LAYERS ) );
562 BOOST_CHECK_EQUAL( expected->GetRemoveUnconnected(), pad->GetRemoveUnconnected() );
563 BOOST_CHECK_EQUAL( expected->GetKeepTopBottom(), pad->GetKeepTopBottom() );
564
565 // TODO: did we check everything for complex pad shapes?
567 pad->GetAnchorPadShape( PADSTACK::ALL_LAYERS ) );
568 CHECK_ENUM_CLASS_EQUAL( expected->GetCustomShapeInZoneOpt(),
569 pad->GetCustomShapeInZoneOpt() );
570
571 BOOST_CHECK_EQUAL( expected->GetPrimitives( PADSTACK::ALL_LAYERS ).size(),
572 pad->GetPrimitives( PADSTACK::ALL_LAYERS ).size() );
573
574 if( expected->GetPrimitives( PADSTACK::ALL_LAYERS ).size()
575 == pad->GetPrimitives( PADSTACK::ALL_LAYERS ).size() )
576 {
577 for( size_t i = 0; i < expected->GetPrimitives( PADSTACK::ALL_LAYERS ).size(); ++i )
578 {
579 CheckFpShape( expected->GetPrimitives( PADSTACK::ALL_LAYERS ).at( i ).get(),
580 pad->GetPrimitives( PADSTACK::ALL_LAYERS ).at( i ).get() );
581 }
582 }
583 }
584}
585
586
588{
589 BOOST_TEST_CONTEXT( "Assert PCB_TEXT with KIID=" << expected->m_Uuid.AsString() )
590 {
591 CHECK_ENUM_CLASS_EQUAL( expected->Type(), text->Type() );
592
593 BOOST_CHECK_EQUAL( expected->IsLocked(), text->IsLocked() );
594
595 BOOST_CHECK_EQUAL( expected->GetText(), text->GetText() );
596 BOOST_CHECK_EQUAL( expected->GetPosition(), text->GetPosition() );
597 BOOST_CHECK_EQUAL( expected->GetTextAngle(), text->GetTextAngle() );
598 BOOST_CHECK_EQUAL( expected->IsKeepUpright(), text->IsKeepUpright() );
599
600 BOOST_CHECK_EQUAL( expected->GetLayerSet(), text->GetLayerSet() );
601 BOOST_CHECK_EQUAL( expected->IsVisible(), text->IsVisible() );
602
603 BOOST_CHECK_EQUAL( expected->GetTextSize(), text->GetTextSize() );
604 BOOST_CHECK_EQUAL( expected->GetLineSpacing(), text->GetLineSpacing() );
605 BOOST_CHECK_EQUAL( expected->GetTextThickness(), text->GetTextThickness() );
606 BOOST_CHECK_EQUAL( expected->IsBold(), text->IsBold() );
607 BOOST_CHECK_EQUAL( expected->IsItalic(), text->IsItalic() );
608 BOOST_CHECK_EQUAL( expected->GetHorizJustify(), text->GetHorizJustify() );
609 BOOST_CHECK_EQUAL( expected->GetVertJustify(), text->GetVertJustify() );
610 BOOST_CHECK_EQUAL( expected->IsMirrored(), text->IsMirrored() );
611 BOOST_CHECK_EQUAL( expected->GetFontName(), text->GetFontName() );
612
613 // TODO: render cache?
614 }
615}
616
617
618void CheckFpShape( const PCB_SHAPE* expected, const PCB_SHAPE* shape )
619{
620 BOOST_TEST_CONTEXT( "Assert PCB_SHAPE with KIID=" << expected->m_Uuid.AsString() )
621 {
622 CHECK_ENUM_CLASS_EQUAL( expected->Type(), shape->Type() );
623
624 CHECK_ENUM_CLASS_EQUAL( expected->GetShape(), shape->GetShape() );
625
626 BOOST_CHECK_EQUAL( expected->IsLocked(), shape->IsLocked() );
627
628 BOOST_CHECK_EQUAL( expected->GetStart(), shape->GetStart() );
629 BOOST_CHECK_EQUAL( expected->GetEnd(), shape->GetEnd() );
630
631 if( expected->GetShape() == SHAPE_T::ARC )
632 {
633 // center and position might differ as they are calculated from start/mid/end -> compare mid instead
634 BOOST_CHECK_EQUAL( expected->GetArcMid(), shape->GetArcMid() );
635 }
636 else
637 {
638 BOOST_CHECK_EQUAL( expected->GetCenter(), shape->GetCenter() );
639 BOOST_CHECK_EQUAL( expected->GetPosition(), shape->GetPosition() );
640 }
641
642 BOOST_CHECK_EQUAL( expected->GetBezierC1(), shape->GetBezierC1() );
643 BOOST_CHECK_EQUAL( expected->GetBezierC2(), shape->GetBezierC2() );
644
645 CheckShapePolySet( &expected->GetPolyShape(), &shape->GetPolyShape() );
646
647 BOOST_CHECK_EQUAL( expected->GetLayerSet(), shape->GetLayerSet() );
648
649 BOOST_CHECK_EQUAL( expected->GetStroke().GetWidth(), shape->GetStroke().GetWidth() );
650 CHECK_ENUM_CLASS_EQUAL( expected->GetStroke().GetLineStyle(),
651 shape->GetStroke().GetLineStyle() );
652 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), shape->GetFillMode() );
653 }
654}
655
656
657void CheckFpZone( const ZONE* expected, const ZONE* zone )
658{
659 BOOST_TEST_CONTEXT( "Assert ZONE with KIID=" << expected->m_Uuid.AsString() )
660 {
661 CHECK_ENUM_CLASS_EQUAL( expected->Type(), zone->Type() );
662
663 BOOST_CHECK_EQUAL( expected->IsLocked(), zone->IsLocked() );
664
665 BOOST_CHECK_EQUAL( expected->GetNetCode(), zone->GetNetCode() );
666 BOOST_CHECK_EQUAL( expected->GetAssignedPriority(), zone->GetAssignedPriority() );
667 CHECK_ENUM_CLASS_EQUAL( expected->GetPadConnection(), zone->GetPadConnection() );
668 BOOST_CHECK_EQUAL( expected->GetLocalClearance().value_or( 0 ),
669 zone->GetLocalClearance().value_or( 0 ) );
670 BOOST_CHECK_EQUAL( expected->GetMinThickness(), zone->GetMinThickness() );
671
672 BOOST_CHECK_EQUAL( expected->GetLayerSet(), zone->GetLayerSet() );
673
674 BOOST_CHECK_EQUAL( expected->IsFilled(), zone->IsFilled() );
675 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), zone->GetFillMode() );
676 BOOST_CHECK_EQUAL( expected->GetHatchThickness(), zone->GetHatchThickness() );
677 BOOST_CHECK_EQUAL( expected->GetHatchGap(), zone->GetHatchGap() );
678 BOOST_CHECK_EQUAL( expected->GetHatchOrientation(), zone->GetHatchOrientation() );
679 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingLevel(), zone->GetHatchSmoothingLevel() );
680 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingValue(), zone->GetHatchSmoothingValue() );
681 BOOST_CHECK_EQUAL( expected->GetHatchBorderAlgorithm(), zone->GetHatchBorderAlgorithm() );
682 BOOST_CHECK_EQUAL( expected->GetHatchHoleMinArea(), zone->GetHatchHoleMinArea() );
683 BOOST_CHECK_EQUAL( expected->GetThermalReliefGap(), zone->GetThermalReliefGap() );
684 BOOST_CHECK_EQUAL( expected->GetThermalReliefSpokeWidth(),
686 BOOST_CHECK_EQUAL( expected->GetCornerSmoothingType(), zone->GetCornerSmoothingType() );
687 BOOST_CHECK_EQUAL( expected->GetCornerRadius(), zone->GetCornerRadius() );
688 CHECK_ENUM_CLASS_EQUAL( expected->GetIslandRemovalMode(), zone->GetIslandRemovalMode() );
689 BOOST_CHECK_EQUAL( expected->GetMinIslandArea(), zone->GetMinIslandArea() );
690
691 BOOST_CHECK_EQUAL( expected->GetIsRuleArea(), zone->GetIsRuleArea() );
692 BOOST_CHECK_EQUAL( expected->GetDoNotAllowZoneFills(), zone->GetDoNotAllowZoneFills() );
693 BOOST_CHECK_EQUAL( expected->GetDoNotAllowVias(), zone->GetDoNotAllowVias() );
694 BOOST_CHECK_EQUAL( expected->GetDoNotAllowTracks(), zone->GetDoNotAllowTracks() );
695 BOOST_CHECK_EQUAL( expected->GetDoNotAllowPads(), zone->GetDoNotAllowPads() );
696 BOOST_CHECK_EQUAL( expected->GetDoNotAllowFootprints(), zone->GetDoNotAllowFootprints() );
697
698 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
699 CHECK_ENUM_CLASS_EQUAL( expected->GetTeardropAreaType(), zone->GetTeardropAreaType() );
700 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
701
702 CheckShapePolySet( expected->Outline(), zone->Outline() );
703 // TODO: filled zones
704 }
705}
706
707
709{
710 BOOST_TEST_CONTEXT( "Assert SHAPE_POLY_SET" )
711 {
712 BOOST_CHECK_EQUAL( expected->OutlineCount(), polyset->OutlineCount() );
713 BOOST_CHECK_EQUAL( expected->TotalVertices(), polyset->TotalVertices() );
714
715 if( expected->OutlineCount() != polyset->OutlineCount() )
716 return; // don't check the rest
717
718 if( expected->TotalVertices() != polyset->TotalVertices() )
719 return; // don't check the rest
720
721 // TODO: check all outlines and holes (just checking outlines for now)
722 for( int i = 0; i < expected->OutlineCount(); ++i )
723 {
724 BOOST_TEST_CONTEXT( "Outline " << i )
725 {
726 BOOST_CHECK_EQUAL( expected->Outline( i ).ArcCount(),
727 polyset->Outline( i ).ArcCount() );
728 BOOST_CHECK_EQUAL( expected->Outline( i ).PointCount(),
729 polyset->Outline( i ).PointCount() );
730
731
732 if( expected->Outline( i ).PointCount() != polyset->Outline( i ).PointCount() )
733 return; // don't check the rest
734
735 for( int j = 0; j < expected->Outline( i ).PointCount(); ++j )
736 {
737 BOOST_CHECK_EQUAL( expected->Outline( i ).GetPoint( j ),
738 polyset->Outline( i ).GetPoint( j ) );
739 }
740 }
741 }
742 }
743}
744
745
746void PrintBoardStats( const BOARD* aBoard, const std::string& aBoardName )
747{
748 if( !aBoard )
749 {
750 BOOST_TEST_MESSAGE( aBoardName << ": FAILED TO LOAD" );
751 return;
752 }
753
754 int trackCount = 0;
755 int viaCount = 0;
756 int arcCount = 0;
757
758 for( PCB_TRACK* track : aBoard->Tracks() )
759 {
760 switch( track->Type() )
761 {
762 case PCB_TRACE_T: trackCount++; break;
763 case PCB_VIA_T: viaCount++; break;
764 case PCB_ARC_T: arcCount++; break;
765 default: break;
766 }
767 }
768
769 int smdPadCount = 0;
770 int thPadCount = 0;
771
772 for( FOOTPRINT* fp : aBoard->Footprints() )
773 {
774 for( PAD* pad : fp->Pads() )
775 {
776 if( pad->GetAttribute() == PAD_ATTRIB::SMD )
777 smdPadCount++;
778 else
779 thPadCount++;
780 }
781 }
782
783 std::ostringstream ss;
784 ss << "\n=== Board Statistics: " << aBoardName << " ===\n"
785 << " Layers: " << aBoard->GetCopperLayerCount() << "\n"
786 << " Nets: " << aBoard->GetNetCount() << "\n"
787 << " Footprints: " << aBoard->Footprints().size() << "\n"
788 << " Tracks: " << trackCount << "\n"
789 << " Vias: " << viaCount << "\n"
790 << " Arcs: " << arcCount << "\n"
791 << " SMD Pads: " << smdPadCount << "\n"
792 << " TH Pads: " << thPadCount << "\n"
793 << " Zones: " << aBoard->Zones().size();
794
795 BOOST_TEST_MESSAGE( ss.str() );
796}
797
798
799REPORTER& CAPTURING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
800{
801 MESSAGE msg;
802 msg.text = aText;
803 msg.severity = aSeverity;
804 m_messages.push_back( msg );
805
806 switch( aSeverity )
807 {
808 case RPT_SEVERITY_ERROR: m_errorCount++; break;
811 case RPT_SEVERITY_ACTION: m_infoCount++; break;
812 default: break;
813 }
814
815 return *this;
816}
817
818
819void CAPTURING_REPORTER::PrintAllMessages( const std::string& aContext ) const
820{
821 if( m_messages.empty() )
822 {
823 BOOST_TEST_MESSAGE( aContext << ": No messages" );
824 return;
825 }
826
827 BOOST_TEST_MESSAGE( aContext << ": " << m_messages.size() << " messages (" << m_errorCount << " errors, "
828 << m_warningCount << " warnings)" );
829
830 for( const MESSAGE& msg : m_messages )
831 {
832 const char* severityStr = "???";
833
834 switch( msg.severity )
835 {
836 case RPT_SEVERITY_ERROR: severityStr = "ERROR"; break;
837 case RPT_SEVERITY_WARNING: severityStr = "WARN "; break;
838 case RPT_SEVERITY_INFO: severityStr = "INFO "; break;
839 case RPT_SEVERITY_ACTION: severityStr = "ACT "; break;
840 case RPT_SEVERITY_DEBUG: severityStr = "DEBUG"; break;
841 default: severityStr = " "; break;
842 }
843
844 BOOST_TEST_MESSAGE( " [" << severityStr << "] " << msg.text );
845 }
846}
847
848
849std::unique_ptr<BOARD> LoadBoardWithCapture( PCB_IO& aIoPlugin, const std::string& aFilePath, REPORTER* aReporter )
850{
851 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
852
853 aIoPlugin.SetReporter( aReporter );
854
855 try
856 {
857 aIoPlugin.LoadBoard( aFilePath, board.get(), nullptr, nullptr );
858 return board;
859 }
860 catch( const IO_ERROR& e )
861 {
862 if( aReporter )
863 aReporter->Report( wxString::Format( "IO_ERROR: %s", e.What() ), RPT_SEVERITY_ERROR );
864 return nullptr;
865 }
866 catch( const std::exception& e )
867 {
868 if( aReporter )
869 aReporter->Report( wxString::Format( "Exception: %s", e.what() ), RPT_SEVERITY_ERROR );
870 return nullptr;
871 }
872 catch( ... )
873 {
874 if( aReporter )
875 aReporter->Report( "Unknown exception during load", RPT_SEVERITY_ERROR );
876 return nullptr;
877 }
878}
879
880
881BOARD* CACHED_BOARD_LOADER::GetCachedBoard( const std::string& aFilePath )
882{
883 return getCachedBoard( aFilePath, false, nullptr );
884}
885
886
887BOARD* CACHED_BOARD_LOADER::LoadAndCache( const std::string& aFilePath, REPORTER* aReporter )
888{
889 return getCachedBoard( aFilePath, true, aReporter );
890}
891
892
893BOARD* CACHED_BOARD_LOADER::getCachedBoard( PCB_IO& aIoPlugin, const std::string& aFilePath, bool aForceReload,
894 REPORTER* aReporter )
895{
896 auto it = m_boardCache.find( aFilePath );
897
898 if( it != m_boardCache.end() && !aForceReload )
899 return it->second.get();
900
901 auto board = KI_TEST::LoadBoardWithCapture( aIoPlugin, aFilePath, aReporter );
902 BOARD* raw = board.get();
903 m_boardCache[aFilePath] = std::move( board );
904 return raw;
905}
906
907
908} // namespace KI_TEST
#define SKIP_CONNECTIVITY
#define ZONE_FILL_OP
General utilities for PCB file IO for QA programs.
std::ostream & boost_test_print_type(std::ostream &os, const VIATYPE &aViaType)
#define CHECK_ENUM_CLASS_EQUAL(L, R)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
bool IsLocked() const override
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:288
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
const ZONES & Zones() const
Definition board.h:368
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:203
int GetCopperLayerCount() const
Definition board.cpp:937
const FOOTPRINTS & Footprints() const
Definition board.h:364
const TRACKS & Tracks() const
Definition board.h:362
unsigned GetNetCount() const
Definition board.h:1033
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:1789
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:275
FILL_T GetFillMode() const
Definition eda_shape.h:158
SHAPE_POLY_SET & GetPolyShape()
SHAPE_T GetShape() const
Definition eda_shape.h:185
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:232
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:190
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:272
VECTOR2I GetArcMid() const
const EDA_ANGLE & GetTextAngle() const
Definition eda_text.h:172
wxString GetLibDescription() const
Definition footprint.h:446
EDA_ANGLE GetOrientation() const
Definition footprint.h:408
ZONES & Zones()
Definition footprint.h:383
std::deque< PAD * > & Pads()
Definition footprint.h:377
int GetAttributes() const
Definition footprint.h:495
wxString GetTypeName() const
Get the type of footprint.
GROUPS & Groups()
Definition footprint.h:386
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
std::vector< FP_3DMODEL > & Models()
Definition footprint.h:394
const wxString & GetValue() const
Definition footprint.h:851
const wxString & GetReference() const
Definition footprint.h:829
int GetFlag() const
Definition footprint.h:506
wxString GetKeywords() const
Definition footprint.h:449
VECTOR2I GetPosition() const override
Definition footprint.h:405
DRAWINGS & GraphicalItems()
Definition footprint.h:380
virtual void SetReporter(REPORTER *aReporter)
Set an optional reporter for warnings/errors.
Definition io_base.h:89
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
Definition kiid.h:48
void DumpBoardToFile(BOARD &aBoard, const std::string &aName) const
std::map< std::string, std::unique_ptr< BOARD > > m_boardCache
BOARD * getCachedBoard(PCB_IO &aIoPlugin, const std::string &aFilePath, bool aForceReload, REPORTER *aReporter)
BOARD * LoadAndCache(const std::string &aFilePath, REPORTER *aReporter)
Load (or reload) board for the given file path and send the load messages to the given reporter.
BOARD * GetCachedBoard(const std::string &aFilePath)
Get a cached board for the given file path, or load it if not already cached, without forcing a reloa...
void PrintAllMessages(const std::string &aContext) const
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
std::vector< MESSAGE > m_messages
A temporary directory that will be deleted when it goes out of scope.
const std::filesystem::path & GetPath() const
TEMPORARY_DIRECTORY(const std::string &aNamePrefix, const std::string aSuffix)
Create a temporary directory with a given prefix and suffix.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:313
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:55
A base class that BOARD loading and saving plugins should derive from.
Definition pcb_io.h:79
virtual BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into either ...
Definition pcb_io.cpp:74
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_shape.h:81
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
STROKE_PARAMS GetStroke() const override
Definition pcb_shape.h:91
VECTOR2I GetPosition() const override
Definition pcb_shape.h:79
virtual VECTOR2I GetPosition() const override
Definition pcb_text.h:97
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:104
REPORTER()
Definition reporter.h:77
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
virtual const VECTOR2I GetPoint(int aIndex) const override
int PointCount() const
Return the number of points (vertices) in this line chain.
size_t ArcCount() const
Represent a set of closed polygons.
int TotalVertices() const
Return total number of vertices stored in the set.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
int GetWidth() const
LINE_STYLE GetLineStyle() const
Master controller class:
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
A wrapper for reporting to a wxString object.
Definition reporter.h:193
const wxString & GetMessages() const
Definition reporter.cpp:105
bool Fill(const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
Handle a list of polygons defining a copper zone.
Definition zone.h:74
int GetHatchBorderAlgorithm() const
Definition zone.h:329
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition zone.h:716
std::optional< int > GetLocalClearance() const override
Definition zone.cpp:845
bool GetDoNotAllowVias() const
Definition zone.h:727
bool GetDoNotAllowPads() const
Definition zone.h:729
bool GetDoNotAllowTracks() const
Definition zone.h:728
bool IsFilled() const
Definition zone.h:293
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition zone.h:738
SHAPE_POLY_SET * Outline()
Definition zone.h:336
long long int GetMinIslandArea() const
Definition zone.h:741
const wxString & GetZoneName() const
Definition zone.h:164
int GetMinThickness() const
Definition zone.h:302
ZONE_CONNECTION GetPadConnection() const
Definition zone.h:299
int GetHatchThickness() const
Definition zone.h:311
double GetHatchHoleMinArea() const
Definition zone.h:326
int GetThermalReliefSpokeWidth() const
Definition zone.h:246
EDA_ANGLE GetHatchOrientation() const
Definition zone.h:317
bool GetDoNotAllowFootprints() const
Definition zone.h:730
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:225
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition zone.h:137
int GetHatchGap() const
Definition zone.h:314
TEARDROP_TYPE GetTeardropAreaType() const
Definition zone.h:702
double GetHatchSmoothingValue() const
Definition zone.h:323
bool GetDoNotAllowZoneFills() const
Definition zone.h:726
int GetHatchSmoothingLevel() const
Definition zone.h:320
unsigned int GetCornerRadius() const
Definition zone.h:661
int GetCornerSmoothingType() const
Definition zone.h:657
int GetThermalReliefGap() const
Definition zone.h:235
unsigned GetAssignedPriority() const
Definition zone.h:126
#define _(s)
#define TEST_PT(a, b)
#define TEST(a, b)
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void CheckFootprint(const FOOTPRINT *expected, const FOOTPRINT *fp)
Helper method to check if two footprints are semantically the same.
void PrintBoardStats(const BOARD *aBoard, const std::string &aBoardName)
Print detailed board statistics for debugging using test-framework logging.
void FillZones(BOARD *m_board)
std::unique_ptr< BOARD > LoadBoardWithCapture(PCB_IO &aIoPlugin, const std::string &aFilePath, REPORTER *aReporter)
Attempt to load an board with a given IO plugin, capturing all reporter messages.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void CheckFpShape(const PCB_SHAPE *expected, const PCB_SHAPE *shape)
std::unique_ptr< FOOTPRINT > ReadFootprintFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
void LoadAndTestFootprintFile(const wxString &aLibRelativePath, const wxString &aFpName, bool aRoundtrip, std::function< void(FOOTPRINT &)> aFootprintTestFunction, std::optional< int > aExpectedFootprintVersion)
Same as LoadAndTestBoardFile, but for footprints.
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
void CheckFpPad(const PAD *expected, const PAD *pad)
void CheckFpZone(const ZONE *expected, const ZONE *zone)
void CheckFpText(const PCB_TEXT *expected, const PCB_TEXT *text)
void DumpFootprintToFile(const FOOTPRINT &aFootprint, const std::string &aLibraryPath)
Same as DumpBoardToFile, but for footprints.
void LoadAndTestBoardFile(const wxString aRelativePath, bool aRoundtrip, std::function< void(BOARD &)> aBoardTestFunction, std::optional< int > aExpectedBoardVersion)
Perform "some test" on a board file loaded from the path, then optionally save and reload and run the...
void CheckShapePolySet(const SHAPE_POLY_SET *expected, const SHAPE_POLY_SET *polyset)
BOARD_ITEM & RequireBoardItemWithTypeAndId(const BOARD &aBoard, KICAD_T aItemType, const KIID &aID)
Get an item from the given board with a certain type and UUID.
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:99
VIATYPE
SEVERITY
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_DEBUG
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
#define SKIP_SET_DIRTY
Definition sch_commit.h:42
#define SKIP_UNDO
Definition sch_commit.h:40
std::vector< FAB_LAYER_COLOR > dummy
FOOTPRINT::cmp_drawings fp_comp
bool operator()(const BOARD_ITEM *itemA, const BOARD_ITEM *itemB) const
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
std::string path
VECTOR3I expected(15, 30, 45)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:75
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:103
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:100
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:101
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:89
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:98
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:99
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:95
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:102