|
KiCad PCB EDA Suite
|
Test suite for SCH_SYMBOL object. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include "eeschema_test_utils.h"#include <sch_symbol.h>#include <sch_edit_frame.h>#include <wildcards_and_files_ext.h>#include <lib_symbol.h>#include <eda_search_data.h>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 (VariantDialogBatchCommit) | |
| Regression test for issue #23545. | |
| 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. | |
| BOOST_AUTO_TEST_CASE (MatchesUsesInstanceFields) | |
| Regression test for issue #23518. | |
Test suite for SCH_SYMBOL object.
Definition in file test_sch_symbol.cpp.
| BOOST_AUTO_TEST_CASE | ( | CopyVariantCreatesIndependentCopy | ) |
Test CopyVariant creates an independent copy.
Definition at line 431 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetExcludedFromBoard(), SCH_SYMBOL::GetExcludedFromBOM(), SCH_SYMBOL::GetExcludedFromPosFiles(), SCH_SYMBOL::GetField(), SCH_FIELD::GetShownText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromPosFiles(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | DefaultProperties | ) |
Declare the test suite.
Check that we can get the default properties as expected.
Definition at line 78 of file test_sch_symbol.cpp.
References BOOST_AUTO_TEST_CASE().
| 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 162 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 | ( | FootprintFieldVariantNoOpWhenSame | ) |
Test that setting footprint to same value as base when variant is active does not create an unnecessary override entry.
Definition at line 1000 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 | ( | 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 947 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 | ( | GetVariantNamesForUI | ) |
Test GetVariantNamesForUI returns properly formatted array.
Definition at line 599 of file test_sch_symbol.cpp.
References BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().
| BOOST_AUTO_TEST_CASE | ( | MatchesUsesInstanceFields | ) |
Regression test for issue #23518.
Find-and-replace was matching power symbols derived from "+5V" (e.g. "+5VA") when searching for "+5V" with whole-word matching, because SCH_SYMBOL::Matches() was iterating the library template's fields instead of the instance's fields. The lib template for "+5VA" still contained "+5V" in its value field.
Definition at line 1174 of file test_sch_symbol.cpp.
References BOOST_CHECK_MESSAGE(), EDA_SEARCH_DATA::findString, SCH_SYMBOL::GetField(), LIB_SYMBOL::GetLibId(), LIB_SYMBOL::GetValueField(), SCH_SYMBOL::Matches(), EDA_SEARCH_DATA::matchMode, PLAIN, EDA_SEARCH_DATA::searchAllFields, SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), VALUE, and WHOLEWORD.
| BOOST_AUTO_TEST_CASE | ( | Orientation | ) |
Test the orientation transform changes.
Definition at line 86 of file test_sch_symbol.cpp.
References SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.
| BOOST_AUTO_TEST_CASE | ( | RenameVariantPreservesData | ) |
Test RenameVariant preserves data.
Definition at line 374 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetShownText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | SchSymbolVariantTest | ) |
Test symbol variant handling.
Definition at line 104 of file test_sch_symbol.cpp.
References SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetExcludedFromBoard(), SCH_SYMBOL::GetExcludedFromBOM(), SCH_SYMBOL::GetExcludedFromPosFiles(), SCH_SYMBOL::GetExcludedFromSim(), SCH_SYMBOL::GetField(), SCH_FIELD::GetShownText(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromPosFiles(), SCH_SYMBOL::SetExcludedFromSim(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | SetFieldTextAndSetValueFieldTextConsistency | ) |
Test that SetFieldText works consistently with SetValueFieldText for the VALUE field.
Definition at line 696 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetFieldText(), SCH_FIELD::GetName(), SCH_SYMBOL::GetValue(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetFieldText(), SCH_SYMBOL::SetValueFieldText(), and VALUE.
| 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 651 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 | ( | TextVariableVARIANT | ) |
Test ${VARIANT} text variable resolution.
Definition at line 296 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().
| BOOST_AUTO_TEST_CASE | ( | TextVariableVARIANT_DESC | ) |
Test ${VARIANT_DESC} text variable resolution.
Definition at line 337 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().
| 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 1120 of file test_sch_symbol.cpp.
References BOOST_CHECK_MESSAGE(), 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 | ( | VariantDeletionCascade | ) |
Test variant deletion clears symbol variant data.
Definition at line 792 of file test_sch_symbol.cpp.
References BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetVariant(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | VariantDescription | ) |
Test variant description methods.
Definition at line 262 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), FILEEXT::KiCadSchematicFileExtension, and LoadSchematic().
| BOOST_AUTO_TEST_CASE | ( | VariantDialogBatchCommit | ) |
Regression test for issue #23545.
The symbol properties dialog called SetExcludedFromBoard() and SetExcludedFromPosFiles() without variant parameters, causing them to modify the base property instead of the variant override. When reading back via GetExcludedFromBoard/PosFiles with a variant name, the stale variant value (from InitializeAttributes at variant creation time) was returned instead of the user-intended value.
This test simulates the dialog's TransferDataFromWindow call order to verify all five boolean attributes survive a batch commit to the same variant.
Definition at line 212 of file test_sch_symbol.cpp.
References BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetExcludedFromBoard(), SCH_SYMBOL::GetExcludedFromBOM(), SCH_SYMBOL::GetExcludedFromPosFiles(), SCH_SYMBOL::GetExcludedFromSim(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromPosFiles(), and SCH_SYMBOL::SetExcludedFromSim().
| BOOST_AUTO_TEST_CASE | ( | VariantDNPFiltering | ) |
Test variant DNP filtering for BOM.
Definition at line 545 of file test_sch_symbol.cpp.
References BOOST_REQUIRE(), SCH_SYMBOL::GetDNP(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetExcludedFromBoard(), SCH_SYMBOL::GetExcludedFromBOM(), SCH_SYMBOL::GetExcludedFromPosFiles(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), and SCH_SYMBOL::SetExcludedFromPosFiles().
| BOOST_AUTO_TEST_CASE | ( | VariantFieldDifferenceDetection | ) |
Test variant field value difference detection.
Definition at line 497 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetShownText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | VariantFieldUnicodeAndSpecialChars | ) |
Test variant field values with unicode and special characters.
Definition at line 832 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_FIELD::GetShownText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_FIELD::SetText(), and VALUE.
| BOOST_AUTO_TEST_CASE | ( | VariantNameHandling | ) |
Test variant name handling in eeschema.
Note: Unlike PCB, eeschema variant lookups are currently case-sensitive.
Definition at line 752 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 | ( | VariantSpecificFieldDereferencing | ) |
Test variant-specific field dereferencing via ${REF:FIELD:VARIANT} syntax.
Definition at line 881 of file test_sch_symbol.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetRef(), SCH_FIELD::GetShownText(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), SCH_SYMBOL::ResolveTextVar(), SCH_FIELD::SetText(), and VALUE.
| 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 1042 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().