KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_net_chains_remove.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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
24
25#include <connection_graph.h>
27#include <schematic.h>
28#include <sch_netchain.h>
29#include <sch_screen.h>
30#include <sch_sheet.h>
31#include <sch_symbol.h>
33#include <locale_io.h>
34
42
43BOOST_FIXTURE_TEST_CASE( RemoveFromSignal_DisablesPropagationAndSplitsGroup, SIGNALS_REMOVE_TEST_FIXTURE )
44{
46 KI_TEST::LoadSchematic( m_settingsManager, wxString( "net_chains_four_nets" ), m_schematic );
47
48 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
49 CONNECTION_GRAPH* graph = m_schematic->ConnectionGraph();
50 graph->Recalculate( sheets, /*aUnconditional=*/true );
51
52 auto& manager = m_schematic->NetChains();
53 SCH_NETCHAIN* four = nullptr;
54
55 for( const auto& sig : manager.GetPotentialNetChains() )
56 {
57 if( sig && sig->GetNets().size() == 4 )
58 four = sig.get();
59 }
60
61 BOOST_REQUIRE_MESSAGE( four, "Expected initial 4-net signal present" );
62
63 SCH_NETCHAIN* chain = manager.CreateNetChainFromPotential( four, wxS( "REMOVE" ) );
65
66 const wxString net = *chain->GetNets().begin();
67 const auto bridges = manager.GetBridgeSymbols( *chain, net );
68
69 BOOST_REQUIRE_MESSAGE( !bridges.empty(), "No bridging symbol reported for a chain member" );
70 BOOST_CHECK( manager.GetBridgeSymbols( *chain, wxS( "NOT_A_MEMBER" ) ).empty() );
71
72 for( const auto& [symbol, screen] : bridges )
73 {
74 BOOST_CHECK( screen == m_schematic->CurrentSheet().LastScreen() );
75 BOOST_CHECK( chain->GetSymbols().contains( symbol ) );
76 symbol->SetPassthroughMode( SCH_SYMBOL::PASSTHROUGH_MODE::BLOCK );
77 }
78
79 graph->Recalculate( sheets, /*aUnconditional=*/true );
80
81 for( const auto& sig : manager.GetPotentialNetChains() )
82 {
83 BOOST_CHECK_MESSAGE( sig->GetNets().size() < 4, "Expected removal to split the 4-net signal" );
84 BOOST_CHECK_MESSAGE( !sig->GetNets().contains( net ), "Removed net still bridged into a chain" );
85 }
86}
87
88// EOF
Calculate the connectivity of a schematic and generate netlists.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Update the connection graph for the given list of sheets.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
A net chain is a collection of nets that are connected together through passive components.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
static bool empty(const wxTextEntryBase *aCtrl)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(RemoveFromSignal_DisablesPropagationAndSplitsGroup, SIGNALS_REMOVE_TEST_FIXTURE)
const SHAPE_LINE_CHAIN chain