Search in sources :

Example 1 with StyleObserver

use of limelight.styles.StyleObserver in project limelight by slagyr.

the class StyledTextTest method shouldBuildStyles.

@Test
public void shouldBuildStyles() throws Exception {
    makeSampleStyles();
    StyleObserver observer = new MockStyleObserver();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, observer);
    RichStyle style = styledText.getStyle();
    assertSame(style1, style.getExtention(0));
    assertSame(style2, style.getExtention(1));
    assertSame(defaultStyle, style.getExtention(2));
    assertEquals(true, style.hasObserver(observer));
}
Also used : RichStyle(limelight.styles.RichStyle) StyleObserver(limelight.styles.StyleObserver) Test(org.junit.Test)

Example 2 with StyleObserver

use of limelight.styles.StyleObserver in project limelight by slagyr.

the class StyledTextTest method shouldNotBuildStylesMoreThanOnce.

@Test
public void shouldNotBuildStylesMoreThanOnce() throws Exception {
    makeSampleStyles();
    StyleObserver observer = new MockStyleObserver();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, observer);
    styledText.setupStyles(styles, defaultStyle, observer);
    RichStyle style = styledText.getStyle();
    assertEquals(3, style.getExtentions().size());
    assertEquals(1, style.getObservers().size());
}
Also used : RichStyle(limelight.styles.RichStyle) StyleObserver(limelight.styles.StyleObserver) Test(org.junit.Test)

Example 3 with StyleObserver

use of limelight.styles.StyleObserver in project limelight by slagyr.

the class TextPanelTest method teardownStyledTextBeforeDiscarding.

@Test
public void teardownStyledTextBeforeDiscarding() throws Exception {
    panel.setText("Original Text", parent);
    Layouts.on(panel, panel.getDefaultLayout());
    List<StyleObserver> observers = panel.getStyle().getObservers();
    assertEquals(1, observers.size());
    StyleObserver observer = observers.get(0);
    Layouts.on(panel, panel.getDefaultLayout());
    List<StyleObserver> newObservers = panel.getStyle().getObservers();
    assertEquals(1, newObservers.size());
    StyleObserver newObserver = newObservers.get(0);
    assertNotSame(newObserver, observer);
}
Also used : StyleObserver(limelight.styles.StyleObserver) Test(org.junit.Test)

Aggregations

StyleObserver (limelight.styles.StyleObserver)3 Test (org.junit.Test)3 RichStyle (limelight.styles.RichStyle)2