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.

PCLRendererConfiguratorTestCase.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. package org.apache.fop.render.pcl;
  18. import org.junit.Test;
  19. import static org.junit.Assert.assertEquals;
  20. import static org.junit.Assert.assertFalse;
  21. import static org.junit.Assert.assertTrue;
  22. import static org.mockito.Mockito.when;
  23. import org.apache.fop.apps.AbstractRendererConfiguratorTest;
  24. import org.apache.fop.apps.FOPException;
  25. import org.apache.fop.apps.MimeConstants;
  26. import org.apache.fop.render.pcl.PCLRendererConfig.PCLRendererConfigParser;
  27. public class PCLRendererConfiguratorTestCase extends
  28. AbstractRendererConfiguratorTest<PCLRendererConfigurator, PCLRendererConfBuilder> {
  29. private PCLRenderingUtil pclUtil;
  30. public PCLRendererConfiguratorTestCase() {
  31. super(MimeConstants.MIME_PCL, PCLRendererConfBuilder.class, PCLDocumentHandler.class);
  32. }
  33. @Override
  34. public PCLRendererConfigurator createConfigurator() {
  35. return new PCLRendererConfigurator(userAgent, new PCLRendererConfigParser());
  36. }
  37. @Override
  38. public void setUpDocumentHandler() {
  39. pclUtil = new PCLRenderingUtil(userAgent);
  40. when(((PCLDocumentHandler) docHandler).getPCLUtil()).thenReturn(pclUtil);
  41. }
  42. @Test
  43. public void testSetRenderingMode() throws Exception {
  44. parseConfig(createBuilder().setRenderingMode("bitmap"));
  45. assertEquals(PCLRenderingMode.BITMAP, pclUtil.getRenderingMode());
  46. parseConfig(createBuilder().setRenderingMode("quality"));
  47. assertEquals(PCLRenderingMode.QUALITY, pclUtil.getRenderingMode());
  48. parseConfig(createBuilder().setRenderingMode("speed"));
  49. assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode());
  50. parseConfig(createBuilder());
  51. assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode());
  52. }
  53. @Test(expected = FOPException.class)
  54. public void testRenderingModeFailureCase() throws Exception {
  55. parseConfig(createBuilder().setRenderingMode("fail"));
  56. assertEquals(PCLRenderingMode.SPEED, pclUtil.getRenderingMode());
  57. }
  58. @Test
  59. public void testPJLDisabled() throws Exception {
  60. parseConfig(createBuilder().setDisablePjl(true));
  61. assertTrue(pclUtil.isPJLDisabled());
  62. parseConfig(createBuilder().setDisablePjl(false));
  63. assertFalse(pclUtil.isPJLDisabled());
  64. parseConfig(createBuilder());
  65. assertFalse(pclUtil.isPJLDisabled());
  66. }
  67. @Test
  68. public void testSetAllTextAsBitmaps() throws Exception {
  69. parseConfig(createBuilder().setTextRendering("bitmap"));
  70. assertTrue(pclUtil.isAllTextAsBitmaps());
  71. parseConfig(createBuilder().setTextRendering("auto"));
  72. assertFalse(pclUtil.isAllTextAsBitmaps());
  73. parseConfig(createBuilder());
  74. assertFalse(pclUtil.isAllTextAsBitmaps());
  75. }
  76. @Test(expected = FOPException.class)
  77. public void testSetAllTextAsBitmapsFailureCase() throws Exception {
  78. parseConfig(createBuilder().setTextRendering("fail"));
  79. assertFalse(pclUtil.isAllTextAsBitmaps());
  80. }
  81. }