aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2011-01-18 16:40:13 +0000
committerJeremias Maerki <jeremias@apache.org>2011-01-18 16:40:13 +0000
commitd3d628c0b698ca5dfe7e7246028bad9634882d82 (patch)
tree88715ef0643a71b74534b4df0d9e9fc83b665a2a /test
parent463d94cbe9455244e1c52187a5ed8436d9479b71 (diff)
downloadxmlgraphics-fop-d3d628c0b698ca5dfe7e7246028bad9634882d82.tar.gz
xmlgraphics-fop-d3d628c0b698ca5dfe7e7246028bad9634882d82.zip
Removed FopFactory.getColorSpace() in favor of FopFactory.getColorSpaceCache() to better follow the pattern we use for the FontManager and ImageManager.
Increased accuracy for sRGB derivation. Fixed some tests. Fixed bug in ColorUtil.toSRGBColor(). Documented inconsistency inside java.awt.Color in ColorUtilTest. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@1060457 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/java/org/apache/fop/traits/BorderPropsTestCase.java5
-rw-r--r--test/java/org/apache/fop/util/ColorUtilTestCase.java24
2 files changed, 23 insertions, 6 deletions
diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java
index 6eb41daac..07e4cd68c 100644
--- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java
+++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java
@@ -23,7 +23,7 @@ import java.awt.Color;
import junit.framework.TestCase;
-import org.apache.xmlgraphics.java2d.color.ColorSpaces;
+import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives;
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace;
import org.apache.fop.fo.Constants;
@@ -51,6 +51,9 @@ public class BorderPropsTestCase extends TestCase {
float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f};
col = DeviceCMYKColorSpace.createCMYKColor(cmyk);
+ //Convert to sRGB with CMYK alternative as constructed by the cmyk() function
+ float[] rgb = col.getRGBColorComponents(null);
+ col = new ColorWithAlternatives(rgb[0], rgb[1], rgb[2], new Color[] {col});
b1 = new BorderProps(Constants.EN_INSET, 9999,
col, BorderProps.SEPARATE);
ser = b1.toString();
diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java
index d0b6cc79a..c466b6cc6 100644
--- a/test/java/org/apache/fop/util/ColorUtilTestCase.java
+++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java
@@ -118,8 +118,8 @@ public class ColorUtilTestCase extends TestCase {
FopFactory fopFactory = FopFactory.newInstance();
URI sRGBLoc = new URI(
"file:src/java/org/apache/fop/pdf/sRGB%20Color%20Space%20Profile.icm");
- ColorSpace cs = fopFactory.getColorSpace("sRGBAlt", null, sRGBLoc.toASCIIString(),
- RenderingIntent.AUTO);
+ ColorSpace cs = fopFactory.getColorSpaceCache().get(
+ "sRGBAlt", null, sRGBLoc.toASCIIString(), RenderingIntent.AUTO);
assertNotNull("Color profile not found", cs);
FOUserAgent ua = fopFactory.newFOUserAgent();
@@ -194,7 +194,7 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(0.2196f, comps[1], 0.001);
assertEquals(0.3216f, comps[2], 0.001);
assertEquals(0f, comps[3], 0);
- assertEquals("fop-rgb-icc(0.972549,0.78039217,0.6745098,#CMYK,,0.0274,0.2196,0.3216,0.0)",
+ assertEquals("fop-rgb-icc(0.9726,0.7804,0.67840004,#CMYK,,0.0274,0.2196,0.3216,0.0)",
ColorUtil.colorToString(colActual));
colSpec = "fop-rgb-icc(1.0,1.0,0.0,#CMYK,,0.0,0.0,1.0,0.0)";
@@ -228,6 +228,20 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(0.5f, comps[3], 0);
assertEquals("fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)",
ColorUtil.colorToString(colActual));
+
+ //Verify that the cmyk() and fop-rgb-icc(#CMYK) functions have the same results
+ ColorWithAlternatives colCMYK = (ColorWithAlternatives)ColorUtil.parseColorString(
+ null, "cmyk(0,0,0,0.5)");
+ assertEquals(colCMYK.getAlternativeColors()[0], colActual.getAlternativeColors()[0]);
+ //The following doesn't work:
+ //assertEquals(colCMYK, colActual);
+ //java.awt.Color does not consistenly calculate the int RGB values:
+ //Color(ColorSpace cspace, float components[], float alpha): 0.5 --> 127
+ //Color(float r, float g, float b): 0.5 --> 128
+ if (!colCMYK.equals(colActual)) {
+ System.out.println("Info: java.awt.Color does not consistently calculate"
+ + " int RGB values from float RGB values.");
+ }
}
/**
@@ -270,8 +284,8 @@ public class ColorUtilTestCase extends TestCase {
public void testNamedColorProfile() throws Exception {
FopFactory fopFactory = FopFactory.newInstance();
URI ncpLoc = new URI("file:test/resources/color/ncp-example.icc");
- ColorSpace cs = fopFactory.getColorSpace("NCP", null, ncpLoc.toASCIIString(),
- RenderingIntent.AUTO);
+ ColorSpace cs = fopFactory.getColorSpaceCache().get(
+ "NCP", null, ncpLoc.toASCIIString(), RenderingIntent.AUTO);
assertNotNull("Color profile not found", cs);
FOUserAgent ua = fopFactory.newFOUserAgent();