KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_autoplace_fields.cpp File Reference

Test suite for autoplace fields functionality. More...

Go to the source code of this file.

Classes

class  TEST_AUTOPLACE_FIELDS_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (RotatedSymbolFieldBoundingBox)
 Test that field bounding boxes for rotated symbols have correct dimensions.
 
 BOOST_AUTO_TEST_CASE (FieldDrawRotationForRotatedSymbol)
 Test that GetDrawRotation returns correct visual orientation.
 
 BOOST_AUTO_TEST_CASE (RotatedSymbolFieldAngleForHorizontalDisplay)
 Regression test for issue #22927.
 
 BOOST_AUTO_TEST_CASE (RotatedSymbolBBoxAngleEffects)
 Verify that HORIZONTAL and VERTICAL field angles produce different bbox shapes on a 90-degree rotated symbol.
 
 BOOST_AUTO_TEST_CASE (RotatedSymbolFieldSizingDimensions)
 Regression test for issue #23032.
 

Detailed Description

Test suite for autoplace fields functionality.

Definition in file test_autoplace_fields.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( FieldDrawRotationForRotatedSymbol )

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( RotatedSymbolBBoxAngleEffects )

Verify that HORIZONTAL and VERTICAL field angles produce different bbox shapes on a 90-degree rotated symbol.

HORIZONTAL field angle + 90-degree symbol transform results in a visually vertical bbox. VERTICAL field angle + 90-degree transform produces a 180-degree net rotation, giving dimensions matching horizontal display.

Definition at line 210 of file test_autoplace_fields.cpp.

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BOOST_REQUIRE(), SCH_FIELD::GetBoundingBox(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), REFERENCE, and EDA_TEXT::SetTextAngle().

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( RotatedSymbolFieldAngleForHorizontalDisplay )

Regression test for issue #22927.

The autoplacer must set field angles so that GetDrawRotation() returns HORIZONTAL for all symbol orientations. For 90/270-degree rotated symbols, the stored angle should be VERTICAL (counteracting the symbol's transform).

Definition at line 158 of file test_autoplace_fields.cpp.

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, EDA_ANGLE::AsDegrees(), BOOST_REQUIRE(), SCH_FIELD::GetDrawRotation(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), SYMBOL::GetTransform(), EDA_ANGLE::IsHorizontal(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), REFERENCE, EDA_TEXT::SetTextAngle(), and TRANSFORM::y1.

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( RotatedSymbolFieldBoundingBox )

Test that field bounding boxes for rotated symbols have correct dimensions.

This is a regression test for issue #16538.

The bug was that when computing field bounding boxes for autoplace, the code set field text angle to ANGLE_VERTICAL for 90/270 degree rotated symbols. However, GetBoundingBox() applies BOTH the field angle AND the symbol transform, resulting in 180-degree effective rotation (field angle + symbol transform). This caused the bounding box dimensions to be incorrect.

The fix sets field text angle to ANGLE_HORIZONTAL, so that GetBoundingBox() applies only the symbol transform (90 degrees), giving correct dimensions for vertical text display.

Definition at line 81 of file test_autoplace_fields.cpp.

References ANGLE_HORIZONTAL, BOOST_AUTO_TEST_CASE(), BOOST_REQUIRE(), SCH_FIELD::GetBoundingBox(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), BOX2< Vec >::GetHeight(), SYMBOL::GetTransform(), BOX2< Vec >::GetWidth(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), REFERENCE, EDA_TEXT::SetTextAngle(), and TRANSFORM::y1.

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( RotatedSymbolFieldSizingDimensions )

Regression test for issue #23032.

The autoplacer uses the display angle (VERTICAL for 90/270, HORIZONTAL for 0/180) when computing field bounding boxes for sizing. This ensures consistent field spacing regardless of symbol rotation. Using HORIZONTAL for all orientations (the previous bug) produced swapped width/height for 90/270 symbols, causing wrong vertical spacing.

Definition at line 260 of file test_autoplace_fields.cpp.

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BOOST_REQUIRE(), SCH_FIELD::GetBoundingBox(), KI_TEST::GetEeschemaTestDataDir(), SCH_SYMBOL::GetField(), BOX2< Vec >::GetHeight(), SYMBOL::GetTransform(), BOX2< Vec >::GetWidth(), FILEEXT::KiCadSchematicFileExtension, LoadSchematic(), REFERENCE, EDA_TEXT::SetTextAngle(), and TRANSFORM::y1.