20#include <boost/test/unit_test.hpp>
47struct ALTIUM_SCH_IMPORT_FIXTURE
49 ALTIUM_SCH_IMPORT_FIXTURE() :
50 m_loadInfoScope( &NULL_REPORTER::GetInstance() ),
51 m_schematic( nullptr )
53 m_settingsManager.LoadProject(
"" );
54 m_schematic.SetProject( &m_settingsManager.Prj() );
58 ~ALTIUM_SCH_IMPORT_FIXTURE() { m_schematic.Reset(); }
60 wxString dataFile(
const wxString& aName )
const
63 +
"/plugins/altium/issue22943/" )
67 wxString issue24861DataFile(
const wxString& aName )
const
70 +
"/plugins/altium/issue24861/" )
74 wxString issue22908DataFile(
const wxString& aName )
const
77 +
"/plugins/altium/issue22908/" )
81 wxString ticket1303DataFile(
const wxString& aName )
const
84 +
"/plugins/altium/ticket1303/" )
88 wxString issue16903DataFile(
const wxString& aName )
const
91 +
"/plugins/altium/issue16903/" )
95 wxString eDPAdapterDataFile(
const wxString& aName )
const
98 +
"pcbnew/plugins/altium/eDP_adapter_dvt1_source/" )
103 LOAD_INFO_REPORTER_SCOPE m_loadInfoScope;
104 SETTINGS_MANAGER m_settingsManager;
111BOOST_FIXTURE_TEST_SUITE( AltiumSchImport, ALTIUM_SCH_IMPORT_FIXTURE )
127 wxArrayString libNames;
130 std::set<wxString> libSymbolNames( libNames.begin(), libNames.end() );
133 std::vector<SCH_SYMBOL*> fromMountingHoles;
140 fromMountingHoles.push_back( sym );
148 const LIB_ID& libId = sym->GetLibId();
149 BOOST_CHECK( libId.
IsValid() );
152 <<
"' does not resolve in mounting_holes.SchLib" );
162 std::map<std::string, UTF8> properties;
163 properties.emplace(
"project_file",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.PrjPcb" ) ) ) );
164 properties.emplace(
"sch0",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.SchDoc" ) ) ) );
165 properties.emplace(
"sch1",
UTF8( issue24861DataFile( wxT(
"Channel.SchDoc" ) ) ) );
170 const std::vector<SCH_SHEET*> topLevelSheets = m_schematic.GetTopLevelSheets();
171 BOOST_REQUIRE_EQUAL( topLevelSheets.size(), 1 );
172 BOOST_CHECK_EQUAL( topLevelSheets.front()->GetName(), wxT(
"Repeated_Schematic" ) );
174 std::optional<SCH_SHEET_PATH> topLevelPath;
175 std::map<wxString, SCH_SHEET_PATH> channelPaths;
181 if( sheet && sheet->
GetName() == wxT(
"Repeated_Schematic" ) )
182 topLevelPath = sheetPath;
183 else if( sheet && sheet->
GetName().StartsWith( wxT(
"CH" ) ) )
184 channelPaths.emplace( sheet->
GetName(), sheetPath );
190 BOOST_REQUIRE_EQUAL( channelPaths.size(), 3 );
191 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH1" ) ).GetPageNumber(), wxT(
"2" ) );
192 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH2" ) ).GetPageNumber(), wxT(
"3" ) );
193 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH3" ) ).GetPageNumber(), wxT(
"4" ) );
195 std::set<wxString> ledReferences;
196 std::set<wxString> resistorReferences;
198 for(
const auto& [channelName, sheetPath] : channelPaths )
203 wxString ref = symbol->
GetRef( &sheetPath );
205 if( ref.StartsWith( wxT(
"LED" ) ) )
206 ledReferences.insert( ref );
207 else if( ref.StartsWith( wxT(
"R" ) ) )
208 resistorReferences.insert( ref );
212 BOOST_CHECK( ledReferences == std::set<wxString>( { wxT(
"LED1_CH1" ), wxT(
"LED1_CH2" ),
213 wxT(
"LED1_CH3" ) } ) );
214 BOOST_CHECK( resistorReferences == std::set<wxString>( { wxT(
"R1_CH1" ), wxT(
"R1_CH2" ),
215 wxT(
"R1_CH3" ) } ) );
232 static const std::vector<VECTOR2I> crosses = {
233 { 360, 500 }, { 360, 540 }, { 360, 610 }, { 360, 600 }, { 360, 620 }, { 360, 530 }, { 360, 460 },
234 { 360, 450 }, { 170, 550 }, { 170, 540 }, { 170, 520 }, { 170, 510 }, { 170, 610 }, { 170, 590 },
235 { 170, 580 }, { 880, 500 }, { 880, 540 }, { 880, 610 }, { 880, 600 }, { 880, 620 }, { 880, 530 },
236 { 880, 460 }, { 880, 450 }, { 690, 550 }, { 690, 540 }, { 690, 520 }, { 690, 510 }, { 690, 610 },
237 { 690, 590 }, { 690, 580 }, { 480, 650 }, { 1000, 650 }, { 290, 340 }, { 810, 340 }
240 const int gridPitch = m_schematic.Settings().m_ConnectionGridSize;
242 const int flipY = ( pageHeight / gridPitch ) * gridPitch;
244 std::set<std::pair<int, int>>
expected;
246 for(
const VECTOR2I& cross : crosses )
249 std::set<std::pair<int, int>>
actual;
251 size_t actualCount = 0;
256 actual.emplace( item->GetPosition().x, item->GetPosition().y );
274 &m_schematic,
nullptr,
nullptr );
286 bool foundMergedScreen =
false;
292 if( !screen || screen == rootSheet->
GetScreen() )
295 std::optional<VECTOR2I> posA;
296 std::optional<VECTOR2I> posB;
302 if( label->
GetText() == wxT(
"ONLY_A" ) )
304 else if( label->
GetText() == wxT(
"ONLY_B" ) )
311 foundMergedScreen =
true;
315 int subSheetCount = 0;
327 BOOST_CHECK_MESSAGE( *posA != *posB,
"Merged pages must be tiled, not overlapping" );
331 bool foundSigLabel =
false;
335 if(
static_cast<SCH_HIERLABEL*
>( item )->GetText() == wxT(
"SIG" ) )
336 foundSigLabel =
true;
339 BOOST_CHECK_MESSAGE( foundSigLabel,
340 "Pruned sheet pin must survive as a hierarchical label" );
343 BOOST_CHECK_MESSAGE( foundMergedScreen,
344 "Both pages of the multi-file sheet symbol must load into one screen" );
365 m_schematic.RefreshHierarchy();
368 const std::map<wxString, SYMBOL_ORIENTATION_PROP>
expected = {
375 std::map<wxString, SYMBOL_ORIENTATION_PROP>
actual;
382 wxString ref = symbol->
GetRef( &sheetPath );
389 for(
const auto& [ref, angle] :
expected )
391 BOOST_REQUIRE_MESSAGE(
actual.count( ref ),
"Symbol '" << ref <<
"' not found on import" );
392 BOOST_CHECK_MESSAGE(
actual.at( ref ) == angle,
393 "Symbol '" << ref <<
"' imported with orientation " <<
actual.at( ref )
394 <<
", expected " << angle );
407 plugin.
LoadSchematicFile( issue16903DataFile( wxT(
"hierarchical_schematic_top.SchDoc" ) ),
411 m_schematic.RefreshHierarchy();
constexpr EDA_IU_SCALE schIUScale
virtual const wxString & GetText() const
Return the string associated with the text object.
EE_TYPE OfType(KICAD_T aType) const
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
int TestOffGridEndpoints()
Test pins and wire ends for being off grid.
virtual void SetReporter(REPORTER *aReporter)
Set an optional reporter for warnings/errors.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
static REPORTER & GetInstance()
int GetHeightIU(double aIUScale) const
Get the page height in IU.
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,...
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
Base class for any item which can be embedded within the SCHEMATIC container class,...
const PAGE_INFO & GetPageSettings() const
EE_RTREE & Items()
Get the full RTree, usually for iterating.
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
const LIB_ID & GetLibId() const override
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
VECTOR2I GetPosition() const override
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
std::string GetTestDataRootDir()
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_AUTO_TEST_CASE(Issue22943_SourceLibrarySymbolLibId)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I