KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue26031_wire_over_pin.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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
28
29#include <boost/test/unit_test.hpp>
31
32#include <memory>
33
34#include <connection_graph.h>
36#include <sch_connection.h>
37#include <sch_pin.h>
38#include <sch_screen.h>
39#include <sch_sheet.h>
40#include <sch_sheet_path.h>
41#include <sch_symbol.h>
42#include <schematic.h>
44
45
46BOOST_AUTO_TEST_CASE( CadstarWireOverForeignPin )
47{
48 SETTINGS_MANAGER manager;
49 std::unique_ptr<SCHEMATIC> schematic( new SCHEMATIC( nullptr ) );
50
51 manager.LoadProject( "" );
52 schematic->SetProject( &manager.Prj() );
53 schematic->CurrentSheet().clear();
54 schematic->CurrentSheet().push_back( &schematic->Root() );
55
57 plugin.LoadSchematicFile( KI_TEST::GetEeschemaTestDataDir() + "io/cadstar/issue26031_wire_over_pin.csa",
58 schematic.get() );
59
60 SCH_SHEET_LIST sheets = schematic->BuildSheetListSortedByPageNumbers();
61 schematic->ConnectionGraph()->Recalculate( sheets, true );
62
63 const SCH_SHEET_PATH& path = sheets.front();
64 SCH_CONNECTION* pin1Conn = nullptr;
65 SCH_CONNECTION* pin2Conn = nullptr;
66
67 for( SCH_ITEM* item : path.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
68 {
69 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
70
71 if( symbol->GetRef( &path, false ) != wxS( "U1" ) )
72 continue;
73
74 for( SCH_PIN* pin : symbol->GetPins( &path ) )
75 {
76 if( pin->GetNumber() == wxS( "1" ) )
77 pin1Conn = pin->Connection( &path );
78 else if( pin->GetNumber() == wxS( "2" ) )
79 pin2Conn = pin->Connection( &path );
80 }
81 }
82
83 BOOST_REQUIRE( pin1Conn );
84 BOOST_REQUIRE( pin2Conn );
85
86 BOOST_CHECK_NE( pin1Conn->NetCode(), pin2Conn->NetCode() );
87}
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int NetCode() const
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:76
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_CASE(CadstarWireOverForeignPin)
std::string path
KIBIS_PIN * pin
@ SCH_SYMBOL_T
Definition typeinfo.h:168