|
KiCad PCB EDA Suite
|
Test for issue #20173: Copy/paste subsheet causes original sheet's references to be corrupted. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <schematic_utils/schematic_file_util.h>#include <connection_graph.h>#include <schematic.h>#include <sch_sheet.h>#include <sch_screen.h>#include <sch_symbol.h>#include <settings/settings_manager.h>#include <locale_io.h>Go to the source code of this file.
Classes | |
| struct | ISSUE20173_FIXTURE |
Functions | |
| std::map< KIID, wxString > | GetSymbolReferences (const SCH_SHEET_PATH &aPath) |
| Helper function to get all symbol references for a given sheet path. | |
| BOOST_FIXTURE_TEST_CASE (Issue20173PruningAfterPaste, ISSUE20173_FIXTURE) | |
| Test that simulates the paste flow more closely, including instance pruning. | |
| BOOST_FIXTURE_TEST_CASE (Issue20173ClearAnnotationFieldCorruption, ISSUE20173_FIXTURE) | |
| Test that ClearAnnotation doesn't corrupt REFERENCE field in a way that affects GetRef. | |
| BOOST_FIXTURE_TEST_CASE (Issue20173FieldTextCorruption, ISSUE20173_FIXTURE) | |
| Test that reproduces the actual bug: ClearAnnotation corrupts field text. | |
| BOOST_FIXTURE_TEST_CASE (Issue20173SharedScreenInstances, ISSUE20173_FIXTURE) | |
| Test that symbols on a shared screen maintain independent instances for each sheet path. | |
Test for issue #20173: Copy/paste subsheet causes original sheet's references to be corrupted.
The test verifies that when a subsheet is copy/pasted to create a second instance sharing the same screen file, the original sheet's symbol references are preserved correctly.
Bug scenario:
Root cause: When a shared screen is used, symbol instances for the original path may be incorrectly modified or lost during the paste operation.
Definition in file test_issue20173_paste_subsheet.cpp.
| BOOST_FIXTURE_TEST_CASE | ( | Issue20173ClearAnnotationFieldCorruption | , |
| ISSUE20173_FIXTURE | ) |
Test that ClearAnnotation doesn't corrupt REFERENCE field in a way that affects GetRef.
ClearAnnotation modifies both the instance reference AND the REFERENCE field text. If GetRef falls back to the field text (when instance doesn't match), this can cause issues.
Definition at line 255 of file test_issue20173_paste_subsheet.cpp.
References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), SCH_SYMBOL::ClearAnnotation(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SYMBOL::GetRef(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, REFERENCE, SCH_SYMBOL_T, SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, and SCH_SHEET_PATH::size().
| BOOST_FIXTURE_TEST_CASE | ( | Issue20173FieldTextCorruption | , |
| ISSUE20173_FIXTURE | ) |
Test that reproduces the actual bug: ClearAnnotation corrupts field text.
When ClearAnnotation is called for a specific path (CH2), it incorrectly modifies the REFERENCE field text. If GetRef later falls back to field text (due to mismatched instance paths), it returns the corrupted value.
Definition at line 379 of file test_issue20173_paste_subsheet.cpp.
References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), SCH_SYMBOL::ClearAnnotation(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, REFERENCE, SCH_SYMBOL_T, SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, and SCH_SHEET_PATH::size().
| BOOST_FIXTURE_TEST_CASE | ( | Issue20173PruningAfterPaste | , |
| ISSUE20173_FIXTURE | ) |
Test that simulates the paste flow more closely, including instance pruning.
This test specifically checks whether the PruneOrphanedSymbolInstances call after paste incorrectly removes the original sheet's instances.
Definition at line 96 of file test_issue20173_paste_subsheet.cpp.
References KIID::AsString(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SHEET::GetPosition(), SCH_SYMBOL::GetRef(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, SCH_SCREENS::PruneOrphanedSymbolInstances(), REFERENCE, SCH_SYMBOL_T, schIUScale, SCH_SHEET::SetPosition(), SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, and SCH_SHEET_PATH::size().
| BOOST_FIXTURE_TEST_CASE | ( | Issue20173SharedScreenInstances | , |
| ISSUE20173_FIXTURE | ) |
Test that symbols on a shared screen maintain independent instances for each sheet path.
This tests the fundamental requirement that symbols can have different reference designators in different sheet instances, even when sharing the same screen.
Definition at line 513 of file test_issue20173_paste_subsheet.cpp.
References KIID::AsString(), KIID_PATH::AsString(), BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), dummy, SCH_SHEET::GetField(), SCH_SYMBOL::GetField(), SCH_SHEET::GetFileName(), SCH_SYMBOL::GetInstances(), SCH_SHEET::GetPosition(), SCH_SYMBOL::GetRef(), SCH_SHEET::GetScreen(), SCH_FIELD::GetText(), SCH_SCREEN::Items(), KI_TEST::LoadSchematic(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), SCH_SHEET_PATH::Path(), path, SCH_SHEET_PATH::push_back(), REFERENCE, SCH_SYMBOL_T, schIUScale, SCH_SHEET::SetPosition(), SCH_SYMBOL::SetRef(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, SCH_SHEET_PATH::size(), and SCH_SHEET_PATH::UpdateAllScreenReferences().
| std::map< KIID, wxString > GetSymbolReferences | ( | const SCH_SHEET_PATH & | aPath | ) |
Helper function to get all symbol references for a given sheet path.
Returns a map of symbol UUID -> reference designator.
Definition at line 68 of file test_issue20173_paste_subsheet.cpp.
References SCH_SYMBOL::GetRef(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EDA_ITEM::m_Uuid, EE_RTREE::OfType(), and SCH_SYMBOL_T.