package no.agens.cassowarylayout.util;

import android.test.AndroidTestCase;
import android.util.TypedValue;

/**
 * Created by alex on 09/09/2014.
 */
public class DimensionParserTest extends AndroidTestCase {

    public void testWrapContent() {
        assertEquals(-2, (int)DimensionParser.getDimension("wrapContent", getContext()));
    }

    public void testMatchParent() {
        assertEquals(-1, (int)DimensionParser.getDimension("matchParent", getContext()));
    }

    public void test10dp() {
        int expectedResult = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getContext().getResources().getDisplayMetrics());
        assertEquals(expectedResult, (int)DimensionParser.getDimension("10dp", getContext()));
    }

    public void test10px() {
        int expectedResult = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, 10, getContext().getResources().getDisplayMetrics());
        assertEquals(expectedResult, (int)DimensionParser.getDimension("10px", getContext()));
    }

    public void test10sp() {
        int expectedResult = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10, getContext().getResources().getDisplayMetrics());
        assertEquals(expectedResult, (int)DimensionParser.getDimension("10sp", getContext()));
    }

    public void test10mm() {
        int expectedResult = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 10, getContext().getResources().getDisplayMetrics());
        assertEquals(expectedResult, (int)DimensionParser.getDimension("10mm", getContext()));
    }

}

@@ -264,23 +264,19 @@
 quals(-2
+D
 , 
-(int)
 Dimensio
@@ -393,23 +393,19 @@
 quals(-1
+D
 , 
-(int)
 Dimensio
@@ -492,35 +492,38 @@
 0dp() %7B%0A        
-int
+double
  expectedResult 
@@ -516,37 +516,32 @@
 xpectedResult = 
-(int)
 TypedValue.apply
@@ -662,37 +662,32 @@
 expectedResult, 
-(int)
 DimensionParser.
@@ -759,35 +759,38 @@
 0px() %7B%0A        
-int
+double
  expectedResult 
@@ -783,37 +783,32 @@
 xpectedResult = 
-(int)
 TypedValue.apply
@@ -928,37 +928,32 @@
 expectedResult, 
-(int)
 DimensionParser.
@@ -1025,35 +1025,38 @@
 0sp() %7B%0A        
-int
+double
  expectedResult 
@@ -1049,37 +1049,32 @@
 xpectedResult = 
-(int)
 TypedValue.apply
@@ -1194,37 +1194,32 @@
 expectedResult, 
-(int)
 DimensionParser.
@@ -1299,19 +1299,22 @@
         
-int
+double
  expecte
@@ -1323,21 +1323,16 @@
 esult = 
-(int)
 TypedVal
@@ -1472,13 +1472,8 @@
 lt, 
-(int)
 Dime

Fix DimensionParserTests