From 797de9d327c3ab265d6c6b6bbcaa1f4bc4a00ea0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 2 Jan 2022 14:54:27 +0100 Subject: [PATCH] Fix some issues (but not all) in qa tests for eeschema The main fix is for errors in SCH_TEXT and derived: qa test expects 4 rotations is an identity transform: This is false if the item has autoplaced fields. The fix clears autoplaced flags. --- common/eda_angle.cpp | 4 ++-- eeschema/sch_field.cpp | 7 ++++++- qa/drc_proto/drc_proto.cpp | 2 +- qa/eeschema/test_ee_item.cpp | 11 ++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/eda_angle.cpp b/common/eda_angle.cpp index 44c8b4df58..2ab1217b50 100644 --- a/common/eda_angle.cpp +++ b/common/eda_angle.cpp @@ -59,7 +59,7 @@ void EDA_ANGLE::normalize( bool n720 ) int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const { - int full_circle_upper; + int full_circle_upper = DEGREES_FULL_CIRCLE; switch( aAngleType ) { @@ -93,7 +93,7 @@ int EDA_ANGLE::normalize( int aValue, ANGLE_TYPE aAngleType, bool n720 ) const double EDA_ANGLE::normalize( double aValue, ANGLE_TYPE aAngleType, bool n720 ) const { - double full_circle_upper; + double full_circle_upper = DEGREES_FULL_CIRCLE; switch( aAngleType ) { diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index b94e14f8bc..8b2eb1853e 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -765,7 +765,12 @@ wxString SCH_FIELD::GetCanonicalName() const } else { - wxFAIL_MSG( "Unhandled field owner type." ); + if( m_parent ) + { + wxFAIL_MSG( wxString::Format( "Unhandled field owner type (id %d, parent type %d).", + m_id, m_parent->Type() ) ); + } + return m_name; } } diff --git a/qa/drc_proto/drc_proto.cpp b/qa/drc_proto/drc_proto.cpp index c1f8a8ea72..63e4c95a58 100644 --- a/qa/drc_proto/drc_proto.cpp +++ b/qa/drc_proto/drc_proto.cpp @@ -114,7 +114,7 @@ int runDRCProto( PROJECT_CONTEXT project, std::shared_ptr a drcEngine->SetProgressReporter( new CONSOLE_PROGRESS_REPORTER ( &consoleLog ) ); drcEngine->SetViolationHandler( - [&]( const std::shared_ptr& aItem, wxPoint aPos, PCB_LAYER_ID aLayer ) + [&]( const std::shared_ptr& aItem, VECTOR2I aPos, PCB_LAYER_ID aLayer ) { // fixme } ); diff --git a/qa/eeschema/test_ee_item.cpp b/qa/eeschema/test_ee_item.cpp index 6da241812c..575a46c5de 100644 --- a/qa/eeschema/test_ee_item.cpp +++ b/qa/eeschema/test_ee_item.cpp @@ -202,6 +202,7 @@ BOOST_AUTO_TEST_CASE( Rotate ) BOOST_TEST_CONTEXT( "Class: " << item->GetClass() ) { // Four equivalent 90 degree rotations are an identity. + // (warning: only for items having no autoplaced fields). if( item->GetClass() == "SCH_SHEET_PIN" ) { @@ -212,6 +213,7 @@ BOOST_AUTO_TEST_CASE( Rotate ) if( schItem != nullptr ) { + schItem->ClearFieldsAutoplaced(); // Only rotating pins around the center of parent sheet works. schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() ); schItem->Rotate( m_sheet.GetBodyBoundingBox().GetCenter() ); @@ -286,10 +288,11 @@ BOOST_AUTO_TEST_CASE( MirrorHorizontally ) SCH_ITEM* schItem = dynamic_cast( item.get() ); LIB_ITEM* libItem = dynamic_cast( item.get() ); - // Two mirrorings are an identity. - + // Two mirrorings are an identity + // (warning: only for text items having no autoplaced fields). if( schItem != nullptr ) { + schItem->ClearFieldsAutoplaced(); schItem->MirrorHorizontally( aRef.x ); schItem->MirrorHorizontally( aRef.x ); } @@ -329,10 +332,12 @@ BOOST_AUTO_TEST_CASE( MirrorVertically ) SCH_ITEM* schItem = dynamic_cast( item.get() ); LIB_ITEM* libItem = dynamic_cast( item.get() ); - // Two mirrorings are an identity. + // Two mirrorings are an identity + // (warning only for text items having no autoplaced fields). if( schItem != nullptr ) { + schItem->ClearFieldsAutoplaced(); schItem->MirrorVertically( aRef.y ); schItem->MirrorVertically( aRef.y ); }