KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue25521.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include <
qa_utils/wx_utils/unit_test_utils.h
>
21
#include <
pcbnew_utils/board_test_utils.h
>
22
23
#include <map>
24
#include <
board.h
>
25
#include <
settings/settings_manager.h
>
26
#include <
zone.h
>
27
#include <
zone_settings_bag.h
>
28
29
// Regression test for https://gitlab.com/kicad/code/kicad/-/work_items/25521
30
//
31
// The Zone Manager edits clones of the board zones. Resolving a unique name against the board
32
// originals made every clone collide with itself, so each pass through the dialog appended another
33
// suffix and "bigger" became "bigger_1", then "bigger_2".
34
35
BOOST_AUTO_TEST_SUITE
( Issue25521 )
36
37
38
BOOST_AUTO_TEST_CASE
( ZoneManagerKeepsZoneNames )
39
{
40
SETTINGS_MANAGER
settingsManager;
41
std::unique_ptr<BOARD> board;
42
43
KI_TEST::LoadBoard
( settingsManager,
"issue25521_zone_names"
, board );
44
45
ZONE_SETTINGS_BAG
bag( board.get() );
46
47
BOOST_REQUIRE_EQUAL( bag.
GetClonedZoneList
().size(), 3u );
48
49
std::map<ZONE*, wxString> originalNames;
50
51
for
(
const
auto
& [zone, clone] : bag.
GetZonesCloneMap
() )
52
originalNames[clone.get()] = zone->GetZoneName();
53
54
// Every selection change in the manager reads the panel back, resolving the name once per zone
55
for
(
ZONE
* clone : bag.
GetClonedZoneList
() )
56
{
57
std::shared_ptr<ZONE_SETTINGS> settings = bag.
GetZoneSettings
( clone );
58
59
settings->m_Name = bag.
GetUniqueZoneName
( *board, settings->m_Name, clone );
60
}
61
62
bag.
UpdateClonedZones
();
63
64
for
(
ZONE
* clone : bag.
GetClonedZoneList
() )
65
BOOST_CHECK_EQUAL
( clone->GetZoneName(), originalNames[clone] );
66
}
67
68
69
BOOST_AUTO_TEST_SUITE_END
()
board.h
board_test_utils.h
SETTINGS_MANAGER
Definition
settings_manager.h:48
ZONE_SETTINGS_BAG
Definition
zone_settings_bag.h:33
ZONE_SETTINGS_BAG::GetZonesCloneMap
std::unordered_map< ZONE *, std::shared_ptr< ZONE > > & GetZonesCloneMap()
Definition
zone_settings_bag.h:70
ZONE_SETTINGS_BAG::UpdateClonedZones
void UpdateClonedZones()
The cloned list is the working storage.
Definition
zone_settings_bag.cpp:152
ZONE_SETTINGS_BAG::GetUniqueZoneName
wxString GetUniqueZoneName(const BOARD &aBoard, const wxString &aBaseName, const ZONE *aZone) const
Return a name based on aBaseName that no other zone on aBoard uses.
Definition
zone_settings_bag.cpp:89
ZONE_SETTINGS_BAG::GetClonedZoneList
std::vector< ZONE * > & GetClonedZoneList()
Definition
zone_settings_bag.h:69
ZONE_SETTINGS_BAG::GetZoneSettings
std::shared_ptr< ZONE_SETTINGS > GetZoneSettings(ZONE *aZone)
Definition
zone_settings_bag.cpp:71
ZONE
Handle a list of polygons defining a copper zone.
Definition
zone.h:70
KI_TEST::LoadBoard
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
Definition
board_test_utils.cpp:90
settings_manager.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:80
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
zone.h
zone_settings_bag.h
src
qa
tests
pcbnew
test_issue25521.cpp
Generated on Wed Oct 7 2026 00:06:12 for KiCad PCB EDA Suite by
1.13.2