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