KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_altium_parser_sch.cpp File Reference

Test suite for #ALTIUM_PARSER_SCH. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <eeschema/sch_io/altium/altium_parser_sch.h>
#include <eeschema/sch_text.h>
#include <layer_ids.h>
#include <validators.h>
#include <wx/filename.h>

Go to the source code of this file.

Classes

struct  ALTIUM_PARSER_SCH_FIXTURE
 
struct  ALTIUM_TO_KICAD_UNIT_FRAC_CASE
 Declares the struct as the Boost test fixture. More...
 
struct  SHEET_NAME_SANITIZE_CASE
 
struct  TEXT_ORIENT_CASE
 

Functions

int ReadKiCadUnitFrac (const std::map< wxString, wxString > &aProps, const wxString &aKey)
 
void SetTextPositioning (EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification, ASCH_RECORD_ORIENTATION orientation)
 
void AdjustTextForSymbolOrientation (SCH_TEXT *aText, const ASCH_SYMBOL &aSymbol)
 
 BOOST_AUTO_TEST_CASE (PropertiesReadKiCadUnitFracConversation)
 Test conversation from Altium internal units into KiCad internal units using properties with FRAC.
 
 BOOST_AUTO_TEST_CASE (SheetNameSlashSanitization)
 Verify that the slash-to-underscore sanitization used by the Altium importer produces valid KiCad sheet names.
 
 BOOST_AUTO_TEST_CASE (SheetNameSlashRejection)
 Verify that unsanitized sheet names with slashes are rejected by KiCad validation.
 
 BOOST_AUTO_TEST_CASE (ExtensionlessFilenameDetection)
 Verify that wxFileName::HasExt() correctly distinguishes extensionless Altium filenames from those with extensions.
 
 BOOST_AUTO_TEST_CASE (ExtensionlessBaseNameMatching)
 Verify that case-insensitive base-name matching works for resolving extensionless Altium sheet symbol filenames to .SchDoc files on disk.
 
 BOOST_AUTO_TEST_CASE (SheetNameDerivationFromFilename)
 Verify that name derivation from filenames for top-level sheets produces correct deduplicated names, matching the logic in LoadSchematicProject.
 
static ASCH_SYMBOL MakeTestSymbol (int aOrientation, bool aMirrored)
 
static void SimulateRenderTransform (SCH_TEXT *aText, int aAltiumOrientation, bool aMirrored)
 
 BOOST_AUTO_TEST_CASE (TextOrientationCompensation)
 Verify that AdjustTextForSymbolOrientation correctly pre-compensates text properties so that after the render-time symbol transform, the final text orientation matches the absolute Altium orientation.
 

Variables

static const std::vector< ALTIUM_TO_KICAD_UNIT_FRAC_CASEaltium_to_kicad_unit_frac
 A list of valid internal unit conversation factors.
 
static const std::vector< SHEET_NAME_SANITIZE_CASEsheet_name_sanitize_cases
 
static const std::vector< TEXT_ORIENT_CASEtext_orient_cases
 

Detailed Description

Test suite for #ALTIUM_PARSER_SCH.

Definition in file test_altium_parser_sch.cpp.

Function Documentation

◆ AdjustTextForSymbolOrientation()

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( ExtensionlessBaseNameMatching )

Verify that case-insensitive base-name matching works for resolving extensionless Altium sheet symbol filenames to .SchDoc files on disk.

Definition at line 190 of file test_altium_parser_sch.cpp.

References empty().

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( ExtensionlessFilenameDetection )

Verify that wxFileName::HasExt() correctly distinguishes extensionless Altium filenames from those with extensions.

The Altium importer uses this to decide when to try appending .SchDoc during the hierarchy descent.

Definition at line 173 of file test_altium_parser_sch.cpp.

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( PropertiesReadKiCadUnitFracConversation )

Test conversation from Altium internal units into KiCad internal units using properties with FRAC.

Definition at line 97 of file test_altium_parser_sch.cpp.

References altium_to_kicad_unit_frac, BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), ReadKiCadUnitFrac(), and result.

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( SheetNameDerivationFromFilename )

Verify that name derivation from filenames for top-level sheets produces correct deduplicated names, matching the logic in LoadSchematicProject.

Definition at line 223 of file test_altium_parser_sch.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( SheetNameSlashRejection )

Verify that unsanitized sheet names with slashes are rejected by KiCad validation.

Definition at line 159 of file test_altium_parser_sch.cpp.

References GetFieldValidationErrorMessage(), and SHEET_NAME.

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( SheetNameSlashSanitization )

Verify that the slash-to-underscore sanitization used by the Altium importer produces valid KiCad sheet names.

Definition at line 136 of file test_altium_parser_sch.cpp.

References BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), GetFieldValidationErrorMessage(), SHEET_NAME, and sheet_name_sanitize_cases.

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( TextOrientationCompensation )

Verify that AdjustTextForSymbolOrientation correctly pre-compensates text properties so that after the render-time symbol transform, the final text orientation matches the absolute Altium orientation.

Definition at line 356 of file test_altium_parser_sch.cpp.

References AdjustTextForSymbolOrientation(), TEXT_ORIENT_CASE::altiumSymOrientation, BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), TEXT_ORIENT_CASE::expectedAngle, TEXT_ORIENT_CASE::expectedHJustify, TEXT_ORIENT_CASE::justification, LAYER_DEVICE, MakeTestSymbol(), TEXT_ORIENT_CASE::mirrored, SetTextPositioning(), SimulateRenderTransform(), text_orient_cases, and TEXT_ORIENT_CASE::textOrientation.

◆ MakeTestSymbol()

static ASCH_SYMBOL MakeTestSymbol ( int aOrientation,
bool aMirrored )
static

Definition at line 251 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ ReadKiCadUnitFrac()

◆ SetTextPositioning()

◆ SimulateRenderTransform()

static void SimulateRenderTransform ( SCH_TEXT * aText,
int aAltiumOrientation,
bool aMirrored )
static

Variable Documentation

◆ altium_to_kicad_unit_frac

const std::vector<ALTIUM_TO_KICAD_UNIT_FRAC_CASE> altium_to_kicad_unit_frac
static
Initial value:
= {
{ "0", "0", 0 },
{ "1", "0", 2540 },
{ "2", "0", 5080 },
{ "-1", "0", -2540 },
{ "-2", "0", -5080 },
{ "0", "1", 0 },
{ "0", "10", 0 },
{ "0", "100", 0 },
{ "0", "1000", 30 },
{ "0", "10000", 250 },
{ "1", "10000", 2790 },
{ "0", "-1", 0 },
{ "0", "-10", 0 },
{ "0", "-100", 0 },
{ "0", "-1000", -30 },
{ "0", "-10000", -250 },
{ "-1", "-10000", -2790 },
}

A list of valid internal unit conversation factors.

Definition at line 68 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ sheet_name_sanitize_cases

const std::vector<SHEET_NAME_SANITIZE_CASE> sheet_name_sanitize_cases
static
Initial value:
= {
{ wxT( "SimpleSheet" ), wxT( "SimpleSheet" ) },
{ wxT( "POWER PROTECTION/MONITORING" ), wxT( "POWER PROTECTION_MONITORING" ) },
{ wxT( "A/B/C" ), wxT( "A_B_C" ) },
{ wxT( "/" ), wxT( "_" ) },
{ wxT( "no_slash_here" ), wxT( "no_slash_here" ) },
{ wxT( "trailing/" ), wxT( "trailing_" ) },
{ wxT( "/leading" ), wxT( "_leading" ) },
}

Definition at line 122 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ text_orient_cases

const std::vector<TEXT_ORIENT_CASE> text_orient_cases
static

Definition at line 296 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().