|
|
|
|
@@ -44,4 +44,40 @@ class STextTest {
|
|
|
|
|
SText text = SText.create(0, 0, null);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|