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 <project/net_settings.h>
#include <validators.h>
#include <wx/filename.h>
#include <set>
#include <vector>

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)
 
wxString AltiumWrapBusLabel (const wxString &aText)
 
wxString AltiumDeriveSheetName (const wxString &aFilename, const std::set< wxString > &aExistingNames)
 
 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.
 
 BOOST_AUTO_TEST_CASE (BusLabelWrapping)
 Guard the exact transform SCH_IO_ALTIUM::PostProcessBusLabels() applies to a scalar net label found on a bus line (issue #20707).
 
 BOOST_AUTO_TEST_CASE (SheetNameDerivation)
 Guard the name derivation SCH_IO_ALTIUM::EnsureSheetSymbolNames() applies to sheet symbols that arrive without a SHEET_NAME record.
 

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()

◆ AltiumDeriveSheetName()

wxString AltiumDeriveSheetName ( const wxString & aFilename,
const std::set< wxString > & aExistingNames )

◆ AltiumWrapBusLabel()

wxString AltiumWrapBusLabel ( const wxString & aText)

◆ BOOST_AUTO_TEST_CASE() [1/9]

BOOST_AUTO_TEST_CASE ( BusLabelWrapping )

Guard the exact transform SCH_IO_ALTIUM::PostProcessBusLabels() applies to a scalar net label found on a bus line (issue #20707).

Plain labels must become single-member bus groups so KiCad connects them to the bus; anything already a bus label is left untouched.

Definition at line 393 of file test_altium_parser_sch.cpp.

References AltiumWrapBusLabel(), BOOST_CHECK_EQUAL(), name, and NET_SETTINGS::ParseBusGroup().

◆ BOOST_AUTO_TEST_CASE() [2/9]

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 194 of file test_altium_parser_sch.cpp.

References empty().

◆ BOOST_AUTO_TEST_CASE() [3/9]

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 177 of file test_altium_parser_sch.cpp.

◆ BOOST_AUTO_TEST_CASE() [4/9]

BOOST_AUTO_TEST_CASE ( PropertiesReadKiCadUnitFracConversation )

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

Definition at line 101 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() [5/9]

BOOST_AUTO_TEST_CASE ( SheetNameDerivation )

Guard the name derivation SCH_IO_ALTIUM::EnsureSheetSymbolNames() applies to sheet symbols that arrive without a SHEET_NAME record.

The name comes from the filename, with a numeric suffix to disambiguate collisions.

Definition at line 422 of file test_altium_parser_sch.cpp.

References AltiumDeriveSheetName(), and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [6/9]

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 227 of file test_altium_parser_sch.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [7/9]

BOOST_AUTO_TEST_CASE ( SheetNameSlashRejection )

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

Definition at line 163 of file test_altium_parser_sch.cpp.

References BOOST_CHECK_MESSAGE(), GetFieldValidationErrorMessage(), and SHEET_NAME.

◆ BOOST_AUTO_TEST_CASE() [8/9]

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 140 of file test_altium_parser_sch.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [9/9]

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 360 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 255 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 72 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 126 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 300 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().