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

Test suite for SCH_SYMBOL object. More...

Go to the source code of this file.

Classes

class  TEST_SCH_SYMBOL_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (DefaultProperties)
 Declare the test suite.
 
 BOOST_AUTO_TEST_CASE (Orientation)
 Test the orientation transform changes.
 
 BOOST_AUTO_TEST_CASE (SchSymbolVariantTest)
 Test symbol variant handling.
 
 BOOST_AUTO_TEST_CASE (FieldAdditionByName)
 Test field addition and retrieval by name.
 
 BOOST_AUTO_TEST_CASE (VariantDescription)
 Test variant description methods.
 
 BOOST_AUTO_TEST_CASE (TextVariableVARIANT)
 Test ${VARIANT} text variable resolution.
 
 BOOST_AUTO_TEST_CASE (TextVariableVARIANT_DESC)
 Test ${VARIANT_DESC} text variable resolution.
 
 BOOST_AUTO_TEST_CASE (RenameVariantPreservesData)
 Test RenameVariant preserves data.
 
 BOOST_AUTO_TEST_CASE (CopyVariantCreatesIndependentCopy)
 Test CopyVariant creates an independent copy.
 
 BOOST_AUTO_TEST_CASE (VariantFieldDifferenceDetection)
 Test variant field value difference detection.
 
 BOOST_AUTO_TEST_CASE (VariantDNPFiltering)
 Test variant DNP filtering for BOM.
 
 BOOST_AUTO_TEST_CASE (GetVariantNamesForUI)
 Test GetVariantNamesForUI returns properly formatted array.
 
 BOOST_AUTO_TEST_CASE (SetValueFieldTextPersistsVariantValue)
 Test that SetValueFieldText correctly persists variant field values.
 
 BOOST_AUTO_TEST_CASE (SetFieldTextAndSetValueFieldTextConsistency)
 Test that SetFieldText works consistently with SetValueFieldText for the VALUE field.
 
 BOOST_AUTO_TEST_CASE (VariantNameHandling)
 Test variant name handling in eeschema.
 
 BOOST_AUTO_TEST_CASE (VariantDeletionCascade)
 Test variant deletion clears symbol variant data.
 
 BOOST_AUTO_TEST_CASE (VariantFieldUnicodeAndSpecialChars)
 Test variant field values with unicode and special characters.
 
 BOOST_AUTO_TEST_CASE (VariantSpecificFieldDereferencing)
 Test variant-specific field dereferencing via ${REF:FIELD:VARIANT} syntax.
 
 BOOST_AUTO_TEST_CASE (FootprintFieldVariantSupport)
 Test footprint field variant support.
 
 BOOST_AUTO_TEST_CASE (FootprintFieldVariantNoOpWhenSame)
 Test that setting footprint to same value as base when variant is active does not create an unnecessary override entry.
 
 BOOST_AUTO_TEST_CASE (VariantSwitchInvalidatesBoundingBoxCache)
 Test that switching variants invalidates field bounding box caches so that field geometry reflects the new variant's text.
 
 BOOST_AUTO_TEST_CASE (VariantAttributeInitFromSymbol)
 Verify that variant attributes are initialized from the symbol defaults, not all-false.
 

Detailed Description

Test suite for SCH_SYMBOL object.

Definition in file test_sch_symbol.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/22]

◆ BOOST_AUTO_TEST_CASE() [2/22]

BOOST_AUTO_TEST_CASE ( DefaultProperties )

Declare the test suite.

Check that we can get the default properties as expected.

Definition at line 76 of file test_sch_symbol.cpp.

References BOOST_AUTO_TEST_CASE().

◆ BOOST_AUTO_TEST_CASE() [3/22]

BOOST_AUTO_TEST_CASE ( FieldAdditionByName )

Test field addition and retrieval by name.

Verifies that GetField(wxString) returns null for non-existent fields and that AddField properly creates new fields (fix for issue #22628).

Definition at line 160 of file test_sch_symbol.cpp.

References SCH_SYMBOL::AddField(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), EDA_ITEM::GetParent(), SCH_FIELD::GetText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), EDA_ITEM::SetParent(), SCH_FIELD::SetText(), and USER.

◆ BOOST_AUTO_TEST_CASE() [4/22]

BOOST_AUTO_TEST_CASE ( FootprintFieldVariantNoOpWhenSame )

Test that setting footprint to same value as base when variant is active does not create an unnecessary override entry.

Definition at line 939 of file test_sch_symbol.cpp.

References BOOST_REQUIRE(), FOOTPRINT, KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetName(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetFieldText(), and SCH_SYMBOL::SetFootprintFieldText().

◆ BOOST_AUTO_TEST_CASE() [5/22]

BOOST_AUTO_TEST_CASE ( FootprintFieldVariantSupport )

Test footprint field variant support.

Verifies that editing the footprint field when a variant is active creates a variant-specific override instead of modifying the base footprint value.

Definition at line 886 of file test_sch_symbol.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), FOOTPRINT, KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetFieldText(), SCH_SYMBOL::GetFootprintFieldText(), SCH_FIELD::GetName(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetFieldText(), and SCH_SYMBOL::SetFootprintFieldText().

◆ BOOST_AUTO_TEST_CASE() [6/22]

BOOST_AUTO_TEST_CASE ( GetVariantNamesForUI )

Test GetVariantNamesForUI returns properly formatted array.

Definition at line 538 of file test_sch_symbol.cpp.

References BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().

◆ BOOST_AUTO_TEST_CASE() [7/22]

BOOST_AUTO_TEST_CASE ( Orientation )

Test the orientation transform changes.

Definition at line 84 of file test_sch_symbol.cpp.

References SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.

◆ BOOST_AUTO_TEST_CASE() [8/22]

◆ BOOST_AUTO_TEST_CASE() [9/22]

◆ BOOST_AUTO_TEST_CASE() [10/22]

BOOST_AUTO_TEST_CASE ( SetFieldTextAndSetValueFieldTextConsistency )

◆ BOOST_AUTO_TEST_CASE() [11/22]

BOOST_AUTO_TEST_CASE ( SetValueFieldTextPersistsVariantValue )

Test that SetValueFieldText correctly persists variant field values.

This tests the fix for a bug where variant values were not saved because GetVariant returned a copy instead of modifying the instance directly.

Definition at line 590 of file test_sch_symbol.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetName(), SCH_FIELD::GetText(), SCH_SYMBOL::GetValue(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetValueFieldText(), and VALUE.

◆ BOOST_AUTO_TEST_CASE() [12/22]

BOOST_AUTO_TEST_CASE ( TextVariableVARIANT )

◆ BOOST_AUTO_TEST_CASE() [13/22]

BOOST_AUTO_TEST_CASE ( TextVariableVARIANT_DESC )

Test ${VARIANT_DESC} text variable resolution.

Definition at line 276 of file test_sch_symbol.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().

◆ BOOST_AUTO_TEST_CASE() [14/22]

BOOST_AUTO_TEST_CASE ( VariantAttributeInitFromSymbol )

Verify that variant attributes are initialized from the symbol defaults, not all-false.

When a variant's attributes match the symbol's default, the serializer omits them. On reload the parser must initialize those attributes from the symbol's defaults rather than from the VARIANT constructor defaults (all false).

This test verifies InitializeAttributes correctly copies from the symbol. Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23347

Definition at line 1059 of file test_sch_symbol.cpp.

References BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL_VARIANT::InitializeAttributes(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), VARIANT::m_DNP, VARIANT::m_ExcludedFromBoard, VARIANT::m_ExcludedFromBOM, VARIANT::m_ExcludedFromPosFiles, VARIANT::m_ExcludedFromSim, SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromPosFiles(), and SCH_SYMBOL::SetExcludedFromSim().

◆ BOOST_AUTO_TEST_CASE() [15/22]

BOOST_AUTO_TEST_CASE ( VariantDeletionCascade )

◆ BOOST_AUTO_TEST_CASE() [16/22]

BOOST_AUTO_TEST_CASE ( VariantDescription )

◆ BOOST_AUTO_TEST_CASE() [17/22]

◆ BOOST_AUTO_TEST_CASE() [18/22]

BOOST_AUTO_TEST_CASE ( VariantFieldDifferenceDetection )

◆ BOOST_AUTO_TEST_CASE() [19/22]

BOOST_AUTO_TEST_CASE ( VariantFieldUnicodeAndSpecialChars )

◆ BOOST_AUTO_TEST_CASE() [20/22]

BOOST_AUTO_TEST_CASE ( VariantNameHandling )

Test variant name handling in eeschema.

Note: Unlike PCB, eeschema variant lookups are currently case-sensitive.

Definition at line 691 of file test_sch_symbol.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), and SCH_SYMBOL::SetDNP().

◆ BOOST_AUTO_TEST_CASE() [21/22]

BOOST_AUTO_TEST_CASE ( VariantSpecificFieldDereferencing )

◆ BOOST_AUTO_TEST_CASE() [22/22]

BOOST_AUTO_TEST_CASE ( VariantSwitchInvalidatesBoundingBoxCache )

Test that switching variants invalidates field bounding box caches so that field geometry reflects the new variant's text.

This is the regression test for GitLab issue #22917.

Definition at line 981 of file test_sch_symbol.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), EDA_TEXT::ClearBoundingBoxCache(), FOOTPRINT, KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetName(), SCH_FIELD::GetShownText(), EDA_TEXT::GetTextBox(), BOX2< Vec >::GetWidth(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetFieldText(), SCH_SYMBOL::SetFootprintFieldText(), and EDA_TEXT::SetVisible().