diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-05-03 07:21:02 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-05-03 07:21:02 +0000 |
commit | 6e9e6775bd5c5d16550ba64b7666eda6ed382d44 (patch) | |
tree | b0ce141fdbd4d4499ea1ed4994fa9c5bb4b46bd2 /test | |
parent | 3fd99265691afe51eeccd10ecf704148eaaca669 (diff) | |
download | xmlgraphics-fop-6e9e6775bd5c5d16550ba64b7666eda6ed382d44.tar.gz xmlgraphics-fop-6e9e6775bd5c5d16550ba64b7666eda6ed382d44.zip |
Bugzilla #38946:
First step for improved color handling. FOP's own ColorType was replaced with java.awt.Color throughout the codebase.
Submitted by: Max Berger <max.at.berger.name>
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@399185 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
4 files changed, 35 insertions, 29 deletions
diff --git a/test/fotree/testcases/properties_omitted_propertyname.fo b/test/fotree/testcases/properties_omitted_propertyname.fo index 77ee13458..b8bba4d7c 100644 --- a/test/fotree/testcases/properties_omitted_propertyname.fo +++ b/test/fotree/testcases/properties_omitted_propertyname.fo @@ -53,8 +53,8 @@ <fo:block background-color="#0000ff"> Top Level Block: font-size="24pt" background-color="#0000ff" <fo:block> - <test:assert property="background-color" expected="#000000"/> - Nested Block: background-color=default + <test:assert property="background-color" expected="#00000000"/> + Nested Block: background-color=default (transparent) <fo:block background-color="from-nearest-specified-value()"> <test:assert property="background-color" expected="#0000ff"/> Nested Block: background-color="from-nearest-specified-value()" diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index 17cbcb22e..8e12c43fd 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -18,11 +18,13 @@ package org.apache.fop.traits; -import org.apache.fop.area.Trait; -import org.apache.fop.fo.Constants; +import java.awt.Color; import junit.framework.TestCase; +import org.apache.fop.fo.Constants; +import org.apache.fop.util.ColorUtil; + /** * Tests the BorderProps class. */ @@ -33,9 +35,9 @@ public class BorderPropsTestCase extends TestCase { * @throws Exception if an error occurs */ public void testSerialization() throws Exception { - Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f); + Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); //Normalize: Avoid false alarms due to color conversion (rounding) - col = Trait.Color.valueOf(col.toString()); + col = ColorUtil.parseColorString(ColorUtil.colorTOsRGBString(col)); BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250, col, BorderProps.COLLAPSE_OUTER); diff --git a/test/java/org/apache/fop/traits/TraitColorTestCase.java b/test/java/org/apache/fop/traits/TraitColorTestCase.java index 4df691f8d..daf012603 100644 --- a/test/java/org/apache/fop/traits/TraitColorTestCase.java +++ b/test/java/org/apache/fop/traits/TraitColorTestCase.java @@ -18,12 +18,15 @@ package org.apache.fop.traits; -import org.apache.fop.area.Trait; +import java.awt.Color; import junit.framework.TestCase; +import org.apache.fop.util.ColorUtil; + /** * Tests the Trait.Color class. + * TODO: This actually tests the ColorUtil class now. */ public class TraitColorTestCase extends TestCase { @@ -32,12 +35,15 @@ public class TraitColorTestCase extends TestCase { * @throws Exception if an error occurs */ public void testSerialization() throws Exception { - Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f); - String s = col.toString(); - assertEquals("#ffff7f", s); + Color col = new Color(1.0f, 1.0f, 0.5f, 1.0f); + String s = ColorUtil.colorTOsRGBString(col); + + //This is what the old color spit out. Now it is 80 due to rounding + //assertEquals("#ffff7f", s); + assertEquals("#ffff80", s); - col = new Trait.Color(1.0f, 0.0f, 0.0f, 0.8f); - s = col.toString(); + col = new Color(1.0f, 0.0f, 0.0f, 0.8f); + s = ColorUtil.colorTOsRGBString(col); assertEquals("#ff0000cc", s); } @@ -46,19 +52,17 @@ public class TraitColorTestCase extends TestCase { * @throws Exception if an error occurs */ public void testDeserialization() throws Exception { - float tolerance = 0.5f / 255; //due to color value conversion - - Trait.Color col = Trait.Color.valueOf("#ffff7f"); - assertEquals(1.0f, col.getRed(), 0.0f); - assertEquals(1.0f, col.getGreen(), 0.0f); - assertEquals(0.5f, col.getBlue(), tolerance); - assertEquals(1.0f, col.getAlpha(), 0.0f); + Color col = ColorUtil.parseColorString("#ffff7f"); + assertEquals(255, col.getRed()); + assertEquals(255, col.getGreen()); + assertEquals(127, col.getBlue()); + assertEquals(255, col.getAlpha()); - col = Trait.Color.valueOf("#ff0000cc"); - assertEquals(1.0f, col.getRed(), 0.0f); - assertEquals(0.0f, col.getGreen(), 0.0f); - assertEquals(0.0f, col.getBlue(), 0.0f); - assertEquals(0.8f, col.getAlpha(), tolerance); + col = ColorUtil.parseColorString("#ff0000cc"); + assertEquals(255, col.getRed()); + assertEquals(0, col.getGreen()); + assertEquals(0, col.getBlue()); + assertEquals(204, col.getAlpha()); } /** @@ -66,8 +70,8 @@ public class TraitColorTestCase extends TestCase { * @throws Exception if an error occurs */ public void testEquals() throws Exception { - Trait.Color col1 = Trait.Color.valueOf("#ff0000cc"); - Trait.Color col2 = Trait.Color.valueOf("#ff0000cc"); + Color col1 = ColorUtil.parseColorString("#ff0000cc"); + Color col2 = ColorUtil.parseColorString("#ff0000cc"); assertTrue(col1 != col2); assertEquals(col1, col2); } diff --git a/test/layoutengine/standard-testcases/region-body_background-image.xml b/test/layoutengine/standard-testcases/region-body_background-image.xml index c5dbcd64a..0038b3c13 100644 --- a/test/layoutengine/standard-testcases/region-body_background-image.xml +++ b/test/layoutengine/standard-testcases/region-body_background-image.xml @@ -44,8 +44,8 @@ </fo:root> </fo> <checks> - <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/> - <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/> - <eval expected="color=null,url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/> + <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=136960,vertical=136960" xpath="//regionViewport/@background"/> + <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=56960" xpath="//flow/block[1]/@background"/> + <eval expected="url=../../resources/images/bgimg300dpi.jpg,repeat=no-repeat,horiz=56960,vertical=-8640" xpath="//flow/block[1]/block[1]/block[1]/@background"/> </checks> </testcase> |