From 3d72b245f992db8b8ff070623accd3a7845c0d3c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 1 Oct 2025 09:22:46 +0200 Subject: [PATCH] Try to fix QA pcbnew tests. --- qa/tests/pcbnew/test_barcode_load_save.cpp | 17 ++++++++++------- qa/tests/pcbnew/test_board_item.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/qa/tests/pcbnew/test_barcode_load_save.cpp b/qa/tests/pcbnew/test_barcode_load_save.cpp index 9eb4f8b03f..f8ffa4378f 100644 --- a/qa/tests/pcbnew/test_barcode_load_save.cpp +++ b/qa/tests/pcbnew/test_barcode_load_save.cpp @@ -43,9 +43,9 @@ BOOST_AUTO_TEST_CASE( BarcodeWriteRead ) PCB_BARCODE* barcode = new PCB_BARCODE( board.get() ); barcode->SetText( wxT( "12345" ) ); barcode->SetLayer( F_SilkS ); - barcode->SetPosition( VECTOR2I( 1000000, 2000000 ) ); - barcode->SetWidth( 3000000 ); - barcode->SetHeight( 3000000 ); + barcode->SetPosition( VECTOR2I( pcbIUScale.mmToIU( 1.0 ), pcbIUScale.mmToIU( 2.0 ) ) ); + barcode->SetWidth( pcbIUScale.mmToIU( 3.0 ) ); + barcode->SetHeight( pcbIUScale.mmToIU( 3.0 ) ); barcode->SetTextSize( pcbIUScale.mmToIU( 1.5 ) ); barcode->SetKind( BARCODE_T::QR_CODE ); barcode->SetErrorCorrection( BARCODE_ECC_T::M ); @@ -71,8 +71,9 @@ BOOST_AUTO_TEST_CASE( BarcodeWriteRead ) BOOST_CHECK_EQUAL( loaded.GetWidth(), barcode->GetWidth() ); BOOST_CHECK_EQUAL( loaded.GetHeight(), barcode->GetHeight() ); BOOST_CHECK_EQUAL( loaded.GetTextSize(), barcode->GetTextSize() ); + BOOST_CHECK_EQUAL( loaded.GetPosition(), barcode->GetPosition() ); - BOX2I bbox = loaded.GetPolyShape().BBox(); + BOX2I bbox = loaded.GetSymbolPoly().BBox(); BOOST_CHECK_EQUAL( bbox.Centre(), loaded.GetPosition() ); } @@ -124,8 +125,9 @@ BOOST_AUTO_TEST_CASE( BarcodeFootprintWriteRead ) BOOST_CHECK_EQUAL( loaded->GetWidth(), barcode->GetWidth() ); BOOST_CHECK_EQUAL( loaded->GetHeight(), barcode->GetHeight() ); BOOST_CHECK_EQUAL( loaded->GetTextSize(), barcode->GetTextSize() ); + BOOST_CHECK_EQUAL( loaded->GetPosition(), barcode->GetPosition() ); - BOX2I bbox = loaded->GetPolyShape().BBox(); + BOX2I bbox = loaded->GetSymbolPoly().BBox(); BOOST_CHECK_EQUAL( bbox.Centre(), loaded->GetPosition() ); } @@ -188,6 +190,7 @@ BOOST_AUTO_TEST_CASE( BarcodePositioningAlignment ) barcode->SetErrorCorrection( BARCODE_ECC_T::M ); barcode->Text().SetVisible( tc.withText ); barcode->SetIsKnockout( tc.knockout ); + barcode->AssembleBarcode( true, true ); if( tc.angle != 0.0 ) { @@ -196,8 +199,8 @@ BOOST_AUTO_TEST_CASE( BarcodePositioningAlignment ) barcode->AssembleBarcode( true, true ); - // Check that the polygon center matches the position - BOX2I bbox = barcode->GetPolyShape().BBox(); + // Check that the bar code polygon center matches the position + BOX2I bbox = barcode->GetSymbolPoly().BBox(); VECTOR2I actualCenter = bbox.GetCenter(); VECTOR2I expectedCenter = barcode->GetPosition(); diff --git a/qa/tests/pcbnew/test_board_item.cpp b/qa/tests/pcbnew/test_board_item.cpp index b321a2f072..9da790253a 100644 --- a/qa/tests/pcbnew/test_board_item.cpp +++ b/qa/tests/pcbnew/test_board_item.cpp @@ -82,7 +82,13 @@ public: case PCB_PAD_T: return new PAD( &m_footprint ); case PCB_FIELD_T: return new PCB_FIELD( &m_footprint, FIELD_T::USER ); case PCB_SHAPE_T: return new PCB_SHAPE( &m_board ); - case PCB_BARCODE_T: return new PCB_BARCODE( &m_board ); + case PCB_BARCODE_T: + { + PCB_BARCODE* barcode = new PCB_BARCODE( &m_board ); + barcode->SetText( "XXXX" ); + barcode->AssembleBarcode( true, true ); + return barcode; + } case PCB_TEXT_T: return new PCB_TEXT( &m_board ); case PCB_TEXTBOX_T: return new PCB_TEXTBOX( &m_board ); case PCB_TABLECELL_T: return new PCB_TABLECELL( &m_board );