KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sch_rule_area_directive_visibility.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 3
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, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
31
33
34#include <sch_label.h>
35#include <sch_rule_area.h>
36
37
38BOOST_AUTO_TEST_SUITE( SchRuleAreaDirectiveVisibility )
39
40
41
44static void attachDirective( SCH_RULE_AREA& aRuleArea, SCH_DIRECTIVE_LABEL& aDirective )
45{
46 aDirective.AddConnectedRuleArea( &aRuleArea );
47 aRuleArea.m_directives.insert( &aDirective );
48}
49
50
51BOOST_AUTO_TEST_CASE( AreaWithoutDirectiveIsNotDirectiveLabelOnly )
52{
53 SCH_RULE_AREA ruleArea;
54
55 BOOST_CHECK( !ruleArea.IsDirectiveLabelOnlyArea() );
56}
57
58
59BOOST_AUTO_TEST_CASE( AreaWithDirectiveAndNoFlagsIsDirectiveLabelOnly )
60{
61 SCH_DIRECTIVE_LABEL directive;
62 SCH_RULE_AREA ruleArea;
63
64 attachDirective( ruleArea, directive );
65
66 BOOST_CHECK( ruleArea.IsDirectiveLabelOnlyArea() );
67}
68
69
70BOOST_AUTO_TEST_CASE( AnyDesignFlagDisqualifiesDirectiveLabelOnly )
71{
72 using FlagSetter = void ( SCH_RULE_AREA::* )( bool, const SCH_SHEET_PATH*, const wxString& );
73
74 const FlagSetter setters[] = { &SCH_RULE_AREA::SetDNP, &SCH_RULE_AREA::SetExcludedFromSim,
77
78 for( const FlagSetter setter : setters )
79 {
80 SCH_DIRECTIVE_LABEL directive;
81 SCH_RULE_AREA ruleArea;
82
83 attachDirective( ruleArea, directive );
84 ( ruleArea.*setter )( true, nullptr, wxEmptyString );
85
86 BOOST_CHECK( !ruleArea.IsDirectiveLabelOnlyArea() );
87 }
88}
89
90
91BOOST_AUTO_TEST_CASE( ClearingFlagsRestoresDirectiveLabelOnly )
92{
93 SCH_DIRECTIVE_LABEL directive;
94 SCH_RULE_AREA ruleArea;
95
96 attachDirective( ruleArea, directive );
97
98 ruleArea.SetDNP( true );
99 ruleArea.SetExcludedFromBoard( true );
100 BOOST_CHECK( !ruleArea.IsDirectiveLabelOnlyArea() );
101
102 ruleArea.SetDNP( false );
103 ruleArea.SetExcludedFromBoard( false );
104 BOOST_CHECK( ruleArea.IsDirectiveLabelOnlyArea() );
105}
106
107
bool IsDirectiveLabelOnlyArea() const
Return true when the rule area exists only as a container for attached directive labels.
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
static void attachDirective(SCH_RULE_AREA &aRuleArea, SCH_DIRECTIVE_LABEL &aDirective)
Attach a directive label to a rule area, establishing the bidirectional cache link that addDirective(...
BOOST_AUTO_TEST_CASE(AreaWithoutDirectiveIsNotDirectiveLabelOnly)