20#include <boost/test/unit_test.hpp>
43struct ALTIUM_SCH_IMPORT_FIXTURE
45 ALTIUM_SCH_IMPORT_FIXTURE() : m_schematic( nullptr )
47 m_settingsManager.LoadProject(
"" );
48 m_schematic.SetProject( &m_settingsManager.Prj() );
52 ~ALTIUM_SCH_IMPORT_FIXTURE() { m_schematic.Reset(); }
54 wxString dataFile(
const wxString& aName )
const
57 +
"/plugins/altium/issue22943/" )
61 wxString issue24861DataFile(
const wxString& aName )
const
64 +
"/plugins/altium/issue24861/" )
68 wxString ticket1303DataFile(
const wxString& aName )
const
71 +
"/plugins/altium/ticket1303/" )
75 wxString eDPAdapterDataFile(
const wxString& aName )
const
78 +
"pcbnew/plugins/altium/eDP_adapter_dvt1_source/" )
82 SETTINGS_MANAGER m_settingsManager;
89BOOST_FIXTURE_TEST_SUITE( AltiumSchImport, ALTIUM_SCH_IMPORT_FIXTURE )
105 wxArrayString libNames;
108 std::set<wxString> libSymbolNames( libNames.begin(), libNames.end() );
111 std::vector<SCH_SYMBOL*> fromMountingHoles;
118 fromMountingHoles.push_back( sym );
126 const LIB_ID& libId = sym->GetLibId();
127 BOOST_CHECK( libId.
IsValid() );
130 <<
"' does not resolve in mounting_holes.SchLib" );
140 std::map<std::string, UTF8> properties;
141 properties.emplace(
"project_file",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.PrjPcb" ) ) ) );
142 properties.emplace(
"sch0",
UTF8( issue24861DataFile( wxT(
"Repeated_Schematic.SchDoc" ) ) ) );
143 properties.emplace(
"sch1",
UTF8( issue24861DataFile( wxT(
"Channel.SchDoc" ) ) ) );
148 const std::vector<SCH_SHEET*> topLevelSheets = m_schematic.GetTopLevelSheets();
149 BOOST_REQUIRE_EQUAL( topLevelSheets.size(), 1 );
150 BOOST_CHECK_EQUAL( topLevelSheets.front()->GetName(), wxT(
"Repeated_Schematic" ) );
152 std::optional<SCH_SHEET_PATH> topLevelPath;
153 std::map<wxString, SCH_SHEET_PATH> channelPaths;
159 if( sheet && sheet->
GetName() == wxT(
"Repeated_Schematic" ) )
160 topLevelPath = sheetPath;
161 else if( sheet && sheet->
GetName().StartsWith( wxT(
"CH" ) ) )
162 channelPaths.emplace( sheet->
GetName(), sheetPath );
168 BOOST_REQUIRE_EQUAL( channelPaths.size(), 3 );
169 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH1" ) ).GetPageNumber(), wxT(
"2" ) );
170 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH2" ) ).GetPageNumber(), wxT(
"3" ) );
171 BOOST_CHECK_EQUAL( channelPaths.at( wxT(
"CH3" ) ).GetPageNumber(), wxT(
"4" ) );
173 std::set<wxString> ledReferences;
174 std::set<wxString> resistorReferences;
176 for(
const auto& [channelName, sheetPath] : channelPaths )
181 wxString ref = symbol->
GetRef( &sheetPath );
183 if( ref.StartsWith( wxT(
"LED" ) ) )
184 ledReferences.insert( ref );
185 else if( ref.StartsWith( wxT(
"R" ) ) )
186 resistorReferences.insert( ref );
190 BOOST_CHECK( ledReferences == std::set<wxString>( { wxT(
"LED1_CH1" ), wxT(
"LED1_CH2" ),
191 wxT(
"LED1_CH3" ) } ) );
192 BOOST_CHECK( resistorReferences == std::set<wxString>( { wxT(
"R1_CH1" ), wxT(
"R1_CH2" ),
193 wxT(
"R1_CH3" ) } ) );
207 &m_schematic,
nullptr,
nullptr );
219 bool foundMergedScreen =
false;
225 if( !screen || screen == rootSheet->
GetScreen() )
228 std::optional<VECTOR2I> posA;
229 std::optional<VECTOR2I> posB;
235 if( label->
GetText() == wxT(
"ONLY_A" ) )
237 else if( label->
GetText() == wxT(
"ONLY_B" ) )
244 foundMergedScreen =
true;
248 int subSheetCount = 0;
260 BOOST_CHECK_MESSAGE( *posA != *posB,
"Merged pages must be tiled, not overlapping" );
264 bool foundSigLabel =
false;
268 if(
static_cast<SCH_HIERLABEL*
>( item )->GetText() == wxT(
"SIG" ) )
269 foundSigLabel =
true;
272 BOOST_CHECK_MESSAGE( foundSigLabel,
273 "Pruned sheet pin must survive as a hierarchical label" );
276 BOOST_CHECK_MESSAGE( foundMergedScreen,
277 "Both pages of the multi-file sheet symbol must load into one screen" );
295 m_schematic.RefreshHierarchy();
298 const std::map<wxString, SYMBOL_ORIENTATION_PROP>
expected = {
305 std::map<wxString, SYMBOL_ORIENTATION_PROP>
actual;
312 wxString ref = symbol->
GetRef( &sheetPath );
319 for(
const auto& [ref, angle] :
expected )
321 BOOST_REQUIRE_MESSAGE(
actual.count( ref ),
"Symbol '" << ref <<
"' not found on import" );
322 BOOST_CHECK_MESSAGE(
actual.at( ref ) == angle,
323 "Symbol '" << ref <<
"' imported with orientation " <<
actual.at( ref )
324 <<
", expected " << angle );
virtual const wxString & GetText() const
Return the string associated with the text object.
EE_TYPE OfType(KICAD_T aType) const
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
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")