public void testRemoveRedundantTagsFromDoc() throws BadLocationException { m_doc.insertString(0, "Foobar", SimpleAttributeSet.EMPTY); SimpleAttributeSet actualAttr = new SimpleAttributeSet(); actualAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE); m_doc.setCharacterAttributes(1, 2, actualAttr, true); actualAttr = new SimpleAttributeSet(); actualAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE); m_doc.setCharacterAttributes(3, 2, actualAttr, true); assertEquals("F<b>ooba</b>r", FormattedText.formatted(m_doc).getFormatted()); }
public void testRemoveRedundantTagsFromEncoding() throws BadLocationException { StyledDocument doc = FormattedText.formatted("F<b>oo</b><b>ba</b>r").getDocument(); assertEquals("F<b>ooba</b>r", FormattedText.formatted(doc).getFormatted()); }
public void testEscapeCharsThatAreUsedForMarkupInUnformattedText() throws BadLocationException { FormattedText fText = FormattedText.unformatted("Foo<b>ba</b>r"); assertEquals("Foo<b>ba</b>r", fText.getUnformatted()); }
public void testEscapeCharsThatAreUsedForMarkupInDocumentText() throws BadLocationException { m_doc.insertString(0, "Foo<b>ba</b>r", SimpleAttributeSet.EMPTY); String encoding = FormattedText.formatted(m_doc).getFormatted(); assertEquals("Foo<b>ba</b>r", FormattedText.formatted(encoding).getUnformatted()); }
private static StyledDocument roundtrip(StyledDocument doc) { String encoding = FormattedText.formatted(doc).getFormatted(); return FormattedText.formatted(encoding).getDocument(); }