You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LayoutMasterSetTestCase.java 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fo.pagination;
  19. import org.junit.Test;
  20. import static org.junit.Assert.assertEquals;
  21. import org.apache.fop.apps.FOUserAgent;
  22. import org.apache.fop.fo.FODocumentParser;
  23. import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
  24. import org.apache.fop.fo.FOEventHandler;
  25. public class LayoutMasterSetTestCase {
  26. private static class FlowMappingTester extends FOEventHandler {
  27. private static final String[][] FLOW_MAPPINGS = {
  28. {"first-page-before", "xsl-region-before"},
  29. {"first-page-after", "xsl-region-after"},
  30. {"first-page-start", "xsl-region-start"},
  31. {"first-page-end", "xsl-region-end"},
  32. {"odd-page-before", "xsl-region-before"},
  33. {"odd-page-after", "xsl-region-after"},
  34. {"odd-page-start", "xsl-region-start"},
  35. {"odd-page-end", "xsl-region-end"},
  36. {"odd-page-before", "xsl-region-before"},
  37. {"odd-page-after", "xsl-region-after"},
  38. {"odd-page-start", "xsl-region-start"},
  39. {"odd-page-end", "xsl-region-end"},
  40. {"blank-page-before", "xsl-region-before"},
  41. {"blank-page-after", "xsl-region-after"},
  42. {"blank-page-start", "xsl-region-start"},
  43. {"blank-page-end", "xsl-region-end"},
  44. {"last-page-before", "xsl-region-before"},
  45. {"last-page-after", "xsl-region-after"},
  46. {"last-page-start", "xsl-region-start"},
  47. {"last-page-end", "xsl-region-end"},
  48. {"xsl-footnote-separator", "xsl-footnote-separator"}
  49. };
  50. FlowMappingTester(FOUserAgent userAgent) {
  51. super(userAgent);
  52. }
  53. @Override
  54. public void startPageSequence(PageSequence pageSeq) {
  55. super.startPageSequence(pageSeq);
  56. LayoutMasterSet layoutMasterSet = pageSeq.getRoot().getLayoutMasterSet();
  57. for (String[] mapping : FLOW_MAPPINGS) {
  58. assertEquals(mapping[1], layoutMasterSet.getDefaultRegionNameFor(mapping[0]));
  59. }
  60. }
  61. }
  62. /**
  63. * Tests the {@link LayoutMasterSet#getDefaultRegionNameFor(String)} method.
  64. */
  65. @Test
  66. public void testFlowMapping() throws Exception {
  67. FODocumentParser foDocumentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() {
  68. public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) {
  69. return new FlowMappingTester(foUserAgent);
  70. }
  71. });
  72. foDocumentParser.parse(getClass().getResourceAsStream("side-regions.fo"));
  73. }
  74. }