KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_altium_pcblib_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 (C) 2022-2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
32#include <boost/test/data/test_case.hpp>
33
36
37#include <board.h>
38#include <footprint.h>
39#include <pad.h>
40#include <zone.h>
41
42
44{
46
49};
50
51
55BOOST_FIXTURE_TEST_SUITE( AltiumPcbLibImport, ALTIUM_PCBLIB_IMPORT_FIXTURE )
56
57static const std::vector<std::tuple<wxString, wxString>> altium_to_kicad_footprint_property = {
58 { "Tracks.v5.PcbLib", "Tracks.pretty" },
59 { "Tracks.v6.PcbLib", "Tracks.pretty" },
60 { "Espressif ESP32-WROOM-32.PcbLib", "Espressif ESP32-WROOM-32.pretty" }
61};
62
66BOOST_DATA_TEST_CASE( AltiumPcbLibImport2,
67 boost::unit_test::data::make(altium_to_kicad_footprint_property),
68 altiumLibraryName,
69 kicadLibraryName )
70{
71 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/altium/pcblib/";
72
73 wxString altiumLibraryPath = dataPath + altiumLibraryName;
74 wxString kicadLibraryPath = dataPath + kicadLibraryName;
75
76 wxArrayString altiumFootprintNames;
77 wxArrayString kicadFootprintNames;
78
79 altiumPlugin.FootprintEnumerate( altiumFootprintNames, altiumLibraryPath, true, nullptr );
80 kicadPlugin.FootprintEnumerate( kicadFootprintNames, kicadLibraryPath, true, nullptr );
81
82 BOOST_CHECK_EQUAL( altiumFootprintNames.GetCount(), kicadFootprintNames.GetCount() );
83
84 for( size_t i = 0; i < altiumFootprintNames.GetCount(); i++ )
85 {
86 wxString footprintName = altiumFootprintNames[i];
87
88 BOOST_TEST_CONTEXT( wxString::Format( wxT( "Import '%s' from '%s'" ), footprintName,
89 altiumLibraryName ) )
90 {
91 FOOTPRINT* altiumFp = altiumPlugin.FootprintLoad( altiumLibraryPath, footprintName,
92 false, nullptr );
93 BOOST_CHECK( altiumFp );
94
95 BOOST_CHECK_EQUAL( "REF**", altiumFp->GetReference() );
96 BOOST_CHECK_EQUAL( footprintName, altiumFp->GetValue() );
97
98 FOOTPRINT* kicadFp = kicadPlugin.FootprintLoad( kicadLibraryPath, footprintName,
99 true, nullptr );
100 BOOST_CHECK( kicadFp );
101
102 KI_TEST::CheckFootprint( kicadFp, altiumFp );
103 }
104 }
105}
106
General utilities for PCB file IO for QA programs.
const wxString & GetValue() const
Definition: footprint.h:623
const wxString & GetReference() const
Definition: footprint.h:601
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
void CheckFootprint(const FOOTPRINT *expected, const FOOTPRINT *fp)
Helper method to check if two footprints are semantically the same.
STL namespace.
BOOST_DATA_TEST_CASE(AltiumPcbLibImport2, boost::unit_test::data::make(altium_to_kicad_footprint_property), altiumLibraryName, kicadLibraryName)
Compare all footprints declared in a *.PcbLib file with their KiCad reference footprint.
static const std::vector< std::tuple< wxString, wxString > > altium_to_kicad_footprint_property
Declares the struct as the Boost test fixture.
BOOST_AUTO_TEST_SUITE_END()