35#include <wx/filename.h>
39 const wxString& aKey );
80 {
"0",
"10000", 250 },
81 {
"1",
"10000", 2790 },
85 {
"0",
"-1000", -30 },
86 {
"0",
"-10000", -250 },
87 {
"-1",
"-10000", -2790 },
102 wxString::Format( wxT(
"%s FRAC %s -> %i" ), c.input, c.input_frac, c.exp_result ) )
104 std::map<wxString, wxString> properties = { {
"TEST", c.input },
105 {
"TEST_FRAC", c.input_frac } };
123 { wxT(
"SimpleSheet" ), wxT(
"SimpleSheet" ) },
124 { wxT(
"POWER PROTECTION/MONITORING" ), wxT(
"POWER PROTECTION_MONITORING" ) },
125 { wxT(
"A/B/C" ), wxT(
"A_B_C" ) },
126 { wxT(
"/" ), wxT(
"_" ) },
127 { wxT(
"no_slash_here" ), wxT(
"no_slash_here" ) },
128 { wxT(
"trailing/" ), wxT(
"trailing_" ) },
129 { wxT(
"/leading" ), wxT(
"_leading" ) },
142 wxString sanitized = c.input;
143 sanitized.Replace( wxT(
"/" ), wxT(
"_" ) );
149 BOOST_CHECK_MESSAGE( validationError.empty(),
150 wxString::Format( wxT(
"Sanitized name '%s' failed validation: %s" ),
151 sanitized, validationError ) );
161 wxString invalidName = wxT(
"POWER PROTECTION/MONITORING" );
164 BOOST_CHECK_MESSAGE( !validationError.empty(),
165 wxT(
"Sheet name with '/' should fail validation" ) );
176 BOOST_CHECK( wxFileName( wxT(
"6_power.SchDoc" ) ).HasExt() );
177 BOOST_CHECK( wxFileName( wxT(
"my_sheet.SCHDOC" ) ).HasExt() );
180 BOOST_CHECK( !wxFileName( wxT(
"6_power" ) ).HasExt() );
181 BOOST_CHECK( !wxFileName( wxT(
"POWER MANAGEMENT" ) ).HasExt() );
182 BOOST_CHECK( !wxFileName( wxT(
"" ) ).HasExt() );
192 wxFileName sheetFn( wxT(
"6_power" ) );
193 bool extensionless = !sheetFn.HasExt();
195 BOOST_CHECK( extensionless );
197 wxFileName candidateA( wxT(
"6_power.SchDoc" ) );
198 wxFileName candidateB( wxT(
"6_POWER.SCHDOC" ) );
199 wxFileName candidateC( wxT(
"7_other.SchDoc" ) );
200 wxFileName candidateD( wxT(
"6_power.txt" ) );
203 auto matches = [&](
const wxFileName& candidate )
205 return candidate.GetFullName().IsSameAs( sheetFn.GetFullName(),
false )
207 && !sheetFn.GetName().
empty()
208 && candidate.GetName().IsSameAs( sheetFn.GetName(),
false )
209 && candidate.GetExt().IsSameAs( wxT(
"SchDoc" ),
false ) );
212 BOOST_CHECK( matches( candidateA ) );
213 BOOST_CHECK( matches( candidateB ) );
214 BOOST_CHECK( !matches( candidateC ) );
215 BOOST_CHECK( !matches( candidateD ) );
225 auto deriveName = [](
const wxString& aFilePath,
const std::set<wxString>& aExistingNames )
227 wxString baseName = wxFileName( aFilePath ).GetName();
228 baseName.Replace( wxT(
"/" ), wxT(
"_" ) );
230 wxString sheetName = baseName;
232 for(
int ii = 1; aExistingNames.count( sheetName ); ++ii )
233 sheetName = baseName + wxString::Format( wxT(
"_%d" ), ii );
238 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), {} ), wxT(
"6_power" ) );
242 std::set<wxString> existing = { wxT(
"6_power" ) };
243 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), existing ), wxT(
"6_power_1" ) );
246 existing.insert( wxT(
"6_power_1" ) );
247 BOOST_CHECK_EQUAL( deriveName( wxT(
"6_power.SchDoc" ), existing ), wxT(
"6_power_2" ) );
253 std::map<wxString, wxString> props;
254 props[wxT(
"RECORD" )] = wxT(
"1" );
255 props[wxT(
"ORIENTATION" )] = wxString::Format( wxT(
"%d" ), aOrientation );
256 props[wxT(
"ISMIRRORED" )] = aMirrored ? wxT(
"T" ) : wxT(
"F" );
257 props[wxT(
"CURRENTPARTID" )] = wxT(
"1" );
258 props[wxT(
"PARTCOUNT" )] = wxT(
"2" );
259 props[wxT(
"DISPLAYMODECOUNT" )] = wxT(
"1" );
260 props[wxT(
"LOCATION.X" )] = wxT(
"0" );
261 props[wxT(
"LOCATION.Y" )] = wxT(
"0" );
270 int nRotations = ( aAltiumOrientation + 1 ) % 4;
272 for(
int i = 0; i < nRotations; i++ )
363 wxT(
"case %zu: textOri=%d justification=%d symOri=%d mirror=%d" ),
bool IsHorizontal() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const EDA_ANGLE & GetTextAngle() const
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
GR_TEXT_V_ALIGN_T GetVertJustify() const
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.
static void SimulateRenderTransform(SCH_TEXT *aText, int aAltiumOrientation, bool aMirrored)
void SetTextPositioning(EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation)
BOOST_AUTO_TEST_SUITE_END()
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.