KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24606_derived_symbol_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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
24
26
27#include <lib_symbol.h>
28#include <sch_field.h>
29
30
31BOOST_AUTO_TEST_SUITE( DerivedSymbolUserFields )
32
33
34
40BOOST_AUTO_TEST_CASE( UnmodifiedInheritedFieldDetection )
41{
42 LIB_SYMBOL base( wxS( "Base" ) );
43 LIB_SYMBOL derived( wxS( "Derived" ) );
44
45 derived.SetParent( &base );
46
47 SCH_FIELD* parentField = new SCH_FIELD( &base, FIELD_T::USER, wxS( "Tolerance" ) );
48 parentField->SetText( wxS( "1%" ) );
49 base.AddField( parentField );
50
51 SCH_FIELD row( *parentField );
52 row.SetParent( &derived );
53 row.SetOrdinal( 42 );
54
55 BOOST_CHECK( !( row == *parentField ) );
56 BOOST_CHECK( row.HasSameContent( *parentField ) );
57
58 // Any user modification must break the match so the override is saved.
59 SCH_FIELD changedText( row );
60 changedText.SetText( wxS( "5%" ) );
61 BOOST_CHECK( !changedText.HasSameContent( *parentField ) );
62
63 SCH_FIELD changedVisibility( row );
64 changedVisibility.SetVisible( !changedVisibility.IsVisible() );
65 BOOST_CHECK( !changedVisibility.HasSameContent( *parentField ) );
66
67 SCH_FIELD changedPosition( row );
68 changedPosition.SetPosition( changedPosition.GetPosition() + VECTOR2I( 100, 100 ) );
69 BOOST_CHECK( !changedPosition.HasSameContent( *parentField ) );
70
71 SCH_FIELD changedNameShown( row );
72 changedNameShown.SetNameShown( !changedNameShown.IsNameShown() );
73 BOOST_CHECK( !changedNameShown.HasSameContent( *parentField ) );
74
75 SCH_FIELD changedName( row );
76 changedName.SetName( wxS( "Tol" ) );
77 BOOST_CHECK( !changedName.HasSameContent( *parentField ) );
78}
79
80
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:89
virtual bool IsVisible() const
Definition eda_text.h:208
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:381
Define a library symbol object.
Definition lib_symbol.h:79
void SetParent(LIB_SYMBOL *aParent=nullptr)
void AddField(SCH_FIELD *aField)
Add a field.
void SetOrdinal(int aOrdinal)
Definition sch_field.h:138
bool HasSameContent(const SCH_FIELD &aOther) const
Test if this field has the same name, content and presentation as another field, ignoring the owning ...
VECTOR2I GetPosition() const override
bool IsNameShown() const
Definition sch_field.h:218
void SetPosition(const VECTOR2I &aPosition) override
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
void SetNameShown(bool aShown=true)
Definition sch_field.h:219
@ USER
The field ID hasn't been set yet; field is invalid.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683