Compare commits
1 Commits
873f5d2711
...
a8b908ca1d
| Author | SHA1 | Date | |
|---|---|---|---|
| a8b908ca1d |
@@ -57,7 +57,7 @@ public class SText extends AbstractShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateMeasuredBounds(int width, int height) {
|
public void updateMeasuredBounds(int width, int height) {
|
||||||
getBounds().setSize(Math.max(width, 0), Math.max(height, 0));
|
bounds.setSize(Math.max(width, 0), Math.max(height, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,4 +44,40 @@ class STextTest {
|
|||||||
SText text = SText.create(0, 0, null);
|
SText text = SText.create(0, 0, null);
|
||||||
assertEquals(SText.PLACEHOLDER_TEXT, text.getText());
|
assertEquals(SText.PLACEHOLDER_TEXT, text.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpdateMeasuredBoundsActuallyUpdatesBounds() {
|
||||||
|
SText text = SText.create(10, 20, "Hello");
|
||||||
|
text.updateMeasuredBounds(200, 30);
|
||||||
|
Rectangle bounds = text.getBounds();
|
||||||
|
assertEquals(200, bounds.width, "updateMeasuredBounds must update width");
|
||||||
|
assertEquals(30, bounds.height, "updateMeasuredBounds must update height");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpdateMeasuredBoundsDoesNotChangePosition() {
|
||||||
|
SText text = SText.create(10, 20, "Hello");
|
||||||
|
text.updateMeasuredBounds(200, 30);
|
||||||
|
Rectangle bounds = text.getBounds();
|
||||||
|
assertEquals(10, bounds.x, "updateMeasuredBounds must not change x");
|
||||||
|
assertEquals(20, bounds.y, "updateMeasuredBounds must not change y");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpdateMeasuredBoundsNegativeClampedToZero() {
|
||||||
|
SText text = SText.create(0, 0, "Hello");
|
||||||
|
text.updateMeasuredBounds(-5, -10);
|
||||||
|
Rectangle bounds = text.getBounds();
|
||||||
|
assertEquals(0, bounds.width, "negative width must be clamped to 0");
|
||||||
|
assertEquals(0, bounds.height, "negative height must be clamped to 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testUpdateMeasuredBoundsZeroIsAllowed() {
|
||||||
|
SText text = SText.create(0, 0, "Hello");
|
||||||
|
text.updateMeasuredBounds(0, 0);
|
||||||
|
Rectangle bounds = text.getBounds();
|
||||||
|
assertEquals(0, bounds.width);
|
||||||
|
assertEquals(0, bounds.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user