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