KiCad PCB EDA Suite
KI_TEST::SCHEMATIC_TEST_FIXTURE Class Reference

A generic fixture for loading schematics and associated settings for qa tests. More...

#include <eeschema_test_utils.h>

Inheritance diagram for KI_TEST::SCHEMATIC_TEST_FIXTURE:
TEST_NETLIST_EXPORTER_FIXTURE< NETLIST_EXPORTER_KICAD > TEST_NETLIST_EXPORTER_FIXTURE< Exporter > TEST_SCH_REFERENCE_LIST_FIXTURE TEST_SCH_SHEET_LIST_FIXTURE TEST_NETLIST_EXPORTER_KICAD_FIXTURE

Public Member Functions

 SCHEMATIC_TEST_FIXTURE ()
 
virtual ~SCHEMATIC_TEST_FIXTURE ()
 

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

A generic fixture for loading schematics and associated settings for qa tests.

Definition at line 60 of file eeschema_test_utils.h.

Constructor & Destructor Documentation

◆ SCHEMATIC_TEST_FIXTURE()

KI_TEST::SCHEMATIC_TEST_FIXTURE::SCHEMATIC_TEST_FIXTURE ( )
inline

Definition at line 63 of file eeschema_test_utils.h.

64 : m_schematic( nullptr ),
65 m_pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) ),
66 m_manager( true )
67 {
68 }
SCHEMATIC m_schematic
‍Schematic to load

◆ ~SCHEMATIC_TEST_FIXTURE()

virtual KI_TEST::SCHEMATIC_TEST_FIXTURE::~SCHEMATIC_TEST_FIXTURE ( )
inlinevirtual

Definition at line 70 of file eeschema_test_utils.h.

71 {
74 }
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
static void ReleasePlugin(SCH_PLUGIN *aPlugin)
Release a SCH_PLUGIN back to the system, and may cause it to be unloaded from memory.
Definition: sch_io_mgr.cpp:71

References m_pi, m_schematic, SCH_IO_MGR::ReleasePlugin(), and SCHEMATIC::Reset().

Member Function Documentation

◆ GetSchematicPath()

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

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 LoadSchematic().

◆ LoadSchematic()

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

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(), GetSchematicPath(), SCHEMATIC::GetSheets(), SCH_SCREEN::GetSymbolInstances(), SCH_PLUGIN::Load(), SETTINGS_MANAGER::LoadProject(), m_manager, m_pi, 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().

Member Data Documentation

◆ m_manager

SETTINGS_MANAGER KI_TEST::SCHEMATIC_TEST_FIXTURE::m_manager
protected

Definition at line 85 of file eeschema_test_utils.h.

Referenced by LoadSchematic().

◆ m_pi

SCH_PLUGIN* KI_TEST::SCHEMATIC_TEST_FIXTURE::m_pi
protected

Definition at line 83 of file eeschema_test_utils.h.

Referenced by LoadSchematic(), and ~SCHEMATIC_TEST_FIXTURE().

◆ m_schematic

SCHEMATIC KI_TEST::SCHEMATIC_TEST_FIXTURE::m_schematic
protected

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