35#include <boost/test/unit_test.hpp>
50#include <wx/filename.h>
51#include <wx/stdpaths.h>
58 wxString tempDir = wxStandardPaths::Get().GetTempDir();
59 wxString projectPath = tempDir + wxFileName::GetPathSeparator()
60 + wxT(
"test_issue24107.kicad_pro" );
64 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
74 if( wxFileExists( file ) )
84 std::shared_ptr<LIB_SYMBOL>
makeMultiUnitLib(
const wxString& aLibItemName,
int aUnitCount,
85 const wxString& aValue )
87 auto lib = std::make_shared<LIB_SYMBOL>( aLibItemName );
88 lib->SetUnitCount( aUnitCount,
false );
89 lib->GetReferenceField().SetText( wxT(
"U" ) );
90 lib->GetValueField().SetText( aValue );
94 id.SetLibItemName( aLibItemName );
145 auto ad8620Lib = makeMultiUnitLib( wxT(
"AD8620" ), 3, wxT(
"AD8620" ) );
146 auto opa1664Lib = makeMultiUnitLib( wxT(
"OPA1664" ), 4, wxT(
"OPA1664" ) );
148 placeUnit( ad8620Lib, 1,
VECTOR2I( 0, 0 ) );
149 placeUnit( ad8620Lib, 2,
VECTOR2I( 1000000, 0 ) );
150 placeUnit( ad8620Lib, 3,
VECTOR2I( 2000000, 0 ) );
158 BOOST_CHECK( missing.count( 1 ) == 0 );
159 BOOST_CHECK( missing.count( 2 ) == 1 );
160 BOOST_CHECK( missing.count( 3 ) == 1 );
161 BOOST_CHECK( missing.count( 4 ) == 1 );
172 auto ad8620Lib = makeMultiUnitLib( wxT(
"AD8620" ), 3, wxT(
"AD8620" ) );
173 auto opa1664Lib = makeMultiUnitLib( wxT(
"OPA1664" ), 4, wxT(
"OPA1664" ) );
177 placeUnit( ad8620Lib, 1,
VECTOR2I( 0, 1000000 ) );
178 placeUnit( ad8620Lib, 2,
VECTOR2I( 1000000, 1000000 ) );
183 BOOST_CHECK( missing.count( 1 ) == 0 );
184 BOOST_CHECK( missing.count( 2 ) == 1 );
185 BOOST_CHECK( missing.count( 3 ) == 1 );
186 BOOST_CHECK( missing.count( 4 ) == 1 );
197 auto ad8620Lib = makeMultiUnitLib( wxT(
"AD8620" ), 3, wxT(
"AD8620" ) );
198 auto opa1664Lib = makeMultiUnitLib( wxT(
"OPA1664" ), 4, wxT(
"OPA1664" ) );
201 placeUnit( ad8620Lib, 2,
VECTOR2I( 1000000, 0 ) );
202 placeUnit( opa1664Lib, 1,
VECTOR2I( 0, 1000000 ) );
208 BOOST_CHECK( missing.count( 3 ) == 1 );
220 auto ad8620Lib = makeMultiUnitLib( wxT(
"AD8620" ), 3, wxT(
"AD8620" ) );
221 auto opa1664Lib = makeMultiUnitLib( wxT(
"OPA1664" ), 4, wxT(
"OPA1664" ) );
223 placeUnit( ad8620Lib, 1,
VECTOR2I( 0, 0 ) );
224 placeUnit( ad8620Lib, 2,
VECTOR2I( 1000000, 0 ) );
225 placeUnit( ad8620Lib, 3,
VECTOR2I( 2000000, 0 ) );
231 const wxString unannotatedRef = wxT(
"U?" );
A logical library item identifier and consists of various portions much like a URI.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Container for project specific data.
virtual void SetUnit(int aUnit)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::shared_ptr< LIB_SYMBOL > makeMultiUnitLib(const wxString &aLibItemName, int aUnitCount, const wxString &aValue)
Build a fresh multi-unit library symbol with the given lib name, value and unit count.
SETTINGS_MANAGER m_settingsManager
std::vector< wxString > m_tempFiles
std::unique_ptr< SCHEMATIC > m_schematic
SCH_SYMBOL * placeUnit(const std::shared_ptr< LIB_SYMBOL > &aLib, int aUnit, const VECTOR2I &aPos)
Place a single unit of a multi-unit symbol in the schematic.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(UnplacedUnitsAreScopedToLibraryIdentity)
Reproduces the user-reported flow.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I