KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_bus_migration_precondition.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
34
36
37#include <connection_graph.h>
38#include <schematic.h>
39#include <sch_label.h>
40#include <sch_line.h>
41#include <sch_screen.h>
42#include <sch_sheet.h>
44
45
46BOOST_AUTO_TEST_SUITE( BusMigrationPrecondition )
47
48
50{
52 {
53 m_mgr.LoadProject( "" );
54 m_schematic = std::make_unique<SCHEMATIC>( &m_mgr.Prj() );
55 m_schematic->Reset();
56 SCH_SHEET* defaultSheet = m_schematic->GetTopLevelSheet( 0 );
57
58 m_screen = new SCH_SCREEN( m_schematic.get() );
59 m_sheet = new SCH_SHEET( m_schematic.get() );
60 m_sheet->SetScreen( m_screen );
61 m_schematic->AddTopLevelSheet( m_sheet );
62 m_schematic->RemoveTopLevelSheet( defaultSheet );
63 delete defaultSheet;
64 }
65
67 std::unique_ptr<SCHEMATIC> m_schematic;
70};
71
72
73BOOST_FIXTURE_TEST_CASE( MigrationDataOnlyExistsAfterRecalculate, BUS_MIGRATION_FIXTURE )
74{
75 // Two differently named vector bus labels on one bus wire is exactly the pre-6.0
76 // ambiguity the migrate-buses dialog resolves.
77 SCH_LINE* busWire = new SCH_LINE( VECTOR2I( 0, 0 ), LAYER_BUS );
78 busWire->SetEndPoint( VECTOR2I( 5000000, 0 ) );
79 m_screen->Append( busWire );
80
81 m_screen->Append( new SCH_LABEL( VECTOR2I( 0, 0 ), wxT( "DATA[0..3]" ) ) );
82 m_screen->Append( new SCH_LABEL( VECTOR2I( 5000000, 0 ), wxT( "ADDR[0..3]" ) ) );
83
84 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
85 CONNECTION_GRAPH* graph = m_schematic->ConnectionGraph();
86
87 graph->Recalculate( sheets, true );
88
89 // The load path evaluates the prompt here, once connectivity has been built.
91 "Conflicting bus must be reported once connectivity is built" );
92
93 // The load path calls Reset() before rebuilding connectivity. With the subgraphs
94 // cleared the migration list is empty regardless of schematic content, so a prompt
95 // evaluated in that window can never fire.
96 graph->Reset();
97
99 "A freshly-Reset() graph has no migration data" );
100}
101
102
Calculate the connectivity of a schematic and generates netlists.
std::vector< const CONNECTION_SUBGRAPH * > GetBusesNeedingMigration()
Determine which subgraphs have more than one conflicting bus label.
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.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:38
void SetEndPoint(const VECTOR2I &aPosition)
Definition sch_line.h:145
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:44
@ LAYER_BUS
Definition layer_ids.h:451
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_FIXTURE_TEST_CASE(MigrationDataOnlyExistsAfterRecalculate, BUS_MIGRATION_FIXTURE)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683