79 PCB_DIFFER differ( m_before.get(), m_after.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
83 BOOST_CHECK_MESSAGE(
result.Empty(),
"Two fresh loads of the same fixture should produce no diff; "
84 "got " <<
result.changes.size()
85 <<
" change records" );
101 victim =
static_cast<PCB_TRACK*
>( item );
110 PCB_DIFFER differ( m_before.get(), m_after.get() );
113 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
130 subject =
static_cast<PCB_TRACK*
>( item );
137 int originalWidth = subject->
GetWidth();
138 int newWidth = originalWidth + 50000;
141 PCB_DIFFER differ( m_before.get(), m_after.get() );
144 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
148 bool foundWidthDelta =
false;
152 if( d.
name.Lower().Contains( wxS(
"width" ) ) )
154 foundWidthDelta =
true;
160 BOOST_CHECK_MESSAGE( foundWidthDelta,
"Expected Width property delta after SetWidth() on a track" );
167 m_before->GetTitleBlock().SetRevision( wxS(
"A" ) );
168 m_after->GetTitleBlock().SetRevision( wxS(
"B" ) );
170 PCB_DIFFER differ( m_before.get(), m_after.get() );
173 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
174 BOOST_CHECK(
result.changes[0].id.empty() );
177 bool foundRevisionDelta =
false;
183 foundRevisionDelta =
true;
189 BOOST_CHECK_MESSAGE( foundRevisionDelta,
"Expected a title block delta after changing the board revision" );
196 std::map<wxString, PCB_TRACK*> tracksByNet;
197 wxString selectedNet;
213 if( tracksByNet.contains( netName ) )
215 selectedNet = netName;
216 first = tracksByNet[netName];
221 tracksByNet[netName] = track;
230 PCB_DIFFER differ( m_before.get(), m_after.get() );
233 std::size_t selectedNetChanges = 0;
237 if( change.
refdes == selectedNet )
239 ++selectedNetChanges;
240 BOOST_CHECK( change.
typeName == wxS(
"PCB_TRACK" ) || change.
typeName == wxS(
"PCB_VIA" ) );
259 if( !fp->
Pads().empty() )
270 pad->SetNumber(
pad->GetNumber() + wxS(
"X" ) );
272 PCB_DIFFER differ( m_before.get(), m_after.get() );
276 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
279 BOOST_REQUIRE_EQUAL(
result.changes[0].children.size(), 1u );
282 pad->m_Uuid.AsString().ToStdString() );
290 for(
BOARD_ITEM* item : m_after->GetItemSet() )
301 const int before = fp->
GetX();
302 const int after = before +
pcbIUScale.mmToIU( 0.5 );
305 PCB_DIFFER differ( m_before.get(), m_after.get() );
308 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
315 if( d.
name != wxS(
"Position X" ) )
326 BOOST_CHECK( found );
333 FOOTPRINT* beforeFp = m_before->Footprints().front();
334 auto* afterFp =
dynamic_cast<FOOTPRINT*
>( m_after->ResolveItem( beforeFp->
m_Uuid,
true ) );
338 PCB_FIELD& afterField = afterFp->Value();
342 PCB_DIFFER unchangedDiffer( m_before.get(), m_after.get() );
343 BOOST_CHECK( unchangedDiffer.
Diff().
Empty() );
345 afterField.
SetText( wxS(
"QA_CHANGED_VALUE" ) );
346 PCB_DIFFER differ( m_before.get(), m_after.get() );
349 BOOST_REQUIRE_EQUAL( diff.
changes.size(), 1u );
350 BOOST_REQUIRE_EQUAL( diff.
changes[0].children.size(), 1u );
353 BOOST_REQUIRE_EQUAL( change.
id.size(), 2u );
354 BOOST_CHECK( change.
id.at( 0 ) == beforeFp->
m_Uuid );
357 BOOST_CHECK(
FindPcbDiffItem( m_before.get(), change.
id.back() ) == &beforeField );
358 BOOST_CHECK(
FindPcbDiffItem( m_after.get(), change.
id.back() ) == &afterField );
368 for(
FOOTPRINT* fp : m_after->Footprints() )
370 fp->Value().SetText( wxS(
"QA_VALUE_" ) + fp->GetReference() );
376 BOOST_REQUIRE_EQUAL( changed, 2 );
377 PCB_DIFFER differ( m_before.get(), m_after.get() );
380 BOOST_REQUIRE_EQUAL( diff.
changes.size(), 2u );
381 BOOST_REQUIRE_EQUAL( diff.
changes[0].children.size(), 1u );
382 BOOST_REQUIRE_EQUAL( diff.
changes[1].children.size(), 1u );
385 BOOST_REQUIRE_EQUAL( first.
id.size(), 2u );
386 BOOST_REQUIRE_EQUAL( second.
id.size(), 2u );
389 BOOST_CHECK( first.
id.back() != second.
id.back() );
393 auto* fp =
dynamic_cast<FOOTPRINT*
>( m_after->ResolveItem( parent.
id.back(),
true ) );
409 subject =
static_cast<PCB_TRACK*
>( item );
417 PCB_DIFFER differ1( m_before.get(), m_after.get() );
418 PCB_DIFFER differ2( m_before.get(), m_after.get() );
436 subject =
static_cast<PCB_TRACK*
>( item );
444 PCB_DIFFER differ( m_before.get(), m_after.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
447 nlohmann::json j =
result.ToJson();
452 BOOST_REQUIRE_EQUAL( back.
changes.size(),
result.changes.size() );
453 BOOST_CHECK( back.
changes[0].kind ==
result.changes[0].kind );
463 BOOST_CHECK( !geometry.
Empty() );
465 LSET expectedTrackLayers;
467 for(
const PCB_TRACK* track : m_after->Tracks() )
470 expectedTrackLayers |= track->GetLayerSet();
476 BOOST_CHECK( ( geometryLayers & expectedTrackLayers ).
any() );
478 bool segmentWithLayer =
false;
482 if( segment.
layers.any() )
484 segmentWithLayer =
true;
489 BOOST_CHECK( segmentWithLayer );
constexpr EDA_IU_SCALE pcbIUScale
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
wxString GetNetname() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetUuid(const KIID &aUuid)
virtual void SetText(const wxString &aText)
wxString AsString() const
wxString ToDisplayString() const
Human-readable representation with no unit context.
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
A color representation with 4 components: red, green, blue, alpha.
wxString AsString() const
LSET is a set of PCB_LAYER_IDs.
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
A type-safe container of any type.
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
LSET GeometryLayerSet(const DOCUMENT_GEOMETRY &aGeometry)
Return the union of every non-empty layer set carried by the geometry.
const EDA_IU_SCALE & IuScaleForDocKind(DOC_KIND aKind)
Internal-unit scale a document kind's coordinates are expressed in.
const wxString DOC_PROP_REVISION
BOARD_ITEM * FindPcbDiffItem(const BOARD *aBoard, const KIID &aId)
Resolve an actual UUID or a footprint field's diff ID on a board.
DOCUMENT_GEOMETRY ExtractBoardGeometry(const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SC...
DOC_KIND DocKindFromDocType(const wxString &aDocType)
Map a DOCUMENT_DIFF::docType tag written by the differs ("kicad_pcb", "kicad_sch",...
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
The full set of changes between two parsed documents of one type.
nlohmann::json ToJson() const
static DOCUMENT_DIFF FromJson(const nlohmann::json &aJson)
std::vector< ITEM_CHANGE > changes
Aggregate of background geometry extracted from one source document.
std::vector< DOCUMENT_SEGMENT > segments
Stroked line segment from one of the source documents.
One change record on a single item.
std::optional< wxString > refdes
std::vector< ITEM_CHANGE > children
Single (name, before, after) triple for one mutated property on an item.
Fixture: loads the same canonical board into two separate BOARD instances so tests can mutate one and...
std::unique_ptr< BOARD > m_before
SETTINGS_MANAGER m_settingsA
SETTINGS_MANAGER m_settingsB
std::unique_ptr< BOARD > m_after
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TwoFreshLoadsAreIdentical)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)