KiCad PCB EDA Suite
TEST_NETLIST_EXPORTER_FIXTURE< Exporter > Class Template Referenceabstract

#include <eeschema_test_utils.h>

Inheritance diagram for TEST_NETLIST_EXPORTER_FIXTURE< Exporter >:
KI_TEST::SCHEMATIC_TEST_FIXTURE

Public Member Functions

virtual wxString GetNetlistPath (bool aTest=false)
 
virtual unsigned GetNetlistOptions ()
 
void WriteNetlist ()
 
virtual void CompareNetlists ()=0
 
void Cleanup ()
 
void TestNetlist (const wxString &aBaseName)
 

Protected Member Functions

virtual void LoadSchematic (const wxString &aRelativePath)
 
virtual wxFileName GetSchematicPath (const wxString &aBaseName)
 

Protected Attributes

SCHEMATIC m_schematic
 

‍Schematic to load

More...
 
SCH_PLUGINm_pi
 
SETTINGS_MANAGER m_manager
 

Detailed Description

template<typename Exporter>
class TEST_NETLIST_EXPORTER_FIXTURE< Exporter >

Definition at line 93 of file eeschema_test_utils.h.

Member Function Documentation

◆ Cleanup()

template<typename Exporter >
void TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::Cleanup

Definition at line 152 of file eeschema_test_utils.cpp.

153{
154 wxRemoveFile( GetNetlistPath( true ) );
156}
SCHEMATIC m_schematic
‍Schematic to load
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
virtual wxString GetNetlistPath(bool aTest=false)

◆ CompareNetlists()

template<typename Exporter >
virtual void TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::CompareNetlists ( )
pure virtual

◆ GetNetlistOptions()

template<typename Exporter >
virtual unsigned TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::GetNetlistOptions ( )
inlinevirtual

Definition at line 97 of file eeschema_test_utils.h.

97{ return 0; }

◆ GetNetlistPath()

template<typename Exporter >
wxString TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::GetNetlistPath ( bool  aTest = false)
virtual

Definition at line 125 of file eeschema_test_utils.cpp.

126{
127 wxFileName netFile = m_schematic.Prj().GetProjectFullName();
128
129 if( aTest )
130 netFile.SetName( netFile.GetName() + "_test" );
131
132 netFile.SetExt( NetlistFileExtension );
133
134 return netFile.GetFullPath();
135}
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:119
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
const std::string NetlistFileExtension

References NetlistFileExtension.

◆ GetSchematicPath()

wxFileName KI_TEST::SCHEMATIC_TEST_FIXTURE::GetSchematicPath ( const wxString &  aBaseName)
protectedvirtualinherited

Reimplemented in TEST_SCH_SHEET_LIST_FIXTURE.

Definition at line 112 of file eeschema_test_utils.cpp.

113{
114 wxFileName fn = KI_TEST::GetEeschemaTestDataDir();
115 fn.AppendDir( "netlists" );
116 fn.AppendDir( aBaseName );
117 fn.SetName( aBaseName );
118 fn.SetExt( KiCadSchematicFileExtension );
119
120 return fn;
121}
const std::string KiCadSchematicFileExtension
wxFileName GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.

References KI_TEST::GetEeschemaTestDataDir(), and KiCadSchematicFileExtension.

Referenced by KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic().

◆ LoadSchematic()

void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic ( const wxString &  aRelativePath)
protectedvirtualinherited

Definition at line 65 of file eeschema_test_utils.cpp.

66{
67 wxFileName fn = GetSchematicPath( aBaseName );
68
69 BOOST_TEST_MESSAGE( fn.GetFullPath() );
70
71 wxFileName pro( fn );
72 pro.SetExt( ProjectFileExtension );
73
74 // Schematic must be reset before a project is reloaded
76 m_manager.LoadProject( pro.GetFullPath() );
77
79
81 m_schematic.SetRoot( m_pi->Load( fn.GetFullPath(), &m_schematic ) );
82
83 BOOST_REQUIRE_EQUAL( m_pi->GetError().IsEmpty(), true );
84
86
87 SCH_SCREENS screens( m_schematic.Root() );
88
89 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
90 screen->UpdateLocalLibSymbolLinks();
91
93
94 // Restore all of the loaded symbol instances from the root sheet screen.
97
98 sheets.AnnotatePowerSymbols();
99
100 // NOTE: This is required for multi-unit symbols to be correct
101 // Normally called from SCH_EDIT_FRAME::FixupJunctions() but could be refactored
102 for( SCH_SHEET_PATH& sheet : sheets )
103 sheet.UpdateAllScreenReferences();
104
105 // NOTE: SchematicCleanUp is not called; QA schematics must already be clean or else
106 // SchematicCleanUp must be freed from its UI dependencies.
107
108 m_schematic.ConnectionGraph()->Recalculate( sheets, true );
109}
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Updates the connection graph for the given list of sheets.
virtual wxFileName GetSchematicPath(const wxString &aBaseName)
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:293
@ ELEM_SCH_SYMBOL_LIBS
Definition: project.h:207
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:129
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:85
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:104
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:76
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
SCH_SHEET & Root() const
Definition: schematic.h:90
virtual SCH_SHEET * Load(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr)
Load information from some input file format that this SCH_PLUGIN implementation knows about,...
Definition: sch_plugin.cpp:51
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_plugin.cpp:177
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:613
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:488
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:493
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void UpdateSheetInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
const std::string ProjectFileExtension

References SCHEMATIC::CurrentSheet(), PROJECT::ELEM_SCH_SYMBOL_LIBS, SCH_PLUGIN::GetError(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), KI_TEST::SCHEMATIC_TEST_FIXTURE::GetSchematicPath(), SCHEMATIC::GetSheets(), SCH_SCREEN::GetSymbolInstances(), SCH_PLUGIN::Load(), SETTINGS_MANAGER::LoadProject(), KI_TEST::SCHEMATIC_TEST_FIXTURE::m_manager, KI_TEST::SCHEMATIC_TEST_FIXTURE::m_pi, KI_TEST::SCHEMATIC_TEST_FIXTURE::m_schematic, SETTINGS_MANAGER::Prj(), ProjectFileExtension, SCH_SHEET_PATH::push_back(), SCHEMATIC::Reset(), SCHEMATIC::Root(), SCHEMATIC::RootScreen(), PROJECT::SetElem(), SCHEMATIC::SetProject(), SCHEMATIC::SetRoot(), and SCH_SHEET_LIST::UpdateSymbolInstances().

Referenced by TEST_SCH_REFERENCE_LIST_FIXTURE::loadTestCase().

◆ TestNetlist()

template<typename Exporter >
void TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::TestNetlist ( const wxString &  aBaseName)

Definition at line 160 of file eeschema_test_utils.cpp.

161{
162 LoadSchematic( aBaseName );
163 WriteNetlist();
165 Cleanup();
166}
virtual void LoadSchematic(const wxString &aRelativePath)
virtual void CompareNetlists()=0

References KI_TEST::LoadSchematic().

◆ WriteNetlist()

template<typename Exporter >
void TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::WriteNetlist

Definition at line 139 of file eeschema_test_utils.cpp.

140{
141 // In case of a crash the file may not have been deleted.
142 if( wxFileExists( GetNetlistPath( true ) ) )
143 wxRemoveFile( GetNetlistPath( true ) );
144
145 auto exporter = std::make_unique<Exporter>( &m_schematic );
146 BOOST_REQUIRE_EQUAL( exporter->WriteNetlist( GetNetlistPath( true ), GetNetlistOptions() ),
147 true );
148}
virtual unsigned GetNetlistOptions()

Member Data Documentation

◆ m_manager

SETTINGS_MANAGER KI_TEST::SCHEMATIC_TEST_FIXTURE::m_manager
protectedinherited

◆ m_pi

SCH_PLUGIN* KI_TEST::SCHEMATIC_TEST_FIXTURE::m_pi
protectedinherited

◆ m_schematic


The documentation for this class was generated from the following files: