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 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 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, see <https://www.gnu.org/licenses/>.
18 */
19
22
23#include <connection_graph.h>
24#include <schematic.h>
25#include <sch_screen.h>
27#include <locale_io.h>
28
30{
33
35 {
36 for( SCH_ITEM* item : m_schematic->RootScreen()->Items().OfType( SCH_SYMBOL_T ) )
37 {
38 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
39
40 // Fix pre-8.0 legacy power symbols with invisible pins
41 // that have mismatched pin names and value fields
42 if( symbol->GetLibSymbolRef()
43 && symbol->GetLibSymbolRef()->IsGlobalPower()
44 && symbol->GetAllLibPins().size() > 0
45 && symbol->GetAllLibPins()[0]->IsGlobalPower()
46 && !symbol->GetAllLibPins()[0]->IsVisible() )
47 {
49 symbol->GetAllLibPins()[0]->GetName() );
50 }
51 }
52 }
53
55 std::unique_ptr<SCHEMATIC> m_schematic;
56};
57
58
60{
61 KI_TEST::LoadSchematic( m_settingsManager, "netlists/legacy_power/legacy_power", m_schematic );
62
63 CheckSymbols();
64}
65
66
68{
69 KI_TEST::LoadSchematic( m_settingsManager, "netlists/legacy_power/legacy_power", m_schematic );
70
71 CheckSymbols();
72}
bool IsGlobalPower() const override
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:128
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Schematic symbol object.
Definition sch_symbol.h:69
std::vector< SCH_PIN * > GetAllLibPins() const
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:177
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_FIXTURE_TEST_CASE(LegacyPowerFixup, LEGACY_POWER_SYMBOLS_TEST_FIXTURE)
BOOST_CHECK_EQUAL(result, "25.4")
@ SCH_SYMBOL_T
Definition typeinfo.h:169