/**
 * Logistics server side
 */
package com.logistics.pvis.gui.guielement;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import org.junit.Before;
import org.junit.Test;

import com.logistics.pvis.gui.anchorpoint.AnchorPoint;

/**
 * @author Yifan
 *
 */
public class GuiElementDimensionImplTest {
	
	GuiElementDimension containerDimension;
	GuiElementDimension dimension;
	
	@Before
	public void setUp() {
		GuiElementDimension containerDimension = 
				mock(GuiElementDimension.class);
		when(containerDimension.getAbsoluteX()).thenReturn(100);
		when(containerDimension.getAbsoluteY()).thenReturn(200);
		when(containerDimension.getWidth()).thenReturn(1000);
		when(containerDimension.getHeight()).thenReturn(800);
		
		dimension = new GuiElementDimensionImpl();
		dimension.setContainerDimension(containerDimension);
		dimension.setRelativeX(10);
		dimension.setRelativeY(20);
		dimension.setWidth(30);
		dimension.setHeight(40);
	}

	@Test
	public void testGetAbsoluteDimensionTopLeft() {
		dimension.setAnchorPoint(AnchorPoint.TopLeft);
		assertEquals(110, dimension.getAbsoluteX());
		assertEquals(220, dimension.getAbsoluteY());
	}
	
	@Test
	public void testGetAbsoluteDimensionMiddleCenter() {
		dimension.setAnchorPoint(AnchorPoint.MiddleCenter);
		assertEquals(595, dimension.getAbsoluteX());
		assertEquals(600, dimension.getAbsoluteY());
	}
	
	@Test
	public void testGetAbsoluteDimensionBottomRight() {
		dimension.setAnchorPoint(AnchorPoint.BottomRight);
		assertEquals(1060, dimension.getAbsoluteX());
		assertEquals(940, dimension.getAbsoluteY());
	}
	
	@Test
	public void testGetAbsoluteDimensionRootContainer() {
		dimension.setContainerDimension(null);
		dimension.setAnchorPoint(AnchorPoint.BottomRight);
		assertEquals(10, dimension.getAbsoluteX());
		assertEquals(20, dimension.getAbsoluteY());
	}


}

@@ -187,24 +187,71 @@
 unit.Test;%0A%0A
+import com.logistics.pvis.dimension.Dimension;%0A
 import com.l
@@ -1887,12 +1887,251 @@
 ());%0A%09%7D%0A
+%09%0A%09@Test%0A%09public void testgetAbsoluteDimension() %7B%0A%09%09Dimension d = dimension.getAbsoluteDimension();%0A%09%09assertEquals(110, d.x, 1e-5);%0A%09%09assertEquals(220, d.y, 1e-5);%0A%09%09assertEquals(30, d.width, 1e-5);%0A%09%09assertEquals(40, d.height, 1e-5);%0A%09%7D%0A
 %0A%0A%7D%0A

Test getAbsoluteDimension