KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_legacy_power_symbols.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) 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 3
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 at
18 * http://www.gnu.org/licenses/
19 */
20
23
24#include <connection_graph.h>
25#include <schematic.h>
26#include <sch_screen.h>
28#include <locale_io.h>
29
31{
33 m_settingsManager( true /* headless */ )
34 { }
35
37 {
38 for( SCH_ITEM* item : m_schematic->RootScreen()->Items().OfType( SCH_SYMBOL_T ) )
39 {
40 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
41
42 // Fix pre-8.0 legacy power symbols with invisible pins
43 // that have mismatched pin names and value fields
44 if( symbol->GetLibSymbolRef()
45 && symbol->GetLibSymbolRef()->IsPower()
46 && symbol->GetAllLibPins().size() > 0
47 && symbol->GetAllLibPins()[0]->IsGlobalPower()
48 && !symbol->GetAllLibPins()[0]->IsVisible() )
49 {
50 BOOST_CHECK_EQUAL( symbol->GetField( VALUE_FIELD )->GetText(),
51 symbol->GetAllLibPins()[0]->GetName() );
52 }
53 }
54 }
55
57 std::unique_ptr<SCHEMATIC> m_schematic;
58};
59
60
62{
63 KI_TEST::LoadSchematic( m_settingsManager, "netlists/legacy_power/legacy_power", m_schematic );
64
65 CheckSymbols();
66}
67
68
70{
71 KI_TEST::LoadSchematic( m_settingsManager, "netlists/legacy_power/legacy_power", m_schematic );
72
73 CheckSymbols();
74}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
Schematic symbol object.
Definition: sch_symbol.h:104
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:939
std::vector< SCH_PIN * > GetAllLibPins() const
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:212
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::unique_ptr< SCHEMATIC > m_schematic
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
BOOST_FIXTURE_TEST_CASE(LegacyPowerFixup, LEGACY_POWER_SYMBOLS_TEST_FIXTURE)
@ SCH_SYMBOL_T
Definition: typeinfo.h:172