BoxFitterTest: put existing tests inside a nest
This commit is contained in:
parent
b215021eee
commit
9f9797dcbd
1 changed files with 65 additions and 58 deletions
|
@ -2,6 +2,7 @@ package net.kemitix.text.fit;
|
|||
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.*;
|
||||
|
@ -22,20 +23,25 @@ public class BoxFitterTest
|
|||
implements WithAssertions {
|
||||
|
||||
private final BoxFitter boxFitter = TextFit.fitter();
|
||||
private final int imageSize = 300;
|
||||
private final int fontSize = 20;
|
||||
private final Graphics2D graphics2D = graphics(imageSize, imageSize);
|
||||
private final Font font;
|
||||
private Function<Integer, Font> fontFactory;
|
||||
private Rectangle2D box = new Rectangle(imageSize, imageSize);
|
||||
|
||||
public BoxFitterTest() throws URISyntaxException, IOException, FontFormatException {
|
||||
URL resource = this.getClass().getResource("alice/Alice-Regular.ttf");
|
||||
int initialFontSize = 20;
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, new File(resource.toURI()))
|
||||
.deriveFont(Font.PLAIN, fontSize);
|
||||
.deriveFont(Font.PLAIN, initialFontSize);
|
||||
fontFactory = size -> font.deriveFont(Font.PLAIN, size);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Single Box")
|
||||
public class SingleBox {
|
||||
|
||||
private final int imageSize = 300;
|
||||
private final Graphics2D graphics2D = graphics(imageSize, imageSize);
|
||||
private Rectangle2D box = new Rectangle(imageSize, imageSize);
|
||||
|
||||
@Test
|
||||
@DisplayName("Fit single words")
|
||||
public void fitSingleWord() {
|
||||
|
@ -93,6 +99,7 @@ public class BoxFitterTest
|
|||
private int invoke(String longText) {
|
||||
return boxFitter.fit(longText, fontFactory, graphics2D, box);
|
||||
}
|
||||
}
|
||||
|
||||
private String longStringGenerator(int cycles) {
|
||||
String text = "This is a long piece of text that should result in an " +
|
||||
|
|
Loading…
Reference in a new issue