mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Allow QA to create new SCHEMATIC instances rather than reusing a single container
Why make cleanup complicated lol
This commit is contained in:
parent
480c2f0277
commit
e610bc7ec5
@ -48,8 +48,6 @@ KI_TEST::SCHEMATIC_TEST_FIXTURE::SCHEMATIC_TEST_FIXTURE() :
|
||||
|
||||
KI_TEST::SCHEMATIC_TEST_FIXTURE::~SCHEMATIC_TEST_FIXTURE()
|
||||
{
|
||||
m_schematic.Reset();
|
||||
m_pi.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -63,39 +61,40 @@ void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic( const wxString& aBaseName )
|
||||
pro.SetExt( FILEEXT::ProjectFileExtension );
|
||||
|
||||
// Schematic must be reset before a project is reloaded
|
||||
m_schematic.Reset();
|
||||
m_schematic.release();
|
||||
|
||||
m_manager.LoadProject( pro.GetFullPath() );
|
||||
|
||||
m_manager.Prj().SetElem( PROJECT::ELEM::SCH_SYMBOL_LIBS, nullptr );
|
||||
|
||||
m_schematic.SetProject( &m_manager.Prj() );
|
||||
m_schematic.SetRoot( m_pi->LoadSchematicFile( fn.GetFullPath(), &m_schematic ) );
|
||||
m_schematic = std::make_unique<SCHEMATIC>( &m_manager.Prj() );
|
||||
m_schematic->SetRoot( m_pi->LoadSchematicFile( fn.GetFullPath(), m_schematic.get() ) );
|
||||
|
||||
BOOST_REQUIRE_EQUAL( m_pi->GetError().IsEmpty(), true );
|
||||
|
||||
m_schematic.CurrentSheet().push_back( &m_schematic.Root() );
|
||||
m_schematic->CurrentSheet().push_back( &m_schematic->Root() );
|
||||
|
||||
SCH_SCREENS screens( m_schematic.Root() );
|
||||
SCH_SCREENS screens( m_schematic->Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->UpdateLocalLibSymbolLinks();
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
// Restore all of the loaded symbol instances from the root sheet screen.
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221002 )
|
||||
sheets.UpdateSymbolInstanceData( m_schematic.RootScreen()->GetSymbolInstances());
|
||||
if( m_schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221002 )
|
||||
sheets.UpdateSymbolInstanceData( m_schematic->RootScreen()->GetSymbolInstances() );
|
||||
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221110 )
|
||||
sheets.UpdateSheetInstanceData( m_schematic.RootScreen()->GetSheetInstances());
|
||||
if( m_schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221110 )
|
||||
sheets.UpdateSheetInstanceData( m_schematic->RootScreen()->GetSheetInstances() );
|
||||
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
if( m_schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
|
||||
{
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
screen->MigrateSimModels();
|
||||
}
|
||||
|
||||
if( m_schematic.RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
|
||||
if( m_schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
|
||||
screens.FixLegacyPowerSymbolMismatches();
|
||||
|
||||
sheets.AnnotatePowerSymbols();
|
||||
@ -114,7 +113,7 @@ void KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic( const wxString& aBaseName )
|
||||
|
||||
SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, nullptr );
|
||||
|
||||
m_schematic.ConnectionGraph()->Recalculate( sheets, true );
|
||||
m_schematic->ConnectionGraph()->Recalculate( sheets, true );
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +132,7 @@ wxFileName KI_TEST::SCHEMATIC_TEST_FIXTURE::GetSchematicPath( const wxString& aB
|
||||
template <typename Exporter>
|
||||
wxString TEST_NETLIST_EXPORTER_FIXTURE<Exporter>::GetNetlistPath( bool aTest )
|
||||
{
|
||||
wxFileName netFile = m_schematic.Prj().GetProjectFullName();
|
||||
wxFileName netFile = m_schematic->Prj().GetProjectFullName();
|
||||
|
||||
if( aTest )
|
||||
netFile.SetName( netFile.GetName() + "_test" );
|
||||
@ -152,7 +151,7 @@ void TEST_NETLIST_EXPORTER_FIXTURE<Exporter>::WriteNetlist()
|
||||
wxRemoveFile( GetNetlistPath( true ) );
|
||||
|
||||
WX_STRING_REPORTER reporter;
|
||||
std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( &m_schematic );
|
||||
std::unique_ptr<Exporter> exporter = std::make_unique<Exporter>( m_schematic.get() );
|
||||
|
||||
bool success = exporter->WriteNetlist( GetNetlistPath( true ), GetNetlistOptions(), reporter );
|
||||
|
||||
@ -164,7 +163,7 @@ template <typename Exporter>
|
||||
void TEST_NETLIST_EXPORTER_FIXTURE<Exporter>::Cleanup()
|
||||
{
|
||||
wxRemoveFile( GetNetlistPath( true ) );
|
||||
m_schematic.Reset();
|
||||
m_schematic->Reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#ifndef QA_EESCHEMA_EESCHEMA_TEST_UTILS__H
|
||||
#define QA_EESCHEMA_EESCHEMA_TEST_UTILS__H
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <schematic.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <sch_io/sch_io_mgr.h>
|
||||
@ -57,7 +57,7 @@ protected:
|
||||
virtual void LoadSchematic( const wxString& aRelativePath );
|
||||
virtual wxFileName GetSchematicPath( const wxString& aBaseName );
|
||||
|
||||
SCHEMATIC m_schematic;
|
||||
std::unique_ptr<SCHEMATIC> m_schematic;
|
||||
IO_RELEASER<SCH_IO> m_pi;
|
||||
SETTINGS_MANAGER m_manager;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( TestSubsheetNetclass )
|
||||
{
|
||||
LoadSchematic( "issue14494" );
|
||||
|
||||
SCH_SHEET_PATH path = m_schematic.BuildSheetListSortedByPageNumbers().at( 1 );
|
||||
SCH_SHEET_PATH path = m_schematic->BuildSheetListSortedByPageNumbers().at( 1 );
|
||||
SCH_SCREEN* screen = path.GetSheet( 1 )->GetScreen();
|
||||
|
||||
for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) )
|
||||
@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE( TestMultiNetclasses )
|
||||
{
|
||||
LoadSchematic( "multinetclasses" );
|
||||
|
||||
std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic.Prj().GetProjectFile().m_NetSettings;
|
||||
std::shared_ptr<NET_SETTINGS>& netSettings = m_schematic->Prj().GetProjectFile().m_NetSettings;
|
||||
|
||||
std::shared_ptr<NETCLASS> nc = netSettings->GetEffectiveNetClass( "/BUS.SIGNAL" );
|
||||
BOOST_CHECK_EQUAL( nc->GetName(), "CLASS2,CLASS1,Default" );
|
||||
|
@ -81,7 +81,7 @@ SCH_SYMBOL* TEST_SCH_REFERENCE_LIST_FIXTURE::getSymbolByKIID( wxString aK
|
||||
SCH_SHEET_PATH* aSymbolPath )
|
||||
{
|
||||
KIID symKIID( aKIID );
|
||||
SCH_ITEM* foundItem = m_schematic.GetItem( symKIID, aSymbolPath );
|
||||
SCH_ITEM* foundItem = m_schematic->GetItem( symKIID, aSymbolPath );
|
||||
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( foundItem );
|
||||
|
||||
return symbol;
|
||||
@ -93,7 +93,7 @@ SCH_REFERENCE_LIST TEST_SCH_REFERENCE_LIST_FIXTURE::getAdditionalRefs()
|
||||
// Build List of additional references to pass into Annotate()
|
||||
SCH_REFERENCE_LIST allRefs, additionalRefs;
|
||||
|
||||
m_schematic.BuildSheetListSortedByPageNumbers().GetSymbols( allRefs );
|
||||
m_schematic->BuildSheetListSortedByPageNumbers().GetSymbols( allRefs );
|
||||
|
||||
for( size_t i = 0; i < allRefs.GetCount(); ++i )
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE( TestSheetListPageProperties )
|
||||
{
|
||||
LoadSchematic( "complex_hierarchy/complex_hierarchy" );
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
BOOST_CHECK( sheets.AllSheetPageNumbersEmpty() );
|
||||
|
||||
@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
|
||||
// Check the Sub Sheet has the expected page numbers
|
||||
LoadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
BOOST_CHECK_EQUAL( sheets.size(), 2 );
|
||||
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
|
||||
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
|
||||
// Check the parent sheet has the expected page numbers
|
||||
LoadSchematic( "complex_hierarchy_shared/complex_hierarchy" );
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
BOOST_CHECK_EQUAL( sheets.size(), 5 );
|
||||
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "1" );
|
||||
@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
|
||||
|
||||
BOOST_TEST_CONTEXT( "Modify page numbers in root sheet" )
|
||||
{
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
// Amend Page numbers
|
||||
sheets.at( 0 ).SetPageNumber( "A" );
|
||||
@ -116,21 +116,21 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
|
||||
newPrjFn.SetExt( FILEEXT::ProjectFileExtension );
|
||||
BOOST_CHECK( wxCopyFile( prjFn.GetFullPath(), newPrjFn.GetFullPath() ) );
|
||||
|
||||
m_pi->SaveSchematicFile( rootFn.GetFullPath(), &m_schematic.Root(), &m_schematic );
|
||||
m_pi->SaveSchematicFile( rootFn.GetFullPath(), &m_schematic->Root(), m_schematic.get() );
|
||||
|
||||
wxFileName subSheetFn = rootFn;
|
||||
BOOST_CHECK( subSheetFn.AppendDir( "ampli_ht" ) );
|
||||
BOOST_CHECK( subSheetFn.Mkdir() );
|
||||
|
||||
subSheetFn.SetName( "ampli_ht" );
|
||||
m_pi->SaveSchematicFile( subSheetFn.GetFullPath(), sheets.at( 1 ).Last(), &m_schematic );
|
||||
m_pi->SaveSchematicFile( subSheetFn.GetFullPath(), sheets.at( 1 ).Last(), m_schematic.get() );
|
||||
|
||||
subSheetFn.SetName( "filter" );
|
||||
m_pi->SaveSchematicFile( subSheetFn.GetFullPath(), sheets.at( 2 ).Last(), &m_schematic );
|
||||
m_pi->SaveSchematicFile( subSheetFn.GetFullPath(), sheets.at( 2 ).Last(), m_schematic.get() );
|
||||
|
||||
LoadSchematic( "complex_hierarchy_shared/temp/complex_hierarchy" );
|
||||
|
||||
sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
BOOST_CHECK_EQUAL( sheets.size(), 5 );
|
||||
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "A" );
|
||||
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
|
||||
// (This should not have been modified after editing the root sheet)
|
||||
LoadSchematic( "complex_hierarchy_shared/ampli_ht/ampli_ht" );
|
||||
|
||||
SCH_SHEET_LIST sheets = m_schematic.BuildSheetListSortedByPageNumbers();
|
||||
SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
|
||||
|
||||
BOOST_CHECK_EQUAL( sheets.size(), 2 );
|
||||
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
|
||||
|
@ -54,13 +54,13 @@ BOOST_AUTO_TEST_CASE( TestSchematicSharedByMultipleProjects )
|
||||
LoadSchematic( "schematic_object_tests/not_shared_by_multiple_projects/"
|
||||
"not_shared_by_multiple_projects" );
|
||||
|
||||
std::set<const SCH_SCREEN*> sharedScreens = m_schematic.GetSchematicsSharedByMultipleProjects();
|
||||
std::set<const SCH_SCREEN*> sharedScreens = m_schematic->GetSchematicsSharedByMultipleProjects();
|
||||
|
||||
BOOST_CHECK( sharedScreens.empty() );
|
||||
|
||||
LoadSchematic( "schematic_object_tests/shared_by_multiple_projects/project_a/project_a" );
|
||||
|
||||
sharedScreens = m_schematic.GetSchematicsSharedByMultipleProjects();
|
||||
sharedScreens = m_schematic->GetSchematicsSharedByMultipleProjects();
|
||||
|
||||
BOOST_CHECK( !sharedScreens.empty() );
|
||||
}
|
||||
@ -70,11 +70,11 @@ BOOST_AUTO_TEST_CASE( TestSchematicIsComplexHierarchy )
|
||||
{
|
||||
LoadSchematic( "netlists/group_bus_matching/group_bus_matching" );
|
||||
|
||||
BOOST_CHECK( !m_schematic.IsComplexHierarchy() );
|
||||
BOOST_CHECK( !m_schematic->IsComplexHierarchy() );
|
||||
|
||||
LoadSchematic( "netlists/complex_hierarchy/complex_hierarchy" );
|
||||
|
||||
BOOST_CHECK( m_schematic.IsComplexHierarchy() );
|
||||
BOOST_CHECK( m_schematic->IsComplexHierarchy() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
|
||||
wxString GetNetlistPath( bool aTest = false ) override
|
||||
{
|
||||
wxFileName netFile = m_schematic.Prj().GetProjectFullName();
|
||||
wxFileName netFile = m_schematic->Prj().GetProjectFullName();
|
||||
|
||||
if( aTest )
|
||||
netFile.SetName( netFile.GetName() + "_test" );
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
wxString GetNetlistPath( bool aTest = false ) override
|
||||
{
|
||||
wxFileName netFile = m_schematic.Prj().GetProjectFullName();
|
||||
wxFileName netFile = m_schematic->Prj().GetProjectFullName();
|
||||
|
||||
if( aTest )
|
||||
netFile.SetName( netFile.GetName() + "_test" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user