KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_easyedapro_import.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
24
28
31
32#include <board.h>
33#include <footprint.h>
34#include <pad.h>
35#include <pcb_shape.h>
36
37
44
45
46BOOST_FIXTURE_TEST_SUITE( EasyedaproImport, EASYEDAPRO_IMPORT_FIXTURE )
47
48
49
54BOOST_AUTO_TEST_CASE( PolygonPadImport )
55{
56 std::string dataPath = KI_TEST::GetPcbnewTestDataDir()
57 + "plugins/easyedapro/PDFN-8_L3.2-W3.1-P0.65-LS3.4-BL-EP2.efoo";
58
59 wxString fpName = wxS( "PDFN-8_L3.2-W3.1-P0.65-LS3.4-BL-EP2" );
60 FOOTPRINT* fp = plugin.FootprintLoad( dataPath, fpName, false, nullptr );
61
62 BOOST_REQUIRE( fp );
63
64 // The footprint should have 10 pads: 8 numbered pads plus 2 polygon-shaped pads (9 and 10)
65 BOOST_CHECK_EQUAL( fp->Pads().size(), 10 );
66
67 // Find the polygon pads (pads 9 and 10 in the test file)
68 PAD* pad9 = fp->FindPadByNumber( "9" );
69 PAD* pad10 = fp->FindPadByNumber( "10" );
70
71 BOOST_REQUIRE( pad9 );
72 BOOST_REQUIRE( pad10 );
73
74 // These pads should be custom shape (POLYGON in EasyEDA Pro becomes CUSTOM in KiCad)
75 BOOST_CHECK_EQUAL( static_cast<int>( pad9->GetShape( PADSTACK::ALL_LAYERS ) ),
76 static_cast<int>( PAD_SHAPE::CUSTOM ) );
77 BOOST_CHECK_EQUAL( static_cast<int>( pad10->GetShape( PADSTACK::ALL_LAYERS ) ),
78 static_cast<int>( PAD_SHAPE::CUSTOM ) );
79
80 // Check that primitives were added to the custom pads
81 BOOST_CHECK( !pad9->GetPrimitives( PADSTACK::ALL_LAYERS ).empty() );
82 BOOST_CHECK( !pad10->GetPrimitives( PADSTACK::ALL_LAYERS ).empty() );
83
84 delete fp;
85}
86
87
93BOOST_AUTO_TEST_CASE( ParsePolyDegenerateClosedPathSkipped )
94{
95 BOARD board;
96 PCB_IO_EASYEDAPRO_PARSER parser( &board, nullptr );
97
98 nlohmann::json polyData = nlohmann::json::parse( R"(["L", 5, 5])" );
99
100 std::vector<std::unique_ptr<PCB_SHAPE>> shapes;
101 BOOST_CHECK_NO_THROW( shapes = parser.ParsePoly( &board, polyData, true, false ) );
102 BOOST_CHECK( shapes.empty() );
103}
104
105
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
std::deque< PAD * > & Pads()
Definition footprint.h:375
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:177
Definition pad.h:61
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
Definition pad.h:370
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:202
std::vector< std::unique_ptr< PCB_SHAPE > > ParsePoly(BOARD_ITEM_CONTAINER *aContainer, nlohmann::json polyData, bool aClosed, bool aInFill) const
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(PolygonPadImport)
Test importing a footprint with POLYGON-shaped pads (issue #20348) EasyEDA Pro uses POLYGON shape typ...
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")