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
21
#include <
qa_utils/wx_utils/unit_test_utils.h
>
22
#include <
schematic_utils/schematic_file_util.h
>
23
24
#include <
connection_graph.h
>
25
#include <
schematic.h
>
26
#include <
sch_screen.h
>
27
#include <
settings/settings_manager.h
>
28
#include <
locale_io.h
>
29
30
struct
LEGACY_POWER_SYMBOLS_TEST_FIXTURE
31
{
32
LEGACY_POWER_SYMBOLS_TEST_FIXTURE
() :
33
m_settingsManager
( true
/* headless */
)
34
{ }
35
36
void
CheckSymbols
()
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
56
SETTINGS_MANAGER
m_settingsManager
;
57
std::unique_ptr<SCHEMATIC>
m_schematic
;
58
};
59
60
61
BOOST_FIXTURE_TEST_CASE
( LegacyPowerFixup,
LEGACY_POWER_SYMBOLS_TEST_FIXTURE
)
62
{
63
KI_TEST::LoadSchematic
( m_settingsManager,
"netlists/legacy_power/legacy_power"
, m_schematic );
64
65
CheckSymbols();
66
}
67
68
69
BOOST_FIXTURE_TEST_CASE
( LegacyPower4Fixup,
LEGACY_POWER_SYMBOLS_TEST_FIXTURE
)
70
{
71
KI_TEST::LoadSchematic
( m_settingsManager,
"netlists/legacy_power/legacy_power"
, m_schematic );
72
73
CheckSymbols();
74
}
EDA_TEXT::GetText
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition:
eda_text.h:94
SCH_ITEM
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition:
sch_item.h:166
SCH_SYMBOL
Schematic symbol object.
Definition:
sch_symbol.h:104
SCH_SYMBOL::GetField
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition:
sch_symbol.cpp:939
SCH_SYMBOL::GetAllLibPins
std::vector< SCH_PIN * > GetAllLibPins() const
Definition:
sch_symbol.cpp:1276
SCH_SYMBOL::GetLibSymbolRef
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition:
sch_symbol.h:212
SETTINGS_MANAGER
Definition:
settings_manager.h:46
connection_graph.h
locale_io.h
KI_TEST::LoadSchematic
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
Definition:
schematic_file_util.cpp:119
sch_screen.h
schematic.h
schematic_file_util.h
settings_manager.h
LEGACY_POWER_SYMBOLS_TEST_FIXTURE
Definition:
test_legacy_power_symbols.cpp:31
LEGACY_POWER_SYMBOLS_TEST_FIXTURE::m_schematic
std::unique_ptr< SCHEMATIC > m_schematic
Definition:
test_legacy_power_symbols.cpp:57
LEGACY_POWER_SYMBOLS_TEST_FIXTURE::m_settingsManager
SETTINGS_MANAGER m_settingsManager
Definition:
test_legacy_power_symbols.cpp:56
LEGACY_POWER_SYMBOLS_TEST_FIXTURE::LEGACY_POWER_SYMBOLS_TEST_FIXTURE
LEGACY_POWER_SYMBOLS_TEST_FIXTURE()
Definition:
test_legacy_power_symbols.cpp:32
LEGACY_POWER_SYMBOLS_TEST_FIXTURE::CheckSymbols
void CheckSymbols()
Definition:
test_legacy_power_symbols.cpp:36
VALUE_FIELD
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
Definition:
template_fieldnames.h:43
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(LegacyPowerFixup, LEGACY_POWER_SYMBOLS_TEST_FIXTURE)
Definition:
test_legacy_power_symbols.cpp:61
SCH_SYMBOL_T
@ SCH_SYMBOL_T
Definition:
typeinfo.h:172
unit_test_utils.h
src
qa
tests
eeschema
test_legacy_power_symbols.cpp
Generated on Thu Nov 21 2024 00:06:50 for KiCad PCB EDA Suite by
1.9.6