aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-11-25 14:42:48 +0000
committerJeremias Maerki <jeremias@apache.org>2009-11-25 14:42:48 +0000
commita3b7f647e5753c7d0ca271993190a78ef9233887 (patch)
tree9db0233b5dc7738377feab7250daf9bb83cd56e3 /test
parentd61456f236d52c5d828b12d0ff684688d297b41b (diff)
downloadxmlgraphics-fop-a3b7f647e5753c7d0ca271993190a78ef9233887.tar.gz
xmlgraphics-fop-a3b7f647e5753c7d0ca271993190a78ef9233887.zip
Bugfix: Added equals() method to ColorExt because the base class only compares the RGB value but not any other value.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@884117 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/java/org/apache/fop/util/ColorUtilTestCase.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java
index 9b905dd42..79cb0d02c 100644
--- a/test/java/org/apache/fop/util/ColorUtilTestCase.java
+++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java
@@ -75,6 +75,13 @@ public class ColorUtilTestCase extends TestCase {
Color col1 = ColorUtil.parseColorString(null, "#ff0000cc");
Color col2 = ColorUtil.parseColorString(null, "#ff0000cc");
assertEquals(col1, col2);
+
+ col1 = ColorUtil.parseColorString(null, "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)");
+ col2 = ColorUtil.parseColorString(null, "cmyk(0.0,0.0,0.0,0.5)");
+ assertEquals(col1, col2);
+
+ col2 = ColorUtil.parseColorString(null, "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.5,0.5,0.5,0.0)");
+ assertFalse(col1.equals(col2));
}
/**
@@ -120,7 +127,7 @@ public class ColorUtilTestCase extends TestCase {
//TODO Anyone know what's going on here?
assertEquals(0, colActual.getBlue());
assertEquals(cs, colActual.getColorSpace());
- float[] comps = colActual.getOriginalColorComponents();
+ float[] comps = colActual.getColorComponents(null);
assertEquals(3, comps.length);
assertEquals(1f, comps[0], 0);
assertEquals(0f, comps[1], 0);
@@ -148,7 +155,7 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(255, colActual.getGreen());
assertEquals(0, colActual.getBlue());
assertEquals(CMYKColorSpace.getInstance(), colActual.getColorSpace());
- float[] comps = colActual.getOriginalColorComponents();
+ float[] comps = colActual.getColorComponents(null);
assertEquals(4, comps.length);
assertEquals(0f, comps[0], 0);
assertEquals(0f, comps[1], 0);
@@ -163,7 +170,7 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(199, colActual.getGreen());
assertEquals(172, colActual.getBlue());
assertEquals(CMYKColorSpace.getInstance(), colActual.getColorSpace());
- comps = colActual.getOriginalColorComponents();
+ comps = colActual.getColorComponents(null);
assertEquals(0.0274f, comps[0], 0.001);
assertEquals(0.2196f, comps[1], 0.001);
assertEquals(0.3216f, comps[2], 0.001);
@@ -177,7 +184,7 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(255, colActual.getGreen());
assertEquals(0, colActual.getBlue());
assertEquals(CMYKColorSpace.getInstance(), colActual.getColorSpace());
- comps = colActual.getOriginalColorComponents();
+ comps = colActual.getColorComponents(null);
assertEquals(4, comps.length);
assertEquals(0f, comps[0], 0);
assertEquals(0f, comps[1], 0);
@@ -185,6 +192,21 @@ public class ColorUtilTestCase extends TestCase {
assertEquals(0f, comps[3], 0);
assertEquals("fop-rgb-icc(1.0,1.0,0.0,#CMYK,,0.0,0.0,1.0,0.0)",
ColorUtil.colorToString(colActual));
+
+ colSpec = "fop-rgb-icc(0.5,0.5,0.5,#CMYK,,0.0,0.0,0.0,0.5)";
+ colActual = (ColorExt)ColorUtil.parseColorString(null, colSpec);
+ assertEquals(127, colActual.getRed());
+ assertEquals(127, colActual.getGreen());
+ assertEquals(127, colActual.getBlue());
+ assertEquals(CMYKColorSpace.getInstance(), colActual.getColorSpace());
+ comps = colActual.getColorComponents(null);
+ assertEquals(4, comps.length);
+ assertEquals(0f, comps[0], 0);
+ assertEquals(0f, comps[1], 0);
+ assertEquals(0f, comps[2], 0);
+ 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));
}
}