34#include <boost/test/unit_test.hpp>
39#include <wx/filename.h>
40#include <wx/stdpaths.h>
56 wxString tempDir = wxStandardPaths::Get().GetTempDir();
57 wxString projectPath =
58 tempDir + wxFileName::GetPathSeparator() + wxT(
"issue24403_project.kicad_pro" );
62 m_schematic = std::make_unique<SCHEMATIC>(
nullptr );
70 if( wxFileExists( file ) )
81 wxString tempDir = wxStandardPaths::Get().GetTempDir();
82 wxString baseName = wxFileName::CreateTempFileName(
83 tempDir + wxFileName::GetPathSeparator() + aPrefix );
86 wxString fileName = baseName + wxT(
".kicad_sch" );
92 const wxString& aNetClassName )
94 std::vector<SCH_SHEET*> topSheets =
m_schematic->GetTopLevelSheets();
97 SCH_SCREEN* screen = topSheets[0]->GetScreen();
102 label->
GetFields().back().SetText( aNetClassName );
124 m_schematic->CreateDefaultScreens();
128 AddDirectiveLabel( wxT(
"Netzklasse" ), wxT(
"HighSpeed" ) );
130 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
132 wxString outFile = MakeTempSchematicPath(
"issue24403_de" );
134 BOOST_REQUIRE_NO_THROW( io.
SaveSchematicFile( outFile, topSheets[0], m_schematic.get() ) );
136 wxFFile read( outFile,
"rb" );
138 BOOST_REQUIRE( read.IsOpened() && read.ReadAll( &contents ) );
141 "Saved schematic must contain canonical \"Netclass\" token" );
143 "Saved schematic must not contain translated \"Netzklasse\" token" );
145 "Saved schematic must preserve the net class value" );
156 m_schematic->CreateDefaultScreens();
160 wxString legacyFile = MakeTempSchematicPath(
"issue24403_legacy_de" );
163 wxFFile out( legacyFile,
"wb" );
166 const wxString body = wxT(
167 "(kicad_sch (version 20260512) (generator \"qa_test\") (generator_version \"9.99\")\n"
170 " (directive_label \"\" (length 2.54) (shape round)\n"
172 " (effects (font (size 1.27 1.27)) (justify left bottom))\n"
173 " (uuid \"00000000-0000-0000-0000-000000024403\")\n"
174 " (property \"Netzklasse\" \"HighSpeed\" (at 0 -1 0)\n"
175 " (effects (font (size 1.27 1.27)) (justify left bottom))\n"
178 " (sheet_instances (path \"/\" (page \"1\")))\n"
186 BOOST_REQUIRE_NO_THROW( loaded = io.
LoadSchematicFile( legacyFile, m_schematic.get() ) );
190 SCH_SHEET* defaultSheet = m_schematic->GetTopLevelSheet( 0 );
191 m_schematic->AddTopLevelSheet( loaded );
192 m_schematic->RemoveTopLevelSheet( defaultSheet );
198 int directiveCount = 0;
199 int netclassFieldCount = 0;
209 if( field.GetCanonicalName() == wxT(
"Netclass" ) )
211 netclassFieldCount++;
222 wxString resaved = MakeTempSchematicPath(
"issue24403_legacy_de_resave" );
223 std::vector<SCH_SHEET*> topSheets = m_schematic->GetTopLevelSheets();
226 BOOST_REQUIRE_NO_THROW( io.
SaveSchematicFile( resaved, topSheets[0], m_schematic.get() ) );
228 wxFFile resavedFile( resaved,
"rb" );
229 wxString resavedContents;
230 BOOST_REQUIRE( resavedFile.IsOpened() && resavedFile.ReadAll( &resavedContents ) );
233 "Re-saved schematic must use canonical \"Netclass\" token" );
235 "Re-saved schematic must drop the translated form" );
EE_TYPE OfType(KICAD_T aType) const
static bool IsNetclassLabelFieldName(const wxString &aName)
Test whether aName is one of the known translations of the directive-label net class field name (used...
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
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,...
std::vector< SCH_FIELD > & GetFields()
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
~DIRECTIVE_LABEL_I18N_FIXTURE()
std::unique_ptr< SCHEMATIC > m_schematic
std::vector< wxString > m_tempFiles
DIRECTIVE_LABEL_I18N_FIXTURE()
SETTINGS_MANAGER m_settingsManager
SCH_DIRECTIVE_LABEL * AddDirectiveLabel(const wxString &aFieldName, const wxString &aNetClassName)
wxString MakeTempSchematicPath(const wxString &aPrefix)
@ USER
The field ID hasn't been set yet; field is invalid.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CanonicalNetclassEmittedForTranslatedFieldName)
The serializer must always emit the canonical "Netclass" token for the directive-label net class fiel...
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I