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