diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2011-03-14 20:46:03 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2011-03-14 20:46:03 +0000 |
commit | 5d664ac15dd06286fa9e221dddc946cf27585deb (patch) | |
tree | 89c167d4e9b18540e959819c932b47862864a84b /test | |
parent | 1aa0218dfaed1eee72e9c254f84579e301aadaef (diff) | |
download | xmlgraphics-fop-5d664ac15dd06286fa9e221dddc946cf27585deb.tar.gz xmlgraphics-fop-5d664ac15dd06286fa9e221dddc946cf27585deb.zip |
Bugzilla #49910: clipping rectangle is wrong on side-regions
Partial fix that works only when the reference-orientation property is set to 0 or 180 on side-regions
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1081554 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
6 files changed, 229 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java index 61a9bdc5e..480ab8bd0 100644 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ b/test/java/org/apache/fop/StandardTestSuite.java @@ -22,6 +22,7 @@ package org.apache.fop; import junit.framework.Test; import junit.framework.TestSuite; +import org.apache.fop.area.ViewportTestSuite; import org.apache.fop.fonts.DejaVuLGCSerifTest; import org.apache.fop.image.loader.batik.ImageLoaderTestCase; import org.apache.fop.image.loader.batik.ImagePreloaderTestCase; @@ -65,6 +66,7 @@ public class StandardTestSuite { suite.addTest(new TestSuite(PageBoundariesTest.class)); suite.addTest(new TestSuite(PageScaleTest.class)); suite.addTest(new TestSuite(MinOptMaxTest.class)); + suite.addTest(ViewportTestSuite.suite()); //$JUnit-END$ return suite; } diff --git a/test/java/org/apache/fop/area/BlockViewportTestCase.java b/test/java/org/apache/fop/area/BlockViewportTestCase.java new file mode 100644 index 000000000..a2a897322 --- /dev/null +++ b/test/java/org/apache/fop/area/BlockViewportTestCase.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.area; + + +/** + * Tests the {@linkplain BlockViewport} class. + */ +public class BlockViewportTestCase extends ViewportTestCase { + + public void testNonClip() throws Exception { + BlockViewport bv = new BlockViewport(); + bv.setIPD(100); + bv.setBPD(50); + checkNonClip(bv); + } + + public void testClip() throws Exception { + BlockViewport bv = new BlockViewport(); + int ipd = 100; + int bpd = 50; + bv.setIPD(ipd); + bv.setBPD(bpd); + bv.setClip(true); + checkClip(bv, ipd, bpd); + } +} diff --git a/test/java/org/apache/fop/area/RegionViewportTestCase.java b/test/java/org/apache/fop/area/RegionViewportTestCase.java new file mode 100644 index 000000000..f55d08b66 --- /dev/null +++ b/test/java/org/apache/fop/area/RegionViewportTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.area; + +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; + +/** + * Tests the {@linkplain RegionViewport} class. + */ +public class RegionViewportTestCase extends ViewportTestCase { + + private RegionViewport createRegionViewport(int x, int y, int ipd, int bpd) { + Rectangle2D v = new Rectangle(x, y, ipd, bpd); + RegionViewport viewport = new RegionViewport(v); + viewport.setIPD(ipd); + viewport.setBPD(bpd); + return viewport; + } + + public void testNonClip() throws Exception { + RegionViewport viewport = createRegionViewport(10, 10, 100, 20); + checkNonClip(viewport); + } + + public void testClip() throws Exception { + int ipd = 150; + int bpd = 20; + RegionViewport viewport = createRegionViewport(10, 10, ipd, bpd); + viewport.setClip(true); + checkClip(viewport, ipd, bpd); + } +} diff --git a/test/java/org/apache/fop/area/ViewportTestCase.java b/test/java/org/apache/fop/area/ViewportTestCase.java new file mode 100644 index 000000000..335ca2f8d --- /dev/null +++ b/test/java/org/apache/fop/area/ViewportTestCase.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.area; + +import java.awt.Rectangle; + +import junit.framework.TestCase; + +/** + * Tests implementations of the {@linkplain Viewport} interface. + */ +public abstract class ViewportTestCase extends TestCase { + + protected void checkNonClip(Viewport v) throws Exception { + assertFalse(v.hasClip()); + assertNull(v.getClipRectangle()); + } + + protected void checkClip(Viewport v, int expectedWidth, int expectedHeight) throws Exception { + assertTrue(v.hasClip()); + assertEquals(new Rectangle(0, 0, expectedWidth, expectedHeight), v.getClipRectangle()); + } +} diff --git a/test/java/org/apache/fop/area/ViewportTestSuite.java b/test/java/org/apache/fop/area/ViewportTestSuite.java new file mode 100644 index 000000000..babbe8910 --- /dev/null +++ b/test/java/org/apache/fop/area/ViewportTestSuite.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.area; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.fop.area.inline.InlineViewportTestCase; + +/** + * A suite of all the tests relating to the {@linkplain Viewport} interface. + */ +public final class ViewportTestSuite { + + private ViewportTestSuite() { } + + /** + * Returns the suite of {@linkplain Viewport} implementation tests. + * + * @return the tests + */ + public static Test suite() { + TestSuite suite = new TestSuite("Tests for viewport-areas"); + suite.addTestSuite(RegionViewportTestCase.class); + suite.addTestSuite(BlockViewportTestCase.class); + suite.addTestSuite(InlineViewportTestCase.class); + return suite; + } + +} diff --git a/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java new file mode 100644 index 000000000..ccd866d64 --- /dev/null +++ b/test/java/org/apache/fop/area/inline/InlineViewportTestCase.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.area.inline; + +import org.apache.fop.area.ViewportTestCase; + +/** + * Tests the {@linkplain Viewport} class. + */ +public class InlineViewportTestCase extends ViewportTestCase { + + public void testNonClip() throws Exception { + Viewport v = new Viewport(null); + v.setIPD(50); + v.setBPD(25); + checkNonClip(v); + } + + public void testClip() throws Exception { + Viewport v = new Viewport(null); + int ipd = 50; + int bpd = 25; + v.setIPD(ipd); + v.setBPD(bpd); + v.setClip(true); + checkClip(v, ipd, bpd); + } + +} |