20#include <boost/test/unit_test.hpp>
46struct ALTIUM_SCH_IMPORT_FIXTURE
48 ALTIUM_SCH_IMPORT_FIXTURE() :
49 m_loadInfoScope( &NULL_REPORTER::GetInstance() ),
50 m_schematic( nullptr )
52 m_settingsManager.LoadProject(
"" );
53 m_schematic.SetProject( &m_settingsManager.Prj() );
57 ~ALTIUM_SCH_IMPORT_FIXTURE() { m_schematic.Reset(); }
59 wxString dataFile(
const wxString& aName )
const
62 +
"/plugins/altium/issue22943/" )
66 wxString issue24861DataFile(
const wxString& aName )
const
69 +
"/plugins/altium/issue24861/" )
73 wxString ticket1303DataFile(
const wxString& aName )
const
76 +
"/plugins/altium/ticket1303/" )
80 wxString issue16903DataFile(
const wxString& aName )
const
83 +
"/plugins/altium/issue16903/" )
87 wxString eDPAdapterDataFile(
const wxString& aName )
const
90 +
"pcbnew/plugins/altium/eDP_adapter_dvt1_source/" )
95 LOAD_INFO_REPORTER_SCOPE m_loadInfoScope;
96 SETTINGS_MANAGER m_settingsManager;
103BOOST_FIXTURE_TEST_SUITE( AltiumSchImport, ALTIUM_SCH_IMPORT_FIXTURE )
119 wxArrayString libNames;
122 std::set<wxString> libSymbolNames( libNames.begin(), libNames.end() );
125 std::vector<SCH_SYMBOL*> fromMountingHoles;
132 fromMountingHoles.push_back( sym );
140 const LIB_ID& libId = sym->GetLibId();
141 BOOST_CHECK( libId.
IsValid() );
144 <<
"' does not resolve in mounting_holes.SchLib" );
154 std::map<std::string, UTF8> properties;
155 properties.emplace(
"project_file",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.PrjPcb" ) ) ) );
156 properties.emplace(
"sch0",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.SchDoc" ) ) ) );
157 properties.emplace(
"sch1",
UTF8( issue24861DataFile( wxT(
"Channel.SchDoc" ) ) ) );
162 const std::vector<SCH_SHEET*> topLevelSheets = m_schematic.GetTopLevelSheets();
163 BOOST_REQUIRE_EQUAL( topLevelSheets.size(), 1 );
164 BOOST_CHECK_EQUAL( topLevelSheets.front()->GetName(), wxT(
"Repeated_Schematic" ) );
166 std::optional<SCH_SHEET_PATH> topLevelPath;
167 std::map<wxString, SCH_SHEET_PATH> channelPaths;
173 if( sheet && sheet->
GetName() == wxT(
"Repeated_Schematic" ) )
174 topLevelPath = sheetPath;
175 else if( sheet && sheet->
GetName().StartsWith( wxT(
"CH" ) ) )
176 channelPaths.emplace( sheet->
GetName(), sheetPath );
182 BOOST_REQUIRE_EQUAL( channelPaths.size(), 3 );
183 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH1" ) ).GetPageNumber(), wxT(
"2" ) );
184 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH2" ) ).GetPageNumber(), wxT(
"3" ) );
185 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH3" ) ).GetPageNumber(), wxT(
"4" ) );
187 std::set<wxString> ledReferences;
188 std::set<wxString> resistorReferences;
190 for(
const auto& [channelName, sheetPath] : channelPaths )
195 wxString ref = symbol->
GetRef( &sheetPath );
197 if( ref.StartsWith( wxT(
"LED" ) ) )
198 ledReferences.insert( ref );
199 else if( ref.StartsWith( wxT(
"R" ) ) )
200 resistorReferences.insert( ref );
204 BOOST_CHECK( ledReferences == std::set<wxString>( { wxT(
"LED1_CH1" ), wxT(
"LED1_CH2" ),
205 wxT(
"LED1_CH3" ) } ) );
206 BOOST_CHECK( resistorReferences == std::set<wxString>( { wxT(
"R1_CH1" ), wxT(
"R1_CH2" ),
207 wxT(
"R1_CH3" ) } ) );
221 &m_schematic,
nullptr,
nullptr );
233 bool foundMergedScreen =
false;
239 if( !screen || screen == rootSheet->
GetScreen() )
242 std::optional<VECTOR2I> posA;
243 std::optional<VECTOR2I> posB;
249 if( label->
GetText() == wxT(
"ONLY_A" ) )
251 else if( label->
GetText() == wxT(
"ONLY_B" ) )
258 foundMergedScreen =
true;
262 int subSheetCount = 0;
274 BOOST_CHECK_MESSAGE( *posA != *posB,
"Merged pages must be tiled, not overlapping" );
278 bool foundSigLabel =
false;
282 if(
static_cast<SCH_HIERLABEL*
>( item )->GetText() == wxT(
"SIG" ) )
283 foundSigLabel =
true;
286 BOOST_CHECK_MESSAGE( foundSigLabel,
287 "Pruned sheet pin must survive as a hierarchical label" );
290 BOOST_CHECK_MESSAGE( foundMergedScreen,
291 "Both pages of the multi-file sheet symbol must load into one screen" );
312 m_schematic.RefreshHierarchy();
315 const std::map<wxString, SYMBOL_ORIENTATION_PROP>
expected = {
322 std::map<wxString, SYMBOL_ORIENTATION_PROP>
actual;
329 wxString ref = symbol->
GetRef( &sheetPath );
336 for(
const auto& [ref, angle] :
expected )
338 BOOST_REQUIRE_MESSAGE(
actual.count( ref ),
"Symbol '" << ref <<
"' not found on import" );
339 BOOST_CHECK_MESSAGE(
actual.at( ref ) == angle,
340 "Symbol '" << ref <<
"' imported with orientation " <<
actual.at( ref )
341 <<
", expected " << angle );
354 plugin.
LoadSchematicFile( issue16903DataFile( wxT(
"hierarchical_schematic_top.SchDoc" ) ),
358 m_schematic.RefreshHierarchy();
virtual const wxString & GetText() const
Return the string associated with the text object.
EE_TYPE OfType(KICAD_T aType) const
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()
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,...
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")