35 #include "../board_test_utils.h" 111 std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( &aBoard );
116 footprint->SetReference( aFPDef.
m_refdes );
119 footprint->SetPosition( (wxPoint) aFPDef.
m_pos );
129 std::unique_ptr<BOARD>
MakeBoard(
const std::vector<COURTYARD_TEST_FP>& aFPDefs )
131 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
137 board->Add( footprint.release() );
160 "single empty footprint",
172 "single footprint, single courtyard",
190 "two footprint, no overlap",
220 "two footprints, touching, no overlap",
250 "two footprints, overlap",
282 "two footprints, overlap, different sides",
312 "two footprints, multiple courtyards, overlap",
351 "two footprints, no overlap, bbox overlap",
390 auto reporter = std::static_pointer_cast<DRC_ITEM>( aMarker.
GetRCItem() );
392 const FOOTPRINT* item_a = dynamic_cast<FOOTPRINT*>( aBoard.
GetItem( reporter->GetMainItemID() ) );
393 const FOOTPRINT* item_b = dynamic_cast<FOOTPRINT*>( aBoard.
GetItem( reporter->GetAuxItemID() ) );
396 if( !item_a || !item_b )
399 const bool ref_match_aa_bb = ( item_a->GetReference() == aCollision.
m_refdes_a )
402 const bool ref_match_ab_ba = ( item_a->GetReference() == aCollision.
m_refdes_b )
406 return ref_match_aa_bb || ref_match_ab_ba;
418 const std::vector<std::unique_ptr<PCB_MARKER>>& aMarkers,
419 const std::vector<COURTYARD_COLLISION>& aExpCollisions )
421 for(
const auto& marker : aMarkers )
423 BOOST_CHECK_PREDICATE(
455 std::vector<std::unique_ptr<PCB_MARKER>> markers;
457 DRC_ENGINE drcEngine( board.get(), &board->GetDesignSettings() );
461 drcEngine.SetViolationHandler(
462 [&](
const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos )
468 markers.push_back( std::make_unique<PCB_MARKER>( aItem, aPos ) );
489 BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< BOARD > MakeBoard(const std::vector< COURTYARD_TEST_FP > &aFPDefs)
Make a board for courtyard testing.
BOARD_ITEM * GetItem(const KIID &aID) const
BOOST_AUTO_TEST_CASE(OverlapCases)
Design Rule Checker object that performs all the DRC tests.
std::unique_ptr< FOOTPRINT > MakeCourtyardTestFP(BOARD &aBoard, const COURTYARD_TEST_FP &aFPDef)
Construct a FOOTPRINT to use in a courtyard test from a COURTYARD_TEST_FP definition.
std::vector< COURTYARD_COLLISION > m_collisions
static void CheckCollisionsMatchExpected(BOARD &aBoard, const std::vector< std::unique_ptr< PCB_MARKER >> &aMarkers, const std::vector< COURTYARD_COLLISION > &aExpCollisions)
Check that the produced markers match the expected.
static std::vector< COURTYARD_OVERLAP_TEST_CASE > courtyard_cases
void DumpBoardToFile(BOARD &aBoard, const std::string &aName) const
Construction utilities for PCB tests.
std::ostream & operator<<(std::ostream &os, const COURTYARD_COLLISION &aColl)
const KI_TEST::BOARD_DUMPER m_dumper
PCB_LAYER_ID
A quick note on layer IDs:
static bool CollisionMatchesExpected(BOARD &aBoard, const PCB_MARKER &aMarker, const COURTYARD_COLLISION &aCollision)
Check if a PCB_MARKER is described by a particular COURTYARD_COLLISION object.
Functions to provide common constants and other functions to assist in making a consistent UI.
void CheckUnorderedMatches(const EXP_CONT &aExpected, const FOUND_CONT &aFound, MATCH_PRED aMatchPredicate)
Check that a container of "found" objects matches a container of "expected" objects.
#define BOOST_TEST_CONTEXT(A)
static void DoCourtyardOverlapTest(const COURTYARD_OVERLAP_TEST_CASE &aCase, const KI_TEST::BOARD_DUMPER &aDumper)
Run a single courtyard overlap testcase.
std::vector< COURTYARD_TEST_FP > m_fpDefs
void DrawRect(FOOTPRINT &aFootprint, const VECTOR2I &aPos, const VECTOR2I &aSize, int aRadius, int aWidth, PCB_LAYER_ID aLayer)
Draw a rectangle on a footprint.
Simple definition of a rectangle, can be rounded.
A complete courtyard overlap test case: a name, the board footprint list and the expected collisions.
Information pertinent to a Pcbnew printed circuit board.
std::map< int, SEVERITY > m_DRCSeverities
bool IsDrcMarkerOfType(const PCB_MARKER &aMarker, int aErrorCode)
Predicate for testing the type of a DRC marker.
std::vector< RECT_DEFINITION > m_rects
General utilities for PCB file IO for QA programs.
General utilities for DRC-related PCB tests.
static constexpr int Millimeter2iu(double mm)
void AddRectCourtyard(FOOTPRINT &aFootprint, const RECT_DEFINITION &aRect)
Add a rectangular courtyard outline to a footprint.
A helper that contains logic to assist in dumping boards to disk depending on some environment variab...
std::shared_ptr< RC_ITEM > GetRCItem() const
void InitEngine(const wxFileName &aRulePath)
Initializes the DRC engine.
Container for design settings for a BOARD object.