32#include <wx/filename.h>
39 const wxString& aKey );
84 {
"0",
"10000", 250 },
85 {
"1",
"10000", 2790 },
89 {
"0",
"-1000", -30 },
90 {
"0",
"-10000", -250 },
91 {
"-1",
"-10000", -2790 },
106 wxString::Format( wxT(
"%s FRAC %s -> %i" ), c.input, c.input_frac, c.exp_result ) )
108 std::map<wxString, wxString> properties = { {
"TEST", c.input },
109 {
"TEST_FRAC", c.input_frac } };
127 { wxT(
"SimpleSheet" ), wxT(
"SimpleSheet" ) },
128 { wxT(
"POWER PROTECTION/MONITORING" ), wxT(
"POWER PROTECTION_MONITORING" ) },
129 { wxT(
"A/B/C" ), wxT(
"A_B_C" ) },
130 { wxT(
"/" ), wxT(
"_" ) },
131 { wxT(
"no_slash_here" ), wxT(
"no_slash_here" ) },
132 { wxT(
"trailing/" ), wxT(
"trailing_" ) },
133 { wxT(
"/leading" ), wxT(
"_leading" ) },
146 wxString sanitized = c.input;
147 sanitized.Replace( wxT(
"/" ), wxT(
"_" ) );
154 wxString::Format( wxT(
"Sanitized name '%s' failed validation: %s" ),
155 sanitized, validationError ) );
165 wxString invalidName = wxT(
"POWER PROTECTION/MONITORING" );
169 wxString::Format(
"Sheet name with '/' should fail validation" ) );
180 BOOST_CHECK( wxFileName( wxT(
"6_power.SchDoc" ) ).HasExt() );
181 BOOST_CHECK( wxFileName( wxT(
"my_sheet.SCHDOC" ) ).HasExt() );
184 BOOST_CHECK( !wxFileName( wxT(
"6_power" ) ).HasExt() );
185 BOOST_CHECK( !wxFileName( wxT(
"POWER MANAGEMENT" ) ).HasExt() );
186 BOOST_CHECK( !wxFileName( wxT(
"" ) ).HasExt() );
196 wxFileName sheetFn( wxT(
"6_power" ) );
197 bool extensionless = !sheetFn.HasExt();
199 BOOST_CHECK( extensionless );
201 wxFileName candidateA( wxT(
"6_power.SchDoc" ) );
202 wxFileName candidateB( wxT(
"6_POWER.SCHDOC" ) );
203 wxFileName candidateC( wxT(
"7_other.SchDoc" ) );
204 wxFileName candidateD( wxT(
"6_power.txt" ) );
207 auto matches = [&](
const wxFileName& candidate )
209 return candidate.GetFullName().IsSameAs( sheetFn.GetFullName(),
false )
211 && !sheetFn.GetName().
empty()
212 && candidate.GetName().IsSameAs( sheetFn.GetName(),
false )
213 && candidate.GetExt().IsSameAs( wxT(
"SchDoc" ),
false ) );
216 BOOST_CHECK( matches( candidateA ) );
217 BOOST_CHECK( matches( candidateB ) );
218 BOOST_CHECK( !matches( candidateC ) );
219 BOOST_CHECK( !matches( candidateD ) );
229 auto deriveName = [](
const wxString& aFilePath,
const std::set<wxString>& aExistingNames )
231 wxString baseName = wxFileName( aFilePath ).GetName();
232 baseName.Replace( wxT(
"/" ), wxT(
"_" ) );
234 wxString sheetName = baseName;
236 for(
int ii = 1; aExistingNames.count( sheetName ); ++ii )
237 sheetName = baseName + wxString::Format( wxT(
"_%d" ), ii );
242 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), {} ), wxT(
"6_power" ) );
246 std::set<wxString> existing = { wxT(
"6_power" ) };
247 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), existing ), wxT(
"6_power_1" ) );
250 existing.insert( wxT(
"6_power_1" ) );
251 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), existing ), wxT(
"6_power_2" ) );
257 std::map<wxString, wxString> props;
258 props[wxT(
"RECORD" )] = wxT(
"1" );
259 props[wxT(
"ORIENTATION" )] = wxString::Format( wxT(
"%d" ), aOrientation );
260 props[wxT(
"ISMIRRORED" )] = aMirrored ? wxT(
"T" ) : wxT(
"F" );
261 props[wxT(
"CURRENTPARTID" )] = wxT(
"1" );
262 props[wxT(
"PARTCOUNT" )] = wxT(
"2" );
263 props[wxT(
"DISPLAYMODECOUNT" )] = wxT(
"1" );
264 props[wxT(
"LOCATION.X" )] = wxT(
"0" );
265 props[wxT(
"LOCATION.Y" )] = wxT(
"0" );
274 int nRotations = ( aAltiumOrientation + 1 ) % 4;
276 for(
int i = 0; i < nRotations; i++ )
367 wxT(
"case %zu: textOri=%d justification=%d symOri=%d mirror=%d" ),
406 for(
const wxString&
name : { wxT(
"Net 1" ), wxT(
"A,B" ) } )
409 std::vector<wxString> members;
428 std::set<wxString> existing = { wxT(
"power" ) };
431 existing.insert( wxT(
"power_1" ) );
bool IsHorizontal() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual EDA_ANGLE GetTextAngle() const
GR_TEXT_V_ALIGN_T GetVertJustify() const
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
virtual void Rotate90(bool aClockwise)
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
ALTIUM_PARSER_SCH_FIXTURE()
Declares the struct as the Boost test fixture.
ASCH_RECORD_ORIENTATION textOrientation
ASCH_LABEL_JUSTIFICATION justification
GR_TEXT_H_ALIGN_T expectedHJustify
void AdjustTextForSymbolOrientation(SCH_TEXT *aText, const ASCH_SYMBOL &aSymbol)
static const std::vector< ALTIUM_TO_KICAD_UNIT_FRAC_CASE > altium_to_kicad_unit_frac
A list of valid internal unit conversation factors.
static const std::vector< TEXT_ORIENT_CASE > text_orient_cases
int ReadKiCadUnitFrac(const std::map< wxString, wxString > &aProps, const wxString &aKey)
static const std::vector< SHEET_NAME_SANITIZE_CASE > sheet_name_sanitize_cases
static ASCH_SYMBOL MakeTestSymbol(int aOrientation, bool aMirrored)
BOOST_AUTO_TEST_CASE(PropertiesReadKiCadUnitFracConversation)
Test conversation from Altium internal units into KiCad internal units using properties with FRAC.
wxString AltiumDeriveSheetName(const wxString &aFilename, const std::set< wxString > &aExistingNames)
static void SimulateRenderTransform(SCH_TEXT *aText, int aAltiumOrientation, bool aMirrored)
wxString AltiumWrapBusLabel(const wxString &aText)
void SetTextPositioning(EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_CONTEXT("Test Clearance")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
wxString GetFieldValidationErrorMessage(FIELD_T aFieldId, const wxString &aValue)
Return the error message if aValue is invalid for aFieldId.
Custom text control validator definitions.