示例#1
0
  @Test
  public void shouldTeardownStyles() throws Exception {
    makeSampleStyles();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, new MockStyleObserver());

    styledText.teardownStyles();

    RichStyle style = styledText.getStyle();
    assertEquals(false, style1.hasObserver(style));
    assertEquals(false, style2.hasObserver(style));
    assertEquals(false, defaultStyle.hasObserver(style));
  }
示例#2
0
  @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());
  }
示例#3
0
  @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));
  }
示例#4
0
  private void createStyles() {
    root.setStyles(new HashMap<String, RichStyle>());
    RichStyle myStyle = new RichStyle();
    root.getStyles().put("my_style", myStyle);
    myStyle.setFontFace("Helvetica");
    myStyle.setFontStyle("bold");
    myStyle.setFontSize("20");
    myStyle.setTextColor("red");

    RichStyle myOtherStyle = new RichStyle();
    root.getStyles().put("my_other_style", myOtherStyle);
    myOtherStyle.setFontFace("Cuneiform");
    myOtherStyle.setFontStyle("italic");
    myOtherStyle.setFontSize("19");
    myOtherStyle.setTextColor("blue");

    RichStyle sizeOnlyStyle = new RichStyle();
    root.getStyles().put("size_only_style", sizeOnlyStyle);
    sizeOnlyStyle.setFontSize("25");
  }