KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24663_sheet_dnp_fields.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
31
32
#include <boost/test/unit_test.hpp>
33
34
#include <
qa_utils/wx_utils/unit_test_utils.h
>
35
#include "
eeschema_test_utils.h
"
36
37
#include <
fields_data_model.h
>
38
#include <
sch_reference_list.h
>
39
#include <
sch_sheet_path.h
>
40
#include <
sch_symbol.h
>
41
#include <
schematic.h
>
42
43
#include <wx/filename.h>
44
45
46
struct
ISSUE24663_FIXTURE
:
public
KI_TEST::SCHEMATIC_TEST_FIXTURE
47
{
48
};
49
50
51
BOOST_FIXTURE_TEST_CASE
( SheetDNPEffectiveInSymbolFields,
ISSUE24663_FIXTURE
)
52
{
53
wxFileName fn;
54
fn.SetPath(
KI_TEST::GetEeschemaTestDataDir
() );
55
fn.SetName( wxS(
"test_issue24663_sheet_dnp"
) );
56
fn.SetExt(
FILEEXT::KiCadSchematicFileExtension
);
57
58
LoadSchematic
( fn.GetFullPath() );
59
60
SCH_SHEET_LIST
sheets = m_schematic->BuildSheetListSortedByPageNumbers();
61
SCH_REFERENCE_LIST
refs;
62
sheets.
GetSymbols
( refs,
SYMBOL_FILTER_ALL
);
63
64
BOOST_REQUIRE_EQUAL( refs.
GetCount
(), 1 );
65
66
SCH_REFERENCE
& r1 = refs[0];
67
68
// Safety: setting DNP on the sheet must not stamp the attribute onto the symbol.
69
BOOST_CHECK( !r1.
GetSymbolDNP
() );
70
71
// The ancestor sheet forces DNP on, so the effective state is DNP.
72
BOOST_CHECK( r1.
GetSheetPath
().
GetDNP
() );
73
74
// The fix: the symbol fields data model reports that effective state. The same code
75
// path serves the on screen checkbox and the BOM export. The exclude_from_board,
76
// exclude_from_bom and exclude_from_sim attributes share it.
77
FIELDS_EDITOR_GRID_DATA_MODEL
model
( refs,
nullptr
);
78
model
.AddColumn( wxS(
"${DNP}"
), wxS(
"DNP"
),
false
, wxEmptyString );
79
80
int
dnpCol =
model
.GetFieldNameCol( wxS(
"${DNP}"
) );
81
BOOST_REQUIRE
( dnpCol >= 0 );
82
83
// GetValue with resolveVars off is the path that feeds the on screen checkbox: a
84
// value of "1" draws it checked. The stored attribute is still the symbol's own "0".
85
DATA_MODEL_ROW
group
( r1,
GROUP_SINGLETON
);
86
BOOST_CHECK_EQUAL
(
model
.GetValue(
group
, dnpCol ), wxS(
"1"
) );
87
}
BITMAPS::group
@ group
Definition
bitmaps_list.h:246
FIELDS_EDITOR_GRID_DATA_MODEL
Definition
fields_data_model.h:137
KI_TEST::SCHEMATIC_TEST_FIXTURE
A generic fixture for loading schematics and associated settings for qa tests.
Definition
eeschema_test_utils.h:46
SCH_REFERENCE_LIST
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
Definition
sch_reference_list.h:280
SCH_REFERENCE_LIST::GetCount
size_t GetCount() const
Definition
sch_reference_list.h:300
SCH_REFERENCE
A helper to define a symbol's reference designator in a schematic.
Definition
sch_reference_list.h:73
SCH_REFERENCE::GetSheetPath
const SCH_SHEET_PATH & GetSheetPath() const
Definition
sch_reference_list.h:92
SCH_REFERENCE::GetSymbolDNP
bool GetSymbolDNP(const wxString &aVariant=wxEmptyString) const
Definition
sch_reference_list.cpp:946
SCH_SHEET_LIST
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Definition
sch_sheet_path.h:579
SCH_SHEET_LIST::GetSymbols
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Definition
sch_sheet_path.cpp:1408
SCH_SHEET_PATH::GetDNP
bool GetDNP() const
Definition
sch_sheet_path.cpp:387
eeschema_test_utils.h
fields_data_model.h
FILEEXT::KiCadSchematicFileExtension
static const std::string KiCadSchematicFileExtension
Definition
wildcards_and_files_ext.h:128
KI_TEST::GetEeschemaTestDataDir
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
Definition
unit_test_utils.cpp:35
LoadSchematic
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
Definition
sch_io_easyeda.cpp:503
sch_reference_list.h
sch_sheet_path.h
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SYMBOL_FILTER_ALL
@ SYMBOL_FILTER_ALL
Definition
sch_sheet_path.h:44
sch_symbol.h
schematic.h
DATA_MODEL_ROW
Definition
fields_data_model.h:112
ISSUE24663_FIXTURE
Definition
test_issue24663_sheet_dnp_fields.cpp:47
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(SheetDNPEffectiveInSymbolFields, ISSUE24663_FIXTURE)
Definition
test_issue24663_sheet_dnp_fields.cpp:51
model
KIBIS_MODEL * model
Definition
test_kibis.cpp:190
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
GROUP_SINGLETON
GROUP_SINGLETON
Definition
wx_grid.h:41
src
qa
tests
eeschema
test_issue24663_sheet_dnp_fields.cpp
Generated on Fri Jun 26 2026 00:05:44 for KiCad PCB EDA Suite by
1.13.2