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
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
49
50
51BOOST_FIXTURE_TEST_CASE( SheetDNPEffectiveInSymbolFields, ISSUE24663_FIXTURE )
52{
53 wxFileName fn;
54 fn.SetPath( KI_TEST::GetEeschemaTestDataDir() );
55 fn.SetName( wxS( "test_issue24663_sheet_dnp" ) );
57
58 LoadSchematic( fn.GetFullPath() );
59
60 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
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".
86 BOOST_CHECK_EQUAL( model.GetValue( group, dnpCol ), wxS( "1" ) );
87}
A generic fixture for loading schematics and associated settings for qa tests.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
bool GetSymbolDNP(const wxString &aVariant=wxEmptyString) const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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.
bool GetDNP() const
static const std::string KiCadSchematicFileExtension
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SYMBOL_FILTER_ALL
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(SheetDNPEffectiveInSymbolFields, ISSUE24663_FIXTURE)
KIBIS_MODEL * model
BOOST_CHECK_EQUAL(result, "25.4")
GROUP_SINGLETON
Definition wx_grid.h:41