Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PSTTFOutputStreamTest.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.render.ps.fonts;
  19. import static org.mockito.Mockito.mock;
  20. import static org.mockito.Mockito.verify;
  21. import java.io.IOException;
  22. import junit.framework.TestCase;
  23. import org.apache.fop.fonts.truetype.TTFGlyphOutputStream;
  24. import org.apache.fop.fonts.truetype.TTFTableOutputStream;
  25. import org.apache.xmlgraphics.ps.PSGenerator;
  26. /**
  27. * Tests PSTTFOuputStream
  28. */
  29. public class PSTTFOutputStreamTest extends TestCase {
  30. private PSGenerator gen;
  31. private PSTTFOutputStream out;
  32. /**
  33. * Assigns an OutputStream to the PSGenerator.
  34. */
  35. public void setUp() {
  36. gen = mock(PSGenerator.class);
  37. out = new PSTTFOutputStream(gen);
  38. }
  39. /**
  40. * Test startFontStream() - Just tests that the font is properly initiated in the PostScript
  41. * document (in this case with "/sfnts[")
  42. * @throws IOException write exception.
  43. */
  44. public void testStartFontStream() throws IOException {
  45. out.startFontStream();
  46. verify(gen).write("/sfnts[");
  47. }
  48. /**
  49. * Test getTableOutputStream() - we need to test that the inheritance model is properly obeyed.
  50. */
  51. public void testGetTableOutputStream() {
  52. TTFTableOutputStream tableOut = out.getTableOutputStream();
  53. assertTrue(tableOut instanceof PSTTFTableOutputStream);
  54. }
  55. /**
  56. * Test getGlyphOutputStream() - we need to test that the inheritance model is properly obeyed.
  57. */
  58. public void testGetGlyphOutputStream() {
  59. TTFGlyphOutputStream glyphOut = out.getGlyphOutputStream();
  60. assertTrue(glyphOut instanceof PSTTFGlyphOutputStream);
  61. }
  62. /**
  63. * Test endFontStream()
  64. * @exception IOException write error.
  65. */
  66. public void testEndFontStream() throws IOException {
  67. out.endFontStream();
  68. verify(gen).writeln("] def");
  69. }
  70. }