|
KiCad PCB EDA Suite
|
Test suite for SYMBOL_LIBRARY_MANAGER object. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <symbol_library_manager.h>#include <symbol_editor/lib_symbol_library_manager.h>#include <sch_field.h>#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.h>#include <sch_io/sch_io_mgr.h>#include <richio.h>#include <wx/filename.h>Go to the source code of this file.
Classes | |
| class | SYMBOL_LIBRARY_MANAGER_TEST_FIXTURE |
Functions | |
| BOOST_AUTO_TEST_CASE (SymbolBuffer) | |
| Test the SYMBOL_BUFFER object. | |
| BOOST_AUTO_TEST_CASE (LibBuffer) | |
| Test the LIB_BUFFER object. | |
| BOOST_AUTO_TEST_CASE (NewSymbolCreation) | |
| Test new symbol creation routines. | |
| BOOST_AUTO_TEST_CASE (DeletedSymbolsAreRemovedFromFile) | |
| Test that LIB_BUFFER correctly deletes symbols from the library file when saved. | |
| BOOST_AUTO_TEST_CASE (SaveLibraryAsToNewFile) | |
| Test that saving symbols to a new file using buffered mode works when the target file does not yet exist. | |
| BOOST_AUTO_TEST_CASE (SetParentKeepsParentNameInSync) | |
| Test that SetParent keeps the recorded parent name in sync. | |
| BOOST_AUTO_TEST_CASE (SerializeDerivedSymbolUsesParentName) | |
| Test that serializing a derived symbol uses the recorded parent name rather than dereferencing the live parent pointer. | |
| BOOST_AUTO_TEST_CASE (SaveCopyAsDerivedSymbolToNewLibrary) | |
| Test that "Save Copy As" of a derived symbol to a new library produces a valid, round-trippable result where the copied child keeps a valid parent link and parent name. | |
Test suite for SYMBOL_LIBRARY_MANAGER object.
Definition in file test_symbol_library_manager.cpp.
| BOOST_AUTO_TEST_CASE | ( | DeletedSymbolsAreRemovedFromFile | ) |
Test that LIB_BUFFER correctly deletes symbols from the library file when saved.
This test verifies the fix for the bug where deleting a derived symbol from the symbol editor tree and saving would result in the symbol reappearing as a non-derived symbol when the library was reloaded. The root cause was that SaveBuffer only saved existing symbols but never called DeleteSymbol on the plugin for symbols in the m_deleted list.
Definition at line 234 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), LIB_BUFFER::ClearDeletedBuffer(), LIB_BUFFER::CreateBuffer(), LIB_BUFFER::DeleteBuffer(), LIB_BUFFER::GetBuffer(), LIB_BUFFER::GetBuffers(), LIB_BUFFER::GetDeletedBuffers(), LIB_BUFFER::GetSymbol(), LIB_SYMBOL::IsDerived(), SCH_IO_KICAD_SEXPR::PropBuffering, LIB_BUFFER::SaveBuffer(), and LIB_SYMBOL::SetParent().
| BOOST_AUTO_TEST_CASE | ( | LibBuffer | ) |
Test the LIB_BUFFER object.
Definition at line 85 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_EQUAL(), LIB_BUFFER::CreateBuffer(), LIB_BUFFER::DeleteBuffer(), DERIVED_ONLY, LIB_BUFFER::GetBuffer(), LIB_BUFFER::GetBuffers(), LIB_BUFFER::GetDerivedSymbolNames(), LIB_SYMBOL::GetDescriptionField(), LIB_BUFFER::GetHash(), LIB_SYMBOL::GetName(), LIB_BUFFER::GetSymbol(), LIB_BUFFER::GetSymbolNames(), LIB_BUFFER::HasDerivedSymbols(), LIB_BUFFER::IsModified(), ROOT_ONLY, LIB_SYMBOL::SetParent(), SCH_FIELD::SetText(), and LIB_BUFFER::UpdateBuffer().
| BOOST_AUTO_TEST_CASE | ( | NewSymbolCreation | ) |
Test new symbol creation routines.
Definition at line 164 of file test_symbol_library_manager.cpp.
References NEW_SYMBOL_PROPERTIES::alternateBodyStyle, BOOST_CHECK_EQUAL(), LIB_SYMBOL_LIBRARY_MANAGER::CreateSymbol(), NEW_SYMBOL_PROPERTIES::includeInBom, NEW_SYMBOL_PROPERTIES::includeOnBoard, NEW_SYMBOL_PROPERTIES::keepContentUserFields, NEW_SYMBOL_PROPERTIES::keepDatasheet, NEW_SYMBOL_PROPERTIES::keepFootprint, NEW_SYMBOL_PROPERTIES::name, NEW_SYMBOL_PROPERTIES::parentSymbolName, NEW_SYMBOL_PROPERTIES::pinNameInside, NEW_SYMBOL_PROPERTIES::pinTextPosition, NEW_SYMBOL_PROPERTIES::powerSymbol, NEW_SYMBOL_PROPERTIES::reference, SCH_FIELD::SetText(), NEW_SYMBOL_PROPERTIES::showPinName, NEW_SYMBOL_PROPERTIES::showPinNumber, NEW_SYMBOL_PROPERTIES::transferUserFields, NEW_SYMBOL_PROPERTIES::unitCount, NEW_SYMBOL_PROPERTIES::unitsInterchangeable, and USER.
| BOOST_AUTO_TEST_CASE | ( | SaveCopyAsDerivedSymbolToNewLibrary | ) |
Test that "Save Copy As" of a derived symbol to a new library produces a valid, round-trippable result where the copied child keeps a valid parent link and parent name.
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24412
Definition at line 525 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), LIB_SYMBOL::GetName(), LIB_SYMBOL::GetParent(), LIB_SYMBOL::IsDerived(), SCH_IO_KICAD_SEXPR::PropBuffering, LIB_SYMBOL::SetParent(), and LIB_SYMBOL::SetParentName().
| BOOST_AUTO_TEST_CASE | ( | SaveLibraryAsToNewFile | ) |
Test that saving symbols to a new file using buffered mode works when the target file does not yet exist.
This exercises the same code path as "Save Library As" in the symbol editor: a fresh SCH_IO plugin instance buffers symbols and then flushes to a new file path. Before the fix, cacheLib() would call Load() on the non-existent target file and throw, resulting in an empty library (header only).
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23337
Definition at line 372 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), LIB_SYMBOL::IsDerived(), SCH_IO_KICAD_SEXPR::PropBuffering, and LIB_SYMBOL::SetParent().
| BOOST_AUTO_TEST_CASE | ( | SerializeDerivedSymbolUsesParentName | ) |
Test that serializing a derived symbol uses the recorded parent name rather than dereferencing the live parent pointer.
This guards the "Save As" / "Save Copy As" crash from the symbol editor: a derived symbol (e.g. an STM32 part inheriting from a base symbol) is copied to another library and the buffered parent can be freed before the child is written out. In release builds the writer dereferenced the (dangling) parent pointer and crashed; debug builds only tripped a wxASSERT, which is why the issue was "not reproducible" for testers using debug builds.
Regression test for https://gitlab.com/kicad/code/kicad/-/issues/24412
Definition at line 491 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), STRING_FORMATTER::GetString(), LIB_SYMBOL::GetValueField(), LIB_SYMBOL::IsDerived(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), LIB_SYMBOL::SetParent(), LIB_SYMBOL::SetParentName(), and SCH_FIELD::SetText().
| BOOST_AUTO_TEST_CASE | ( | SetParentKeepsParentNameInSync | ) |
Test that SetParent keeps the recorded parent name in sync.
The "Save As" / "Save Copy As" crash (issue #24412) happened because the SEXPR writer dereferenced the live parent pointer to obtain the parent name. That pointer can dangle (the parent LIB_SYMBOL uses a null_deleter shared_ptr whose control block can outlive the object), so the writer now serializes the recorded parent name instead. For that to be correct, the recorded name must track the live parent.
Definition at line 460 of file test_symbol_library_manager.cpp.
References BOOST_CHECK_EQUAL(), LIB_SYMBOL::GetParent(), LIB_SYMBOL::GetParentName(), LIB_SYMBOL::IsDerived(), and LIB_SYMBOL::SetParent().
| BOOST_AUTO_TEST_CASE | ( | SymbolBuffer | ) |
Test the SYMBOL_BUFFER object.
Definition at line 54 of file test_symbol_library_manager.cpp.
References BOOST_AUTO_TEST_CASE(), SYMBOL_BUFFER::GetOriginal(), SYMBOL_BUFFER::GetScreen(), SYMBOL_BUFFER::GetSymbol(), SYMBOL_BUFFER::IsModified(), BASE_SCREEN::SetContentModified(), and SYMBOL_BUFFER::SetOriginal().