KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pads_import.cpp File Reference
#include <pcbnew_utils/board_test_utils.h>
#include <pcbnew_utils/board_file_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pcb_io/pads/pcb_io_pads.h>
#include <layer_ids.h>
#include <padstack.h>
#include <board.h>
#include <pcb_text.h>
#include <pcb_shape.h>
#include <pcb_field.h>
#include <pad.h>
#include <pcb_track.h>
#include <footprint.h>
#include <zone.h>
#include <board_design_settings.h>
#include <pcb_dimension.h>
#include <project/net_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <set>

Go to the source code of this file.

Classes

struct  PADS_BOARD_INFO
 

Functions

static wxString GetBoardPath (const PADS_BOARD_INFO &aBoard)
 
static std::unique_ptr< BOARDLoadAndVerify (const PADS_BOARD_INFO &aBoard)
 Verify that the PADS file is recognized and loads without crashing.
 
static void RunStructuralChecks (const PADS_BOARD_INFO &aBoard)
 Run structural integrity checks on a successfully loaded board.
 
 BOOST_AUTO_TEST_CASE (ImportClaySight_MK1)
 
 BOOST_AUTO_TEST_CASE (ClaySight_MK1_ElementCounts)
 Verify element counts for ClaySight_MK1 (V10.0 BASIC units).
 
 BOOST_AUTO_TEST_CASE (ImportTMS1mmX19)
 
 BOOST_AUTO_TEST_CASE (ImportMC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (ImportMC2_PLUS_REV1)
 
 BOOST_AUTO_TEST_CASE (ImportEms4_Rev2)
 
 BOOST_AUTO_TEST_CASE (ImportLCORE_4)
 
 BOOST_AUTO_TEST_CASE (ImportLCORE_2)
 
 BOOST_AUTO_TEST_CASE (ImportDexter_MotorCtrl)
 
 BOOST_AUTO_TEST_CASE (ImportMAIS_FC)
 
 BOOST_AUTO_TEST_CASE (ImportNonCopperTrackSkipped)
 
 BOOST_AUTO_TEST_CASE (ImportTextOnUnmappedLayer)
 
 BOOST_AUTO_TEST_CASE (ImportClaySight_MK2)
 
 BOOST_AUTO_TEST_CASE (ClaySight_MK2_ElementCounts)
 Verify element counts for ClaySight_MK2 (V10.0 BASIC units, EasyEDA export).
 
 BOOST_AUTO_TEST_CASE (MAIS_FC_Stackup)
 Verify stackup is built from LAYER DATA for MAIS_FC (V5.0 BASIC, 2-layer).
 
 BOOST_AUTO_TEST_CASE (ImportDegeneratePourSkipped)
 Verify that degenerate pour definitions (PADTHERM/VIATHERM with < 3 points) are skipped without crashing.
 
 BOOST_AUTO_TEST_CASE (ImportFilledCopperSingleOutline)
 Verify that filled copper shapes produce zones with exactly one valid outline.
 
 BOOST_AUTO_TEST_CASE (Importer_SpecificFixes)
 Verify Importer.asc (V10.0 BASIC, 6-layer) imports correctly.
 
 BOOST_AUTO_TEST_CASE (Peka_ViaImport)
 Verify peka.asc (V9.0 BASIC, 4-layer) via import.
 
 BOOST_AUTO_TEST_CASE (Importer_OvalDrillHits)
 Verify that U1 pads 1-5 in Importer.asc have oval drill hits.
 
 BOOST_AUTO_TEST_CASE (Peka_AlternateDecalDrill)
 Verify M4 pad 1 in peka.asc uses the alternate MTHOLEAAAB decal.
 
 BOOST_AUTO_TEST_CASE (Peka_ZoneFillNoSelfIntersection)
 Verify zone fills imported from peka.asc are not self-intersecting.
 

Variables

static const PADS_BOARD_INFO PADS_BOARDS []
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/22]

BOOST_AUTO_TEST_CASE ( ClaySight_MK1_ElementCounts )

Verify element counts for ClaySight_MK1 (V10.0 BASIC units).

This board is a 2-layer design with 36 components, routed traces on F.Cu and B.Cu, no vias, no copper pours, and a rectangular board outline. Counts are derived from the ASC source file sections.

Definition at line 220 of file test_pads_import.cpp.

References B_Cu, BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), Edge_Cuts, F_Cu, NETINFO_ITEM::GetNetname(), LoadAndVerify(), PADS_BOARDS, PCB_ARC_T, PCB_TRACE_T, and PCB_VIA_T.

◆ BOOST_AUTO_TEST_CASE() [2/22]

BOOST_AUTO_TEST_CASE ( ClaySight_MK2_ElementCounts )

Verify element counts for ClaySight_MK2 (V10.0 BASIC units, EasyEDA export).

EasyEDA exports footprint silkscreen outlines as COPPER type entries on the silkscreen layer in the LINES section. These are imported as silkscreen graphics rather than copper tracks. Route tracks come from SIGNAL sections.

Definition at line 433 of file test_pads_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), Edge_Cuts, F_SilkS, NET_SETTINGS::GetDefaultNetclass(), NETINFO_ITEM::GetNetname(), IsCopperLayer(), LoadAndVerify(), BOARD_DESIGN_SETTINGS::m_CopperEdgeClearance, BOARD_DESIGN_SETTINGS::m_NetSettings, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, PADS_BOARDS, PCB_ARC_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, RECTANGLE, and text.

◆ BOOST_AUTO_TEST_CASE() [3/22]

BOOST_AUTO_TEST_CASE ( ImportClaySight_MK1 )

Definition at line 207 of file test_pads_import.cpp.

References BOOST_AUTO_TEST_CASE(), PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [4/22]

BOOST_AUTO_TEST_CASE ( ImportClaySight_MK2 )

Definition at line 420 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [5/22]

BOOST_AUTO_TEST_CASE ( ImportDegeneratePourSkipped )

Verify that degenerate pour definitions (PADTHERM/VIATHERM with < 3 points) are skipped without crashing.

Before the fix, these created zones with empty SHAPE_LINE_CHAIN outlines which caused a SIGABRT in the renderer's DrawPolyline() when accessing CPoint(0) on a zero-length vector.

Definition at line 609 of file test_pads_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SHAPE_POLY_SET::COutline(), KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

◆ BOOST_AUTO_TEST_CASE() [6/22]

BOOST_AUTO_TEST_CASE ( ImportDexter_MotorCtrl )

Definition at line 344 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [7/22]

BOOST_AUTO_TEST_CASE ( ImportEms4_Rev2 )

Definition at line 326 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [8/22]

BOOST_AUTO_TEST_CASE ( Importer_OvalDrillHits )

Verify that U1 pads 1-5 in Importer.asc have oval drill hits.

The DIOB_D100JHT160V decal's PAD 0 definition includes slotted drill parameters (2250000 x 9000000 BASIC units at 0 degrees). The converter must set PAD_DRILL_SHAPE::OBLONG with the correct major/minor dimensions rather than treating the drill as round.

Definition at line 888 of file test_pads_import.cpp.

References std::abs(), BOOST_REQUIRE(), KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), OBLONG, pad, FOOTPRINT::Pads(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOOST_AUTO_TEST_CASE() [9/22]

BOOST_AUTO_TEST_CASE ( Importer_SpecificFixes )

Verify Importer.asc (V10.0 BASIC, 6-layer) imports correctly.

This board exercises four specific import scenarios:

  1. Graphics on PADS layers 18/19/20 (UNASSIGNED type) must be imported
  2. Copper pours with HATOUT fills and VOIDOUT holes
  3. Oval finger (OF) pads on U1 must not be overwritten by thermal (RT) entries
  4. Dimension line with non-aligned base points must not be skewed

Definition at line 670 of file test_pads_import.cpp.

References PADSTACK::ALL_LAYERS, BOOST_REQUIRE(), Dwgs_User, end, KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), OVAL, pad, FOOTPRINT::Pads(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOOST_AUTO_TEST_CASE() [10/22]

BOOST_AUTO_TEST_CASE ( ImportFilledCopperSingleOutline )

Verify that filled copper shapes produce zones with exactly one valid outline.

Before the fix, loadCopperShapes() called NewOutline() then Append(SHAPE_LINE_CHAIN), which created two outlines per zone: an empty polygon from NewOutline() and the real one from the implicit SHAPE_LINE_CHAIN->SHAPE_POLY_SET conversion. The empty outline (0 points, but closed) crashed the renderer via CPoint(0) on an empty vector.

Definition at line 643 of file test_pads_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SHAPE_POLY_SET::COutline(), KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

◆ BOOST_AUTO_TEST_CASE() [11/22]

BOOST_AUTO_TEST_CASE ( ImportLCORE_2 )

Definition at line 338 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [12/22]

BOOST_AUTO_TEST_CASE ( ImportLCORE_4 )

Definition at line 332 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [13/22]

BOOST_AUTO_TEST_CASE ( ImportMAIS_FC )

Definition at line 350 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [14/22]

BOOST_AUTO_TEST_CASE ( ImportMC2_PLUS_REV1 )

Definition at line 320 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [15/22]

BOOST_AUTO_TEST_CASE ( ImportMC4_PLUS_CSHAPE )

Definition at line 314 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [16/22]

BOOST_AUTO_TEST_CASE ( ImportNonCopperTrackSkipped )

◆ BOOST_AUTO_TEST_CASE() [17/22]

BOOST_AUTO_TEST_CASE ( ImportTextOnUnmappedLayer )

◆ BOOST_AUTO_TEST_CASE() [18/22]

BOOST_AUTO_TEST_CASE ( ImportTMS1mmX19 )

Definition at line 308 of file test_pads_import.cpp.

References PADS_BOARDS, and RunStructuralChecks().

◆ BOOST_AUTO_TEST_CASE() [19/22]

BOOST_AUTO_TEST_CASE ( MAIS_FC_Stackup )

Verify stackup is built from LAYER DATA for MAIS_FC (V5.0 BASIC, 2-layer).

MAIS_FC has meaningful stackup data for its 2 copper layers: LAYER_THICKNESS 304800, COPPER_THICKNESS 38100, DIELECTRIC 3.8.

Definition at line 567 of file test_pads_import.cpp.

References BOOST_REQUIRE(), BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD_STACKUP::GetList(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), LoadAndVerify(), BOARD_DESIGN_SETTINGS::m_HasStackup, and PADS_BOARDS.

◆ BOOST_AUTO_TEST_CASE() [20/22]

BOOST_AUTO_TEST_CASE ( Peka_AlternateDecalDrill )

Verify M4 pad 1 in peka.asc uses the alternate MTHOLEAAAB decal.

The MTHOLE part type has alternate decals separated by colons. M4 has ALT=1 which selects MTHOLEAAAB (250 mil pad, 125 mil circular drill). The converter must resolve through the PARTTYPE section to pick the correct alternate rather than defaulting to the base MTHOLE decal.

Definition at line 960 of file test_pads_import.cpp.

References std::abs(), BOOST_REQUIRE(), CIRCLE, F_Cu, KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), pad, FOOTPRINT::Pads(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOOST_AUTO_TEST_CASE() [21/22]

BOOST_AUTO_TEST_CASE ( Peka_ViaImport )

Verify peka.asc (V9.0 BASIC, 4-layer) via import.

STANDARDVIA spans all 4 copper layers (-2=top, -1=bottom) plus non-copper entries (layer 0=inner pad, layer 25=soldermask). Three specific issues:

  1. Via classified as blind instead of through-hole because the soldermask layer (25) inflates the span beyond the copper layer count
  2. Via size uses the soldermask opening (~63 mil) instead of the copper pad size (~36 mil) because def.size takes the max across all layers
  3. Multiple copies of the same through-hole via because deduplication only applies to VIATYPE::THROUGH

Definition at line 787 of file test_pads_import.cpp.

References BLIND, BOOST_REQUIRE(), F_Cu, KI_TEST::GetPcbnewTestDataDir(), PCB_IO_PADS::LoadBoard(), TENTED, THROUGH, via, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOOST_AUTO_TEST_CASE() [22/22]

BOOST_AUTO_TEST_CASE ( Peka_ZoneFillNoSelfIntersection )

Verify zone fills imported from peka.asc are not self-intersecting.

The HATOUT records define complex outlines with arcs that get converted to polyline approximations. Errors in arc conversion (wrong winding, bad radius, or incorrect center) can produce outlines that cross themselves. Every filled polygon on every layer must be clean.

Definition at line 1021 of file test_pads_import.cpp.

References BOOST_REQUIRE(), SHAPE_POLY_SET::CIterateSegmentsWithHoles(), Collide(), KI_TEST::GetPcbnewTestDataDir(), and PCB_IO_PADS::LoadBoard().

◆ GetBoardPath()

static wxString GetBoardPath ( const PADS_BOARD_INFO & aBoard)
static

◆ LoadAndVerify()

static std::unique_ptr< BOARD > LoadAndVerify ( const PADS_BOARD_INFO & aBoard)
static

Verify that the PADS file is recognized and loads without crashing.

Definition at line 76 of file test_pads_import.cpp.

References PCB_IO_PADS::CanReadBoard(), PADS_BOARD_INFO::dir, GetBoardPath(), and PCB_IO_PADS::LoadBoard().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and RunStructuralChecks().

◆ RunStructuralChecks()

static void RunStructuralChecks ( const PADS_BOARD_INFO & aBoard)
static

Run structural integrity checks on a successfully loaded board.

Uses BOOST_WARN for checks that expose known parser limitations so they report issues without failing the test suite. Invariant checks (no duplicate vias, tracks on copper) use BOOST_CHECK since they must always hold.

Definition at line 113 of file test_pads_import.cpp.

References PADSTACK::ALL_LAYERS, SHAPE_POLY_SET::COutline(), PADS_BOARD_INFO::dir, BOX2< Vec >::Intersects(), IsCopperLayer(), LoadAndVerify(), BOX2< Vec >::Merge(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), pad, PCB_ARC_T, PCB_TRACE_T, SHAPE_LINE_CHAIN::PointCount(), BOX2< Vec >::SetMaximum(), THROUGH, and via.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ PADS_BOARDS

const PADS_BOARD_INFO PADS_BOARDS[]
static
Initial value:
= {
{ "ClaySight_MK1", "ClaySight_MK1.asc" },
{ "TMS1mmX19", "TMS1mmX19.asc" },
{ "MC4_PLUS_CSHAPE", "MC4_PLUS_CSHAPE.asc" },
{ "MC2_PLUS_REV1", "MC2_PLUS_REV1.asc" },
{ "Ems4_Rev2", "Ems4_Rev2.asc" },
{ "LCORE_4", "LCORE_4.asc" },
{ "LCORE_2", "LCORE_2.asc" },
{ "Dexter_MotorCtrl", "Dexter_MotorCtrl.asc" },
{ "MAIS_FC", "MAIS_FC.asc" },
{ "ClaySight_MK2", "ClaySight_MK2.asc" },
}

Definition at line 53 of file test_pads_import.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().