public void testGetPropertyPrefix() {
assertEquals("TextPane", ui.getPropertyPrefix());
}
public void testPropertyChange() throws BadLocationException {
Style style = textPane.getStyle(StyleContext.DEFAULT_STYLE);
//Font
assertFalse(25 == ((Integer) style.getAttribute(StyleConstants.FontSize)).intValue());
textPane.setFont(font);
assertEquals(25, ((Integer) style.getAttribute(StyleConstants.FontSize)).intValue());
assertEquals(font.getName(), style.getAttribute(StyleConstants.FontFamily));
assertFalse(font.getFontName().equals(style.getAttribute(StyleConstants.FontFamily)));
assertEquals(font.getName(), style.getAttribute(StyleConstants.FontFamily));
// Foreground
assertFalse(Color.BLUE.equals(style.getAttribute(StyleConstants.Foreground)));
textPane.setForeground(Color.BLUE);
assertEquals(Color.BLUE, style.getAttribute(StyleConstants.Foreground));
// Document
style.addAttribute(StyleConstants.Subscript, Boolean.TRUE);
StyledDocument newDoc = new DefaultStyledDocument();
Style newStyle = newDoc.getStyle(StyleContext.DEFAULT_STYLE);
assertNull(newStyle.getAttribute(StyleConstants.FontSize));
assertNull(newStyle.getAttribute(StyleConstants.FontFamily));
newStyle.addAttribute(StyleConstants.FontFamily, "family2");
newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
textPane.setDocument(newDoc);
assertNotSame(style, newStyle);
assertEquals(25, ((Integer) newStyle.getAttribute(StyleConstants.FontSize)).intValue());
assertEquals(font.getName(), newStyle.getAttribute(StyleConstants.FontFamily));
assertEquals(Boolean.TRUE, newStyle.getAttribute(StyleConstants.Italic));
assertEquals(Boolean.TRUE, newStyle.getAttribute(StyleConstants.Bold));
assertEquals(Boolean.TRUE, newStyle.getAttribute(StyleConstants.StrikeThrough));
assertEquals(Boolean.FALSE, newStyle.getAttribute(StyleConstants.Subscript));
assertEquals(Color.BLUE, newStyle.getAttribute(StyleConstants.Foreground));
}