DimensionResource { public float toFloat(DisplayMetrics metrics) { return TypedValue.applyDimension(type, value, metrics); } DimensionResource(int type, float value); static DimensionResource fromString(@NonNull String resource); float toFloat(DisplayMetrics metrics);  }
@Test public void testToFloat() throws Exception { resource = new DimensionResource(TypedValue.COMPLEX_UNIT_DIP, 2.0f); DisplayMetrics metrics = new DisplayMetrics(); metrics.density = 200; assertTrue(resource.toFloat(metrics) == 400.0f); }