KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_altium_pcb_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, 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
28
32
34
35#include <board.h>
37#include <netinfo.h>
38#include <netclass.h>
40
41
48
49
50BOOST_FIXTURE_TEST_SUITE( AltiumPcbImport, ALTIUM_PCB_IMPORT_FIXTURE )
51
52
53
57BOOST_AUTO_TEST_CASE( BoardLoadNoAssertions )
58{
59 std::string dataPath = KI_TEST::GetPcbnewTestDataDir()
60 + "plugins/altium/eDP_adapter_dvt1_source/eDP_adapter_dvt1.PcbDoc";
61
62 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
63
64 // Load the board - should not trigger any assertions
65 m_altiumPlugin.LoadBoard( dataPath, board.get(), nullptr );
66
67 BOOST_REQUIRE( board );
68
69 // Basic sanity checks
70 BOOST_CHECK( board->GetNetCount() > 0 );
71 BOOST_CHECK( board->Footprints().size() > 0 );
72}
73
74
82BOOST_AUTO_TEST_CASE( NetclassAssignment )
83{
84 // HiFive1.B01.PcbDoc has Altium netclass definitions
85 std::string dataPath = KI_TEST::GetPcbnewTestDataDir() + "plugins/altium/HiFive/HiFive1.B01.PcbDoc";
86
87 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
88
89 m_altiumPlugin.LoadBoard( dataPath, board.get(), nullptr );
90
91 BOOST_REQUIRE( board );
92
93 // Get the net settings which contains pattern assignments
94 std::shared_ptr<NET_SETTINGS> netSettings = board->GetDesignSettings().m_NetSettings;
95
96 BOOST_REQUIRE( netSettings );
97
98 // Check if there are any pattern assignments in the board
99 auto& patternAssignments = netSettings->GetNetclassPatternAssignments();
100
101 // The HiFive board should have netclass definitions - require this for the test to be meaningful
102 BOOST_REQUIRE_MESSAGE( patternAssignments.size() > 0,
103 "Test file must have netclass pattern assignments" );
104
105 // For each net that has a pattern assignment, verify that the NETINFO_ITEM
106 // has a netclass directly assigned (not just through pattern resolution)
107 bool foundAssignedNet = false;
108
109 for( NETINFO_ITEM* net : board->GetNetInfo() )
110 {
111 if( net->GetNetCode() <= 0 )
112 continue;
113
114 // Get the netclass directly from the NETINFO_ITEM
115 NETCLASS* directNetclass = net->GetNetClass();
116
117 // Get the effective netclass from pattern resolution
118 std::shared_ptr<NETCLASS> effectiveNetclass =
119 netSettings->GetEffectiveNetClass( net->GetNetname() );
120
121 // If this net has a non-default effective netclass, the direct assignment
122 // should also be non-default (this is what the fix ensures)
123 if( effectiveNetclass && effectiveNetclass->GetName() != NETCLASS::Default )
124 {
125 BOOST_CHECK_MESSAGE(
126 directNetclass != nullptr,
127 wxString::Format( "Net '%s' should have a direct netclass assignment",
128 net->GetNetname() ) );
129
130 if( directNetclass )
131 {
132 foundAssignedNet = true;
133
134 // The direct netclass should match what effective resolution returns
135 // (or be part of the effective class for multi-netclass scenarios)
136 BOOST_CHECK_MESSAGE(
137 directNetclass->GetName() != NETCLASS::Default,
138 wxString::Format( "Net '%s' should not have default netclass, "
139 "expected effective class or component",
140 net->GetNetname() ) );
141 }
142 }
143 }
144
145 // If there were pattern assignments, we should have found at least one assigned net
146 BOOST_CHECK_MESSAGE( foundAssignedNet,
147 "At least one net should have a non-default netclass assigned" );
148}
149
150
General utilities for PCB file IO for QA programs.
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:45
static const char Default[]
the name of the default NETCLASS
Definition netclass.h:47
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
Definition netclass.cpp:328
Handle the data for a net.
Definition netinfo.h:54
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
PCB_IO_ALTIUM_DESIGNER m_altiumPlugin
BOOST_AUTO_TEST_CASE(BoardLoadNoAssertions)
Test basic board loading - verifies that the Altium import doesn't trigger any assertions during the ...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()