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

Test for issue #21401: pasting a symbol with modified pin numbering into a project that already contains the original (unmodified) version of the same library symbol must preserve the modified pin numbers from the clipboard. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <memory>
#include <set>
#include <lib_symbol.h>
#include <sch_pin.h>
#include <sch_symbol.h>
#include <sch_screen.h>
#include <tools/sch_editor_control.h>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (Issue21401_WrongLibSymbolRevertsPinNumbers)
 The core bug mechanism: SetLibSymbol()/UpdatePins() drives pin numbers from the chosen lib symbol.
 
 BOOST_AUTO_TEST_CASE (Issue21401_PastePrefersClipboardLibSymbol)
 Issue #21401: with both clipboard and destination caching the same-named symbol, the paste helper must pick the clipboard copy so its modified pin numbers survive the paste.
 
 BOOST_AUTO_TEST_CASE (Issue22162_PastePrefersClipboardPowerType)
 Regression guard for issue #22162: the clipboard copy must still win when the destination caches a same-named symbol with a different power type, so the pasted symbol keeps its power type.
 
 BOOST_AUTO_TEST_CASE (Issue21401_FallsBackToDestinationWhenClipboardEmpty)
 When the clipboard carries no cached copy (e.g.
 

Detailed Description

Test for issue #21401: pasting a symbol with modified pin numbering into a project that already contains the original (unmodified) version of the same library symbol must preserve the modified pin numbers from the clipboard.

The reproduction is clipboard-driven and only fully exercisable through the GUI Paste action, which the eeschema unit-test harness cannot drive (no frame/tool manager/clipboard). The bug, however, lives entirely in which cached library symbol the paste selects, so these tests drive the production selection helper SCH_EDITOR_CONTROL::ChoosePasteLibSymbol directly and confirm the chosen definition survives SCH_SYMBOL::SetLibSymbol() without losing the copied pin numbers.

Definition in file test_issue21401_paste_pin_numbers.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( Issue21401_FallsBackToDestinationWhenClipboardEmpty )

When the clipboard carries no cached copy (e.g.

legacy clipboard content), the helper falls back to the destination cache.

Definition at line 176 of file test_issue21401_paste_pin_numbers.cpp.

References SCH_SCREEN::AddLibSymbol(), BOOST_CHECK_EQUAL(), SCH_EDITOR_CONTROL::ChoosePasteLibSymbol(), LIB_ID::Format(), LIB_SYMBOL::GetLibId(), and UTF8::wx_str().

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( Issue21401_PastePrefersClipboardLibSymbol )

Issue #21401: with both clipboard and destination caching the same-named symbol, the paste helper must pick the clipboard copy so its modified pin numbers survive the paste.

Definition at line 118 of file test_issue21401_paste_pin_numbers.cpp.

References SCH_SCREEN::AddLibSymbol(), BOOST_REQUIRE(), SCH_EDITOR_CONTROL::ChoosePasteLibSymbol(), SCH_SYMBOL::GetSchSymbolLibraryName(), path, SCH_SYMBOL::SetLibSymbol(), and SCH_SYMBOL::UpdatePins().

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( Issue21401_WrongLibSymbolRevertsPinNumbers )

The core bug mechanism: SetLibSymbol()/UpdatePins() drives pin numbers from the chosen lib symbol.

If paste selects a lib symbol whose pin numbers differ from the pasted instance, the instance's modified numbers are clobbered. This documents why selecting the wrong cache reverts the edits and is the failure mode the fix avoids.

Definition at line 96 of file test_issue21401_paste_pin_numbers.cpp.

References SCH_SYMBOL::GetPins(), path, SCH_SYMBOL::SetLibSymbol(), and SCH_SYMBOL::UpdatePins().

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( Issue22162_PastePrefersClipboardPowerType )

Regression guard for issue #22162: the clipboard copy must still win when the destination caches a same-named symbol with a different power type, so the pasted symbol keeps its power type.

Definition at line 148 of file test_issue21401_paste_pin_numbers.cpp.

References SCH_SCREEN::AddLibSymbol(), BOOST_REQUIRE(), SCH_EDITOR_CONTROL::ChoosePasteLibSymbol(), LIB_ID::Format(), LIB_SYMBOL::GetLibId(), LIB_SYMBOL::IsLocalPower(), LIB_SYMBOL::SetGlobalPower(), LIB_SYMBOL::SetLocalPower(), and UTF8::wx_str().