Example #1
0
 /** @see junit.framework.TestCase#tearDown() */
 @Override
 protected void tearDown() throws Exception {
   lnf.setTheme(null);
   lnf.uninitialize();
   lnf = null;
   super.tearDown();
 }
Example #2
0
  /**
   * Test of the method <code>getTheme()</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testGetTheme() throws Exception {

    assertEquals(RienaDefaultTheme.class, lnf.getTheme().getClass());

    lnf.setTheme(new DummyTheme());
    assertEquals(DummyTheme.class, lnf.getTheme().getClass());
  }
Example #3
0
  /**
   * Test of the method <code>getFont(String)</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testGetFont() throws Exception {

    lnf.initialize();
    assertNull(lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND));
    assertNotNull(lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT));
    assertNull(lnf.getFont("dummy"));
  }
Example #4
0
  /** Tests the <i>private</i> method {@code readSystemProperties()}. */
  public void testReadSystemProperties() {

    lnf.setTheme(new DummyTheme());
    lnf.initialize();
    assertEquals(INTEGER_VALUE, lnf.getIntegerSetting(INTEGER_KEY));

    System.setProperty("riena.lnf.setting." + INTEGER_KEY, "4711");
    ReflectionUtils.invokeHidden(lnf, "readSystemProperties");
    assertEquals(Integer.valueOf(4711), lnf.getIntegerSetting(INTEGER_KEY));
  }
Example #5
0
  /**
   * Test of the method {@code getIntegerSetting(String, Integer)}.
   *
   * @throws Exception handled by JUnit
   */
  public void testGetIntegerSetting() throws Exception {

    Integer value = lnf.getIntegerSetting(INTEGER_KEY, 300);
    assertEquals(300, value.intValue());

    lnf.setTheme(new DummyTheme());
    lnf.initialize();
    value = lnf.getIntegerSetting(INTEGER_KEY, 300);
    assertEquals(INTEGER_VALUE.intValue(), value.intValue());
  }
Example #6
0
  /**
   * Test of the method {@code getBooleanSetting(String, boolean)}.
   *
   * @throws Exception handled by JUnit
   */
  public void testGetBooleanSetting() throws Exception {

    boolean value = lnf.getBooleanSetting(BOOLEAN_KEY, true);
    assertTrue(value);
    value = lnf.getBooleanSetting(BOOLEAN_KEY, false);
    assertFalse(value);

    lnf.setTheme(new DummyTheme());
    lnf.initialize();
    value = lnf.getBooleanSetting(BOOLEAN_KEY, false);
    assertEquals(BOOLEAN_VALUE, value);
  }
Example #7
0
  /**
   * Test of the method <code>setTheme()</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testSetTheme() throws Exception {

    final Color color1 = lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND);
    assertNotNull(color1);

    lnf.setTheme(new DummyTheme());
    lnf.initialize();
    assertFalse(color1.isDisposed());

    final Color color2 = lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND);
    assertNull(color2);
  }
Example #8
0
  /**
   * Creates a new {@link FontLnfResource} and adds it to the {@link RienaDefaultLnf}. So next time,
   * a fontDescriptor with this key will be used to fetch the font, the cached instance will be
   * returned.
   *
   * @return the font defined by this descriptor or <code>null</code> if no registered font can be
   *     found by the lnfKeyConstants key.
   */
  private Font updateFont() {
    if (key == null) {
      return null;
    }

    final Font font = lnf.getFont(key);
    if (font == null || font.getFontData().length == 0) {
      return null;
    }

    final String fontName = font.getFontData()[0].getName();
    final FontData fontData = new FontData(fontName, height, style);
    final FontLnfResource fontResource = new FontLnfResource(fontData);
    lnf.putLnfResource(this.toString(), fontResource);
    return getFont();
  }
Example #9
0
 public Font getFont() {
   final Font font = lnf.getFont(this.toString());
   if (font != null) {
     return font;
   } else {
     return updateFont();
   }
 }
Example #10
0
  /**
   * Test of the method <code>getFont(String, int, int)</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testGetFontWithProps() throws Exception {

    lnf.initialize();
    final Font font =
        lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT, 10, SWT.BOLD | SWT.ITALIC);
    FontData data = font.getFontData()[0];
    assertEquals(SWT.BOLD | SWT.ITALIC, data.getStyle());

    final Font font1 = lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT, 12, SWT.BOLD);
    data = font1.getFontData()[0];
    assertEquals(SWT.BOLD, data.getStyle());

    final Font font2 = lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT, 12, SWT.BOLD);
    assertSame(font1, font2);

    final Font fontNull =
        lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND, 12, SWT.BOLD);
    assertNull(fontNull);
  }
Example #11
0
  /**
   * Test of the method <code>initialize()</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testInitialize() throws Exception {

    lnf.uninitialize();

    assertNull(lnf.getRenderer(LnfKeyConstants.SUB_MODULE_VIEW_BORDER_RENDERER));
    assertNull(lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT));
    assertNull(lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND));

    lnf.initialize();

    assertNotNull(lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT));
    assertNotNull(lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND));
  }
Example #12
0
  /** Tests the method {@code getMarkerSupport}. */
  public void testGetMarkerSupport() {

    lnf.update(
        new ILnfMarkerSupportExtension[] {
          new ILnfMarkerSupportExtension() {
            public String getId() {
              return "defaultMarkerSupport";
            }

            public AbstractMarkerSupport createMarkerSupport() {
              return new MarkerSupport();
            }
          },
          new ILnfMarkerSupportExtension() {
            public String getId() {
              return "borderMarkerSupport";
            }

            public AbstractMarkerSupport createMarkerSupport() {
              return new BorderMarkerSupport();
            }
          }
        });

    AbstractMarkerSupport markerSupport = lnf.getMarkerSupport(null);
    assertNotNull(markerSupport);
    assertTrue(markerSupport.getClass() == BorderMarkerSupport.class);

    lnf.setTheme(new DummyTheme());
    lnf.initialize();
    markerSupport = lnf.getMarkerSupport(null);
    assertNull(markerSupport);

    lnf.setTheme(new DummyTheme2());
    lnf.initialize();
    markerSupport = lnf.getMarkerSupport(null);
    assertNotNull(markerSupport);
    assertTrue(markerSupport.getClass() == BorderMarkerSupport.class);
  }
Example #13
0
  /**
   * Test of the method <code>uninitialize()</code>.
   *
   * @throws Exception handled by JUnit
   */
  public void testUninitialize() throws Exception {

    final Color color = lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND);
    assertNotNull(color);
    final Font font = lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT);
    assertNotNull(font);

    lnf.uninitialize();

    assertFalse(font.isDisposed());
    assertNull(lnf.getFont(LnfKeyConstants.EMBEDDED_TITLEBAR_FONT));
    assertFalse(color.isDisposed());
    assertNull(lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND));
    assertNotSame(
        color,
        lnf.getColor(LnfKeyConstants.EMBEDDED_TITLEBAR_ACTIVE_FOREGROUND)); // TODO Could be removed
  }
Example #14
0
 /**
  * @return the default height of the font from the lnf by <code>
  *     LnfKeyConstants.FONTDESCRIPTOR_DEFAULT_HEIGHT</code>.
  */
 protected Integer getDefaultHeight() {
   return lnf.getIntegerSetting(LnfKeyConstants.FONTDESCRIPTOR_DEFAULT_HEIGHT);
 }
Example #15
0
 /** @see junit.framework.TestCase#setUp() */
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   lnf = new RienaDefaultLnf();
   lnf.initialize();
 }