package de.lessvoid.nifty.elements.render;

import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import junit.framework.TestCase;
import de.lessvoid.nifty.layout.align.HorizontalAlign;
import de.lessvoid.nifty.layout.align.VerticalAlign;
import de.lessvoid.nifty.spi.render.RenderFont;

public class TextRendererTest extends TestCase {

  private RenderFont renderFont;

  public void setUp() {
    renderFont = createMock(RenderFont.class);
    expect(renderFont.getHeight()).andReturn(10).anyTimes();
    expect(renderFont.getWidth(isA(String.class))).andReturn(0).anyTimes();
    replay(renderFont);
  }

  public void testInit() {
    TextRenderer render = new TextRenderer(null, renderFont, "a\nc");
    assertEquals( 20, render.getTextHeight());
    assertEquals( 0, render.getTextWidth());
    verify(renderFont);
  }

  public void testGetStartYWithVerticalAlignTop() {
    assertEquals(0, TextRenderer.getStartYWithVerticalAlign(100, 200, VerticalAlign.top));
  }

  public void testGetStartYWithVerticalAlignBottom() {
    assertEquals(100, TextRenderer.getStartYWithVerticalAlign(100, 200, VerticalAlign.bottom));
  }

  public void testGetStartYWithVerticalAlignCenter() {
    assertEquals(50, TextRenderer.getStartYWithVerticalAlign(100, 200, VerticalAlign.center));
  }

  public void testGetStartYWithVerticalAlignDefault() {
    assertEquals(0, TextRenderer.getStartYWithVerticalAlign(100, 200, null));
  }

  public void testGetStartXWithHorizontalAlignLeft() {
    assertEquals(0, TextRenderer.getStartXWithHorizontalAlign(100, 200, HorizontalAlign.left));
  }

  public void testGetStartXWithHorizontalAlignRight() {
    assertEquals(100, TextRenderer.getStartXWithHorizontalAlign(100, 200, HorizontalAlign.right));
  }

  public void testGetStartXWithHorizontalAlignCenter() {
    assertEquals(50, TextRenderer.getStartXWithHorizontalAlign(100, 200, HorizontalAlign.center));
  }

  public void testGetStartXWithHorizontalAlignDefault() {
    assertEquals(0, TextRenderer.getStartXWithHorizontalAlign(100, 200, null));
  }
}

@@ -70,27 +70,38 @@
 ock.
-EasyMock.createMock
+classextension.EasyMock.expect
 ;%0D%0Ai
@@ -118,32 +118,47 @@
 ic org.easymock.
+classextension.
 EasyMock.expect;
@@ -142,38 +142,35 @@
 ension.EasyMock.
-expect
+isA
 ;%0D%0Aimport static
@@ -175,32 +175,47 @@
 ic org.easymock.
+classextension.
 EasyMock.isA;%0D%0Ai
@@ -199,35 +199,38 @@
 ension.EasyMock.
-isA
+replay
 ;%0D%0Aimport static
@@ -235,32 +235,47 @@
 ic org.easymock.
+classextension.
 EasyMock.replay;
@@ -259,37 +259,37 @@
 ension.EasyMock.
-repla
+verif
 y;%0D%0Aimport stati
@@ -303,31 +303,50 @@
 asymock.
-EasyMock.verify
+classextension.EasyMock.createMock
 ;%0D%0Aimpor
@@ -374,16 +374,49 @@
 tCase;%0D%0A
+import de.lessvoid.nifty.Nifty;%0D%0A
 import d
@@ -924,24 +924,169 @@
 stInit() %7B%0D%0A
+    Nifty niftyMock = createMock(Nifty.class);%0D%0A    expect(niftyMock.specialValuesReplace(%22a%5Cnc%22)).andReturn(%22a%5Cnc%22);%0D%0A    replay(niftyMock);%0D%0A%0D%0A
     TextRend
@@ -1117,19 +1117,24 @@
 nderer(n
-ull
+iftyMock
 , render
@@ -1239,24 +1239,26 @@
 tWidth());%0D%0A
+%0D%0A
     verify(r
@@ -1262,32 +1262,56 @@
 y(renderFont);%0D%0A
+    verify(niftyMock);%0D%0A
   %7D%0D%0A%0D%0A  public 

fix test bug