aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChris Bowditch <cbowditch@apache.org>2012-01-10 16:14:05 +0000
committerChris Bowditch <cbowditch@apache.org>2012-01-10 16:14:05 +0000
commitfb1489b30e69043c94908c6bd6898d97c697a8b5 (patch)
tree8cb0ecf87d14bb8be77bee5211dd03a905096238 /test
parent0cc4cbb9f06fd9c1d8549fb17f501d24bd7b5976 (diff)
downloadxmlgraphics-fop-fb1489b30e69043c94908c6bd6898d97c697a8b5.tar.gz
xmlgraphics-fop-fb1489b30e69043c94908c6bd6898d97c697a8b5.zip
Bugzilla #50391:
Add support for different flow-name of fo:region-body in FOP Submitted by: Peter Hancock git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1229622 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/java/org/apache/fop/fo/flow/table/AllTests.java34
-rw-r--r--test/java/org/apache/fop/fo/pagination/AllTests.java35
-rw-r--r--test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java95
-rw-r--r--test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java171
-rw-r--r--test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java14
5 files changed, 338 insertions, 11 deletions
diff --git a/test/java/org/apache/fop/fo/flow/table/AllTests.java b/test/java/org/apache/fop/fo/flow/table/AllTests.java
new file mode 100644
index 000000000..5b5c32a18
--- /dev/null
+++ b/test/java/org/apache/fop/fo/flow/table/AllTests.java
@@ -0,0 +1,34 @@
+/*
+ * 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.fo.flow.table;
+
+import org.junit.runners.Suite;
+
+/**
+ * All test to be added in FOTreeTestSuite
+ *
+ */
+@Suite.SuiteClasses({ CollapsedConditionalBorderTestCase.class, IllegalRowSpanTestCase.class,
+ RowGroupBuilderTestCase.class, TableColumnColumnNumberTestCase.class,
+ TooManyColumnsTestCase.class })
+
+public final class AllTests {
+}
+
diff --git a/test/java/org/apache/fop/fo/pagination/AllTests.java b/test/java/org/apache/fop/fo/pagination/AllTests.java
new file mode 100644
index 000000000..a91203251
--- /dev/null
+++ b/test/java/org/apache/fop/fo/pagination/AllTests.java
@@ -0,0 +1,35 @@
+/*
+ * 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.fo.pagination;
+
+import org.junit.runners.Suite;
+import org.junit.runner.RunWith;
+
+/**
+ * All test to be added in FOTreeTestSuite
+ *
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ PageSequenceMasterTestCase.class,
+ RepeatablePageMasterAlternativesTestCase.class})
+
+public final class AllTests {
+
+}
diff --git a/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java b/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
new file mode 100644
index 000000000..23c0522e6
--- /dev/null
+++ b/test/java/org/apache/fop/fo/pagination/PageSequenceMasterTestCase.java
@@ -0,0 +1,95 @@
+/*
+ * 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.fo.pagination;
+
+import static org.junit.Assert.fail;
+
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
+
+import org.junit.Test;
+
+
+/**
+ * Unit Test for PageSequenceMaster
+ *
+ */
+public class PageSequenceMasterTestCase {
+
+ /**
+ * Test that PageProductionException is thrown if the final simple-page-master
+ * cannot handle the main-flow of the page sequence
+ * @throws Exception exception
+ */
+ @Test
+ public void testGetNextSimplePageMasterException() throws Exception {
+
+ final String mainFlowRegionName = "main";
+ final String emptyFlowRegionName = "empty";
+ // Create stubs
+
+ FONode mockParent = mock(FONode.class);
+ Root mockRoot = mock(Root.class);
+ LayoutMasterSet mockLayoutMasterSet = mock(LayoutMasterSet.class);
+
+ // This will represent a page master that does not map to the main flow
+ // of the page sequence
+ SimplePageMaster mockEmptySPM = mock(SimplePageMaster.class);
+ Region mockRegion = mock(Region.class);
+ SinglePageMasterReference mockSinglePageMasterReference
+ = mock(SinglePageMasterReference.class);
+ BlockLevelEventProducer mockBlockLevelEventProducer = mock(BlockLevelEventProducer.class);
+
+ //Stub behaviour
+ when(mockParent.getRoot()).thenReturn(mockRoot);
+ when(mockRoot.getLayoutMasterSet()).thenReturn(mockLayoutMasterSet);
+
+ //The layout master set should return the empty page master
+ when(mockLayoutMasterSet.getSimplePageMaster(anyString())).thenReturn(mockEmptySPM);
+ when(mockEmptySPM.getRegion(anyInt())).thenReturn(mockRegion);
+
+ when(mockRegion.getRegionName()).thenReturn(emptyFlowRegionName);
+
+ when(mockSinglePageMasterReference.getNextPageMaster(anyBoolean(), anyBoolean(),
+ anyBoolean(), anyBoolean()))
+ .thenReturn(null, mockEmptySPM);
+
+ PageSequenceMaster pageSequenceMaster = new PageSequenceMaster(mockParent,
+ mockBlockLevelEventProducer);
+ pageSequenceMaster.startOfNode();
+ pageSequenceMaster.addSubsequenceSpecifier(mockSinglePageMasterReference);
+
+ try {
+ pageSequenceMaster.getNextSimplePageMaster(false, false, false, false,
+ mainFlowRegionName);
+ fail("The next simple page master does not refer to the main flow");
+ } catch (PageProductionException ppe) {
+ //Passed test
+ }
+ }
+
+}
+
diff --git a/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java b/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java
new file mode 100644
index 000000000..d2c5b3f13
--- /dev/null
+++ b/test/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternativesTestCase.java
@@ -0,0 +1,171 @@
+/*
+ * 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.fo.pagination;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.NumericProperty;
+import org.apache.fop.fo.properties.Property;
+
+
+
+/**
+ * Unit Test for RepeatablePageMasterAlternatives
+ *
+ */
+public class RepeatablePageMasterAlternativesTestCase
+implements Constants {
+
+ /**
+ *
+ * @throws Exception exception
+ */
+ @Test
+ public void testIsInfinite1() throws Exception {
+ // Create fixture
+ Property maximumRepeats = mock(Property.class);
+ ConditionalPageMasterReference cpmr = createCPMR("empty");
+
+ when(maximumRepeats.getEnum()).thenReturn(EN_NO_LIMIT);
+
+ RepeatablePageMasterAlternatives objectUnderTest
+ = createRepeatablePageMasterAlternatives(cpmr, maximumRepeats);
+
+ assertTrue("is infinite", objectUnderTest.isInfinite());
+ }
+
+ /**
+ *
+ * @throws Exception exception
+ */
+ @Test
+ public void testIsInfinite2() throws Exception {
+ // Create fixture
+ Property maximumRepeats = mock(Property.class);
+ ConditionalPageMasterReference cpmr = createCPMR("empty");
+
+ NumericProperty numericProperty = mock(NumericProperty.class);
+
+ final int maxRepeatNum = 0;
+ assertTrue(maxRepeatNum != EN_NO_LIMIT);
+
+ when(maximumRepeats.getEnum()).thenReturn(maxRepeatNum);
+ when(maximumRepeats.getNumeric()).thenReturn(numericProperty);
+
+ RepeatablePageMasterAlternatives objectUnderTest
+ = createRepeatablePageMasterAlternatives(createCPMR("empty"),
+ maximumRepeats);
+
+ assertTrue("is infinite", !objectUnderTest.isInfinite());
+ }
+
+ /**
+ * Test that an infinite sequence of empty page masters has
+ * willTerminiate() returning false
+ * @throws Exception exception
+ */
+ @Test
+ public void testCanProcess1() throws Exception {
+ // Create fixture
+ Property maximumRepeats = mock(Property.class);
+ ConditionalPageMasterReference cpmr = createCPMR("empty");
+
+ when(maximumRepeats.getEnum()).thenReturn(EN_NO_LIMIT);
+ when(cpmr.isValid(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()))
+ .thenReturn(true);
+
+ RepeatablePageMasterAlternatives objectUnderTest
+ = createRepeatablePageMasterAlternatives(cpmr, maximumRepeats);
+
+ //Fixture assertion
+ assertTrue("Should be infinite", objectUnderTest.isInfinite());
+
+ //Test assertion
+ assertTrue("Infinite sequences that do not process the main flow will "
+ + " not terminate",
+ !objectUnderTest.canProcess("main-flow"));
+ }
+ /**
+ * Test that a finite sequence of simple page masters has
+ * willTerminate() returning true
+ *
+ * @throws Exception exception
+ */
+ @Test
+ public void testCanProcess2() throws Exception {
+ // Create fixture
+ Property maximumRepeats = mock(Property.class);
+ NumericProperty numericProperty = mock(NumericProperty.class);
+
+ final int maxRepeatNum = 0;
+
+ when(maximumRepeats.getEnum()).thenReturn(maxRepeatNum);
+ when(maximumRepeats.getNumeric()).thenReturn(numericProperty);
+
+ RepeatablePageMasterAlternatives objectUnderTest
+ = createRepeatablePageMasterAlternatives(createCPMR("empty"),
+ maximumRepeats);
+
+ //Fixture assertion
+ assertTrue("Should be finite sequence", !objectUnderTest.isInfinite());
+
+ //Test assertion
+ assertTrue("Finite sequences will terminate",
+ objectUnderTest.canProcess("main-flow"));
+ }
+
+ private ConditionalPageMasterReference createCPMR(String regionName) {
+ ConditionalPageMasterReference cpmr = mock(ConditionalPageMasterReference.class);
+ SimplePageMaster master = mock(SimplePageMaster.class);
+ Region region = mock(Region.class);
+ when(master.getRegion(anyInt())).thenReturn(region);
+ when(region.getRegionName()).thenReturn(regionName);
+ when(cpmr.getMaster()).thenReturn(master);
+
+ return cpmr;
+ }
+
+ private RepeatablePageMasterAlternatives createRepeatablePageMasterAlternatives(
+ ConditionalPageMasterReference cpmr, Property maximumRepeats) throws Exception {
+
+ PropertyList pList = mock(PropertyList.class);
+
+ when(pList.get(anyInt())).thenReturn(maximumRepeats);
+
+ PageSequenceMaster parent = mock(PageSequenceMaster.class);
+
+ RepeatablePageMasterAlternatives sut = new RepeatablePageMasterAlternatives(parent);
+
+ sut.startOfNode();
+ sut.bind(pList);
+ sut.addConditionalPageMasterReference(cpmr);
+ return sut;
+ }
+
+}
+
diff --git a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java
index f128055ac..4a77ca000 100644
--- a/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java
+++ b/test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java
@@ -22,22 +22,14 @@ package org.apache.fop.fotreetest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-import org.apache.fop.fo.flow.table.CollapsedConditionalBorderTestCase;
-import org.apache.fop.fo.flow.table.IllegalRowSpanTestCase;
-import org.apache.fop.fo.flow.table.RowGroupBuilderTestCase;
-import org.apache.fop.fo.flow.table.TableColumnColumnNumberTestCase;
-import org.apache.fop.fo.flow.table.TooManyColumnsTestCase;
-
/**
* JUnit test suit for running layout engine test under JUnit control.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- TooManyColumnsTestCase.class,
- IllegalRowSpanTestCase.class,
- RowGroupBuilderTestCase.class,
- TableColumnColumnNumberTestCase.class,
- CollapsedConditionalBorderTestCase.class,
+ org.apache.fop.fo.flow.table.AllTests.class,
+ org.apache.fop.fo.pagination.AllTests.class,
FOTreeTestCase.class })
+
public final class FOTreeTestSuite {
}