KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_multichannel.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pcbnew_utils/board_test_utils.h>
#include <board.h>
#include <board_design_settings.h>
#include <pad.h>
#include <pcb_group.h>
#include <pcb_shape.h>
#include <pcb_track.h>
#include <pcb_text.h>
#include <pcb_field.h>
#include <footprint.h>
#include <zone.h>
#include <drc/drc_item.h>
#include <settings/settings_manager.h>
#include <tools/multichannel_tool.h>
#include <connectivity/topo_match.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_utils.h>
#include <lib_id.h>
#include <atomic>

Go to the source code of this file.

Classes

struct  MULTICHANNEL_TEST_FIXTURE
 
class  MOCK_TOOLS_HOLDER
 

Functions

RULE_AREAfindRuleAreaByPartialName (MULTICHANNEL_TOOL *aTool, const wxString &aName)
 
RULE_AREAfindRuleAreaByPlacementGroup (MULTICHANNEL_TOOL *aTool, const wxString &aGroupName)
 
int countZonesByNameInRuleArea (BOARD *aBoard, const wxString &aZoneName, const RULE_AREA &aRuleArea)
 
 BOOST_FIXTURE_TEST_CASE (MultichannelToolRegressions, MULTICHANNEL_TEST_FIXTURE)
 
 BOOST_FIXTURE_TEST_CASE (RepeatLayoutCopiesFootprintProperties, MULTICHANNEL_TEST_FIXTURE)
 Test that repeat layout copies footprint properties including field visibility, text positions, and 3D models (issue 22548).
 
 BOOST_FIXTURE_TEST_CASE (RepeatLayoutDoesNotRemoveReferenceVias, MULTICHANNEL_TEST_FIXTURE)
 Test that repeat layout does not remove vias from the reference area when a copper zone has the same name as one of the rule areas (issue 21184).
 
 BOOST_FIXTURE_TEST_CASE (RepeatLayoutRespectsZoneLayerSetsForOtherItems, MULTICHANNEL_TEST_FIXTURE)
 Test that "copy other items" only copies zones whose full layer sets are inside both source and target rule area layer sets (issue 22983).
 
 BOOST_FIXTURE_TEST_CASE (TopologyMatchDottedRefDes, MULTICHANNEL_TEST_FIXTURE)
 Test that topology matching works correctly with dotted reference designators used in multi-channel designs (issue 20058).
 
 BOOST_FIXTURE_TEST_CASE (GenerateRuleAreasIncludesChildSheets, MULTICHANNEL_TEST_FIXTURE)
 Test that GeneratePotentialRuleAreas includes components from child sheets when generating rule areas for a parent sheet (issue 20016).
 
 BOOST_FIXTURE_TEST_CASE (FindIsomorphismCancellation, MULTICHANNEL_TEST_FIXTURE)
 Test that FindIsomorphism respects cancellation and reports progress through the ISOMORPHISM_PARAMS interface.
 
 BOOST_FIXTURE_TEST_CASE (TopoMatchGlobalNetHierarchicalPins, MULTICHANNEL_TEST_FIXTURE)
 Test that topology matching succeeds when hierarchical pins are connected directly to global nets (issue 21739).
 
 BOOST_FIXTURE_TEST_CASE (TopoMatchBoundarySignalNetNotExcluded, MULTICHANNEL_TEST_FIXTURE)
 A design block's daisy-chain output net feeds the target instance's inputs, so it appears in both footprint sets with one pad on the reference side and several on the target side.
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutCopiesSilkscreen, MULTICHANNEL_TEST_FIXTURE)
 Apply Design Block Layout must copy silkscreen graphics that are not associated with any footprint from the design block source to the destination group (issue 24372).
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutKeepsDuplicateSilkText, MULTICHANNEL_TEST_FIXTURE)
 Apply Design Block Layout must keep a footprint's silkscreen text when the footprint has several text items with the same string (issue 24583).
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutGraphicsOnlyBlock, MULTICHANNEL_TEST_FIXTURE)
 Apply Design Block Layout must work for a footprint-free block, e.g.
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutFootprintFreeCopperIsNoNet, MULTICHANNEL_TEST_FIXTURE)
 A footprint-free block may contain copper (e.g.
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutFootprintFreeReapplyReplaces, MULTICHANNEL_TEST_FIXTURE)
 Re-applying a footprint-free block must replace the group's previously-copied content, not stack a fresh copy on top of it (issue 24592).
 
 BOOST_FIXTURE_TEST_CASE (ApplyDesignBlockLayoutKeepsOtherGroupRouting, MULTICHANNEL_TEST_FIXTURE)
 Applying a design block layout must not delete routing owned by another group.
 
 BOOST_FIXTURE_TEST_CASE (RepeatLayoutRefusesDuplicatePlacementAreas, MULTICHANNEL_TEST_FIXTURE)
 Repeat layout must refuse a target Rule Area that resolves to the same components as the reference area (issue 22318).
 
 BOOST_FIXTURE_TEST_CASE (RepeatLayoutDoesNotDuplicateUnrelatedGroups, MULTICHANNEL_TEST_FIXTURE)
 Repeat layout with "group items with their target rule areas" must not duplicate unrelated user groups that merely overlap the source rule area (issue 22316).
 
 BOOST_FIXTURE_TEST_CASE (TopoMatchExternalLoopReportsConnectivity, MULTICHANNEL_TEST_FIXTURE)
 Two channels of the same hierarchical sheet can have genuinely different internal connectivity when one channel's hierarchical pins are externally looped together on the parent sheet (issue 24192).
 

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/18]

BOOST_FIXTURE_TEST_CASE ( ApplyDesignBlockLayoutCopiesSilkscreen ,
MULTICHANNEL_TEST_FIXTURE  )

Apply Design Block Layout must copy silkscreen graphics that are not associated with any footprint from the design block source to the destination group (issue 24372).

The bug was that copyRuleAreaContents filtered "other items" by the rule area zone's LayerSet, but the synthetic rule area zones created for the design block / group placement flow always use LSET::AllCuMask(). That filter rejected silkscreen, fab and user-layer graphics even though they were explicitly enumerated in m_designBlockItems.

Definition at line 981 of file test_multichannel.cpp.

References FOOTPRINT::Add(), EDA_GROUP::AddItem(), ZONE::AddPolygon(), LSET::AllCuMask(), LSET::AllTechMask(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), KIGEOM::BoxToLineChain(), BOX2< VECTOR2I >::ByCorners(), DESIGN_BLOCK, F_Cu, F_SilkS, FOOTPRINT, EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), GROUP_PLACEMENT, RULE_AREA::m_components, RULE_AREA::m_designBlockItems, RULE_AREA::m_sourceType, RULE_AREA::m_zone, PAD, pad, PCB_SHAPE_T, pcbIUScale, RECTANGLE, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, SEGMENT, PCB_SHAPE::SetEnd(), TOOL_MANAGER::SetEnvironment(), FOOTPRINT::SetFPID(), ZONE::SetIsRuleArea(), PCB_SHAPE::SetLayer(), ZONE::SetLayerSet(), EDA_GROUP::SetName(), FOOTPRINT::SetPosition(), FOOTPRINT::SetReference(), PCB_SHAPE::SetStart(), PCB_SHAPE::SetStroke(), SOLID, and VECTOR2< T >::x.

◆ BOOST_FIXTURE_TEST_CASE() [2/18]

◆ BOOST_FIXTURE_TEST_CASE() [3/18]

◆ BOOST_FIXTURE_TEST_CASE() [4/18]

◆ BOOST_FIXTURE_TEST_CASE() [5/18]

BOOST_FIXTURE_TEST_CASE ( ApplyDesignBlockLayoutKeepsDuplicateSilkText ,
MULTICHANNEL_TEST_FIXTURE  )

Apply Design Block Layout must keep a footprint's silkscreen text when the footprint has several text items with the same string (issue 24583).

A flippable switch footprint has two "${REFERENCE}" texts, one on F.SilkS and one on B.SilkS. The old code matched footprint texts by string only and stopped at the first match, so both source texts went to the same target item and the front silkscreen text was lost.

Definition at line 1162 of file test_multichannel.cpp.

References FOOTPRINT::Add(), EDA_GROUP::AddItem(), ZONE::AddPolygon(), LSET::AllCuMask(), LSET::AllTechMask(), B_SilkS, BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), KIGEOM::BoxToLineChain(), BOX2< VECTOR2I >::ByCorners(), DESIGN_BLOCK, F_Cu, F_SilkS, FOOTPRINT, FOOTPRINT::GraphicalItems(), GROUP_PLACEMENT, RULE_AREA::m_components, RULE_AREA::m_designBlockItems, RULE_AREA::m_sourceType, RULE_AREA::m_zone, PAD, pad, PCB_TEXT_T, pcbIUScale, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, TOOL_MANAGER::SetEnvironment(), FOOTPRINT::SetFPID(), ZONE::SetIsRuleArea(), BOARD_ITEM::SetLayer(), ZONE::SetLayerSet(), EDA_GROUP::SetName(), FOOTPRINT::SetPosition(), PCB_TEXT::SetPosition(), FOOTPRINT::SetReference(), and EDA_TEXT::SetText().

◆ BOOST_FIXTURE_TEST_CASE() [6/18]

BOOST_FIXTURE_TEST_CASE ( ApplyDesignBlockLayoutKeepsOtherGroupRouting ,
MULTICHANNEL_TEST_FIXTURE  )

Applying a design block layout must not delete routing owned by another group.

When several instances of the same block overlap (e.g. stacked right after Update PCB) the target area encloses a sibling instance's traces. Removing them made each apply wipe the previously applied instance's routing, so only the last instance kept its layout (issue 24767). Loose, ungrouped routing in the target area must still be replaced.

Definition at line 1628 of file test_multichannel.cpp.

References EDA_GROUP::AddItem(), ZONE::AddPolygon(), LSET::AllCuMask(), LSET::AllTechMask(), BOOST_CHECK_MESSAGE(), KIGEOM::BoxToLineChain(), BOX2< VECTOR2I >::ByCorners(), SHAPE::Centre(), SHAPE_POLY_SET::COutline(), DESIGN_BLOCK, F_Cu, F_SilkS, GROUP_PLACEMENT, RULE_AREA::m_center, RULE_AREA::m_designBlockItems, RULE_AREA::m_group, RULE_AREA::m_sourceType, RULE_AREA::m_zone, ZONE::Outline(), pcbIUScale, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, SEGMENT, PCB_SHAPE::SetEnd(), PCB_TRACK::SetEnd(), TOOL_MANAGER::SetEnvironment(), ZONE::SetIsRuleArea(), BOARD_CONNECTED_ITEM::SetLayer(), PCB_SHAPE::SetLayer(), ZONE::SetLayerSet(), EDA_GROUP::SetName(), BOARD_CONNECTED_ITEM::SetNet(), PCB_SHAPE::SetStart(), PCB_TRACK::SetStart(), PCB_SHAPE::SetStroke(), PCB_TRACK::SetWidth(), and SOLID.

◆ BOOST_FIXTURE_TEST_CASE() [7/18]

◆ BOOST_FIXTURE_TEST_CASE() [8/18]

BOOST_FIXTURE_TEST_CASE ( GenerateRuleAreasIncludesChildSheets ,
MULTICHANNEL_TEST_FIXTURE  )

Test that GeneratePotentialRuleAreas includes components from child sheets when generating rule areas for a parent sheet (issue 20016).

The vme-wren board has hierarchical sheets like /io_drivers_fp/bank0/ which contains child sheets /io_drivers_fp/bank0/io01/ through io78/. The parent sheet's rule area should include all components from child sheets.

Definition at line 622 of file test_multichannel.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::GeneratePotentialRuleAreas(), MULTICHANNEL_TOOL::GetData(), KI_TEST::LoadBoard(), RULE_AREA::m_components, RULE_AREA::m_sheetPath, TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::SetEnvironment().

◆ BOOST_FIXTURE_TEST_CASE() [9/18]

◆ BOOST_FIXTURE_TEST_CASE() [10/18]

◆ BOOST_FIXTURE_TEST_CASE() [11/18]

BOOST_FIXTURE_TEST_CASE ( RepeatLayoutDoesNotDuplicateUnrelatedGroups ,
MULTICHANNEL_TEST_FIXTURE  )

Repeat layout with "group items with their target rule areas" must not duplicate unrelated user groups that merely overlap the source rule area (issue 22316).

The fixture has four sheet-based rule areas ("test 1".."test 4") and three user groups ("test group A/B/C") that contain footprints and tracks. Some of those grouped tracks fall geometrically inside the source rule area, so the copy-routing pass duplicates them. The bug was that cloning the parent group of any single copied item produced partial "phantom" clones of the unrelated user groups. After the fix, a source group is only reconstructed in the target when all of its members are part of the copied layout.

Definition at line 1824 of file test_multichannel.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::CheckRACompatibility(), MULTICHANNEL_TOOL::FindExistingRuleAreas(), MULTICHANNEL_TOOL::GetData(), group, KI_TEST::LoadBoard(), RULE_AREA::m_ruleName, RULE_AREA::m_zone, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, and TOOL_MANAGER::SetEnvironment().

◆ BOOST_FIXTURE_TEST_CASE() [12/18]

BOOST_FIXTURE_TEST_CASE ( RepeatLayoutDoesNotRemoveReferenceVias ,
MULTICHANNEL_TEST_FIXTURE  )

Test that repeat layout does not remove vias from the reference area when a copper zone has the same name as one of the rule areas (issue 21184).

The bug occurred because enclosedByArea() matched zones by name, and when a copper fill zone shared a name with a rule area, items enclosed by either zone could be incorrectly affected.

Definition at line 375 of file test_multichannel.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::CheckRACompatibility(), SHAPE_POLY_SET::Contains(), MULTICHANNEL_TOOL::FindExistingRuleAreas(), MULTICHANNEL_TOOL::GetData(), KI_TEST::LoadBoard(), RULE_AREA::m_ruleName, RULE_AREA::m_zone, ZONE::Outline(), PCB_VIA_T, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, TOOL_MANAGER::SetEnvironment(), and via.

◆ BOOST_FIXTURE_TEST_CASE() [13/18]

BOOST_FIXTURE_TEST_CASE ( RepeatLayoutRefusesDuplicatePlacementAreas ,
MULTICHANNEL_TEST_FIXTURE  )

Repeat layout must refuse a target Rule Area that resolves to the same components as the reference area (issue 22318).

The repro board has four placement rule areas all bound to the same sheet "/test sheet 1/", so each resolves to the identical footprint set; copying one onto another would move and delete the reference's own items.

Definition at line 1755 of file test_multichannel.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::CheckRACompatibility(), MULTICHANNEL_TOOL::FindExistingRuleAreas(), MULTICHANNEL_TOOL::GetData(), KI_TEST::LoadBoard(), RULE_AREA::m_components, RULE_AREA::m_zone, TOOL_MANAGER::RegisterTool(), MULTICHANNEL_TOOL::RepeatLayout(), result, and TOOL_MANAGER::SetEnvironment().

◆ BOOST_FIXTURE_TEST_CASE() [14/18]

◆ BOOST_FIXTURE_TEST_CASE() [15/18]

BOOST_FIXTURE_TEST_CASE ( TopologyMatchDottedRefDes ,
MULTICHANNEL_TEST_FIXTURE  )

Test that topology matching works correctly with dotted reference designators used in multi-channel designs (issue 20058).

Reference designators like TRIM_1.1 and TRIM_2.1 should be considered the same kind because they share the base prefix "TRIM_".

Definition at line 528 of file test_multichannel.cpp.

References FOOTPRINT::Add(), BOOST_CHECK_EQUAL(), BOOST_TEST_MESSAGE(), FOOTPRINT::Pads(), result, FOOTPRINT::SetFPID(), BOARD_CONNECTED_ITEM::SetNetCode(), PAD::SetNumber(), and FOOTPRINT::SetReference().

◆ BOOST_FIXTURE_TEST_CASE() [16/18]

BOOST_FIXTURE_TEST_CASE ( TopoMatchBoundarySignalNetNotExcluded ,
MULTICHANNEL_TEST_FIXTURE  )

A design block's daisy-chain output net feeds the target instance's inputs, so it appears in both footprint sets with one pad on the reference side and several on the target side.

It must not be excluded as a global rail; doing so asymmetrically broke the isomorphism and reported "No compatible component found in the target area." Regression test for that case.

Definition at line 880 of file test_multichannel.cpp.

References FOOTPRINT::Add(), PADSTACK::ALL_LAYERS, BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_TEST_MESSAGE(), CIRCLE, F_Cu, FOOTPRINT, NETINFO_ITEM::GetNetCode(), PAD, pad, pcbIUScale, result, FOOTPRINT::SetFPID(), and FOOTPRINT::SetReference().

◆ BOOST_FIXTURE_TEST_CASE() [17/18]

BOOST_FIXTURE_TEST_CASE ( TopoMatchExternalLoopReportsConnectivity ,
MULTICHANNEL_TEST_FIXTURE  )

Two channels of the same hierarchical sheet can have genuinely different internal connectivity when one channel's hierarchical pins are externally looped together on the parent sheet (issue 24192).

In that case the topology match correctly fails, but the failure message must explain the real connectivity difference instead of a generic "no compatible component found" message that wrongly implies a missing or differently-counted part.

Definition at line 1905 of file test_multichannel.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::FindExistingRuleAreas(), MULTICHANNEL_TOOL::GetData(), FOOTPRINT::GetReference(), KI_TEST::LoadBoard(), RULE_AREA::m_components, RULE_AREA::m_ruleName, TOOL_MANAGER::RegisterTool(), result, and TOOL_MANAGER::SetEnvironment().

◆ BOOST_FIXTURE_TEST_CASE() [18/18]

BOOST_FIXTURE_TEST_CASE ( TopoMatchGlobalNetHierarchicalPins ,
MULTICHANNEL_TEST_FIXTURE  )

Test that topology matching succeeds when hierarchical pins are connected directly to global nets (issue 21739).

When address-select pins (AD0, AD2) are tied directly to GND or +3V3 in the parent schematic, those pads end up on a global net that also includes power-supply and pull-up pads from other components in the channel. Without the fix this creates different intra-channel connection counts between channels, producing a false topology-mismatch error.

Definition at line 801 of file test_multichannel.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), MULTICHANNEL_TOOL::FindExistingRuleAreas(), MULTICHANNEL_TOOL::GetData(), ZONE::GetPlacementAreaSource(), KI_TEST::LoadBoard(), RULE_AREA::m_components, RULE_AREA::m_zone, TOOL_MANAGER::RegisterTool(), result, and TOOL_MANAGER::SetEnvironment().

◆ countZonesByNameInRuleArea()

int countZonesByNameInRuleArea ( BOARD * aBoard,
const wxString & aZoneName,
const RULE_AREA & aRuleArea )

◆ findRuleAreaByPartialName()

RULE_AREA * findRuleAreaByPartialName ( MULTICHANNEL_TOOL * aTool,
const wxString & aName )

◆ findRuleAreaByPlacementGroup()

RULE_AREA * findRuleAreaByPlacementGroup ( MULTICHANNEL_TOOL * aTool,
const wxString & aGroupName )