@Test public void givenSquareFollowedBySingleSpace_whenSplittingWithinSpace_shouldKeepSpaceOnFirstLine() throws Exception { final List<IInlineBox> boxes = boxes(staticText("Lorem "), square(15), staticText(" ")); layout(boxes); final int widthOfHeadBoxes = boxes.get(0).getWidth() + boxes.get(1).getWidth(); lines.arrangeBoxes(graphics, boxes.listIterator(), widthOfHeadBoxes + 1, TextAlign.LEFT); assertEquals(1, lines.getLines().size()); assertEquals(boxes.get(2), lines.getLines().iterator().next().getLastChild()); }
@Test public void givenInlineContainerFollowedByTextThatStartsWithSpace_whenSplittingWithinText_shouldSplitAfterSpace() throws Exception { final List<IInlineBox> boxes = boxes(staticText("Lorem "), inlineContainer(staticText("ipsum")), staticText(" dolor")); layout(boxes); final int widthOfHeadBoxes = boxes.get(0).getWidth() + boxes.get(1).getWidth(); lines.arrangeBoxes(graphics, boxes.listIterator(), widthOfHeadBoxes + 10, TextAlign.LEFT); assertEquals(2, lines.getLines().size()); assertEquals(" ", ((StaticText) lines.getLines().iterator().next().getLastChild()).getText()); }
@Test public void givenAllBoxesFitIntoOneLine_shouldArrangeBoxesInOneLine() throws Exception { lines.arrangeBoxes(graphics, joinableBoxes.listIterator(), 210, TextAlign.LEFT); assertEquals(1, lines.getLines().size()); }