mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Add test to determine if schematic is a complex hierarchy.
This test was added to the SCHEMATIC object along with QA tests to verify the test works as expected.
This commit is contained in:
parent
5305953de8
commit
b9f11971ad
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2023, 2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@ -940,3 +940,21 @@ std::set<const SCH_SCREEN*> SCHEMATIC::GetSchematicsSharedByMultipleProjects() c
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
||||
bool SCHEMATIC::IsComplexHierarchy() const
|
||||
{
|
||||
wxCHECK( m_rootSheet, false );
|
||||
|
||||
SCH_SCREENS screens( m_rootSheet );
|
||||
|
||||
for( const SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
wxCHECK2( screen, continue );
|
||||
|
||||
if( screen->GetRefCount() > 1 )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2023, 2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@ -322,6 +322,13 @@ public:
|
||||
*/
|
||||
std::set<const SCH_SCREEN*> GetSchematicsSharedByMultipleProjects() const;
|
||||
|
||||
/**
|
||||
* Test if the schematic is a complex hierarchy.
|
||||
*
|
||||
* @return true if the schematic is a complex hierarchy or false if it's a simple hierarchy.
|
||||
*/
|
||||
bool IsComplexHierarchy() const;
|
||||
|
||||
/**
|
||||
* True if a SCHEMATIC exists, false if not
|
||||
*/
|
||||
|
@ -38,7 +38,6 @@ protected:
|
||||
wxFileName TEST_SCHEMATIC_FIXTURE::GetSchematicPath( const wxString& aRelativePath )
|
||||
{
|
||||
wxFileName fn( KI_TEST::GetEeschemaTestDataDir() );
|
||||
fn.AppendDir( "schematic_object_tests" );
|
||||
|
||||
wxString path = fn.GetFullPath();
|
||||
path += aRelativePath + wxT( "." ) + FILEEXT::KiCadSchematicFileExtension;
|
||||
@ -50,24 +49,33 @@ wxFileName TEST_SCHEMATIC_FIXTURE::GetSchematicPath( const wxString& aRelativePa
|
||||
BOOST_FIXTURE_TEST_SUITE( Schematic, TEST_SCHEMATIC_FIXTURE )
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( TestSchematicNotSharedByMultipleProjects )
|
||||
BOOST_AUTO_TEST_CASE( TestSchematicSharedByMultipleProjects )
|
||||
{
|
||||
LoadSchematic( "not_shared_by_multiple_projects/not_shared_by_multiple_projects" );
|
||||
LoadSchematic( "schematic_object_tests/not_shared_by_multiple_projects/"
|
||||
"not_shared_by_multiple_projects" );
|
||||
|
||||
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" );
|
||||
|
||||
BOOST_AUTO_TEST_CASE( TestSchematicSharedByMultipleProjects )
|
||||
{
|
||||
LoadSchematic( "shared_by_multiple_projects/project_a/project_a" );
|
||||
|
||||
std::set<const SCH_SCREEN*> sharedScreens = m_schematic.GetSchematicsSharedByMultipleProjects();
|
||||
sharedScreens = m_schematic.GetSchematicsSharedByMultipleProjects();
|
||||
|
||||
BOOST_CHECK( !sharedScreens.empty() );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( TestSchematicIsComplexHierarchy )
|
||||
{
|
||||
LoadSchematic( "netlists/group_bus_matching/group_bus_matching" );
|
||||
|
||||
BOOST_CHECK( !m_schematic.IsComplexHierarchy() );
|
||||
|
||||
LoadSchematic( "netlists/complex_hierarchy/complex_hierarchy" );
|
||||
|
||||
BOOST_CHECK( m_schematic.IsComplexHierarchy() );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
x
Reference in New Issue
Block a user