KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_footprint_pad_fixup.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 <base_units.h>
23#include <board.h>
24#include <footprint.h>
25#include <pad.h>
26#include <padstack.h>
27
28
29BOOST_AUTO_TEST_SUITE( FootprintPadFixup )
30
32{
36
39 m_Pad( new PAD( &m_Footprint ) )
40 {
41 m_Board.SetBoardUse( BOARD_USE::FPHOLDER );
42 m_Board.SetCopperLayerCount( 4 );
44
45 m_Pad->SetAttribute( PAD_ATTRIB::SMD );
46 m_Pad->SetPadstackMode( PADSTACK::MODE::NORMAL );
48
49 const VECTOR2I pad_size = VECTOR2I( pcbIUScale.mmToIU( 1.0 ), pcbIUScale.mmToIU( 1.0 ) );
50 m_Pad->SetSize( PADSTACK::ALL_LAYERS, pad_size );
51 m_Footprint.Add( m_Pad );
52 }
53};
54
55
56BOOST_FIXTURE_TEST_CASE( PthPadExpandsToAllCopperLayers, FOOTPRINT_PAD_FIXUP_FIXTURE )
57{
58 m_Pad->SetAttribute( PAD_ATTRIB::PTH );
59 m_Pad->SetLayerSet( LSET( { F_Cu, B_Cu } ) );
60
61 m_Footprint.FixUpPadsForBoard( &m_Board );
62
63 const LSET layers = m_Pad->GetLayerSet();
64
65 BOOST_CHECK_EQUAL( layers.count(), 4u );
66
67 BOOST_CHECK( layers.test( F_Cu ) );
68 BOOST_CHECK( layers.test( In1_Cu ) );
69 BOOST_CHECK( layers.test( In2_Cu ) );
70 BOOST_CHECK( layers.test( B_Cu ) );
71}
72
73
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
@ FPHOLDER
Definition board.h:403
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:170
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:179
Definition pad.h:61
@ EXPAND_INNER_LAYERS
The 'normal' stackup handling, where there is a single inner layer (In1) and rule areas using it expa...
Definition footprint.h:111
@ B_Cu
Definition layer_ids.h:61
@ In2_Cu
Definition layer_ids.h:63
@ In1_Cu
Definition layer_ids.h:62
@ F_Cu
Definition layer_ids.h:60
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:98
@ PTH
Plated through hole pad.
Definition padstack.h:97
@ RECTANGLE
Definition padstack.h:53
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_FIXTURE_TEST_CASE(PthPadExpandsToAllCopperLayers, FOOTPRINT_PAD_FIXUP_FIXTURE)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708