poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/record TestFontCollection.java
Date Tue, 02 Aug 2005 17:16:46 GMT
nick        2005/08/02 10:16:46

  Added:       src/scratchpad/testcases/org/apache/poi/hslf/record
  Tests for Font support from Yegor, from Bug #35972
  Revision  Changes    Path
  1.1                  jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java
  Index: TestFontCollection.java
  /* ====================================================================
     Copyright 2002-2004   Apache Software Foundation
     Licensed 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
     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.
  ==================================================================== */
  package org.apache.poi.hslf.record;
  import junit.framework.TestCase;
  import java.io.ByteArrayOutputStream;
  import java.util.Arrays;
   * Tests <code>FontCollection</code> and <code>FontEntityAtom</code>
   * @author Yegor Kozlov
  public class TestFontCollection extends TestCase {
      // From a real file
      private byte[] data = new byte[]  {
          0x0F, 0x00, 0xD5-256, 0x07, 0x4C, 0x00, 0x00, 0x00,
          0x00, 0x00, 0xB7-256, 0x0F, 0x44, 0x00, 0x00, 0x00,
          0x54, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x73, 0x00,
          0x20, 0x00, 0x4E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x20, 0x00,
          0x52, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x6E, 0x00,
          0x00, 0x00, 0x74, 0x34, 0xB8-256, 0x00, 0x7C, 0xDA-256, 0x12, 0x00,
          0x64, 0xDA-256, 0x12, 0x00, 0x76, 0xC7-256, 0x0B, 0x30, 0x08, 0x00,
          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xDA-256, 0x12, 0x00,
          0x28, 0xDD-256, 0x0D, 0x30, 0x00, 0x00, 0x04, 0x00  };
      public void testFonts() throws Exception {
          FontCollection fonts = new FontCollection(data, 0, data.length);
          Record[] child = fonts.getChildRecords();
          assertEquals(child.length, 1);
          FontEntityAtom fnt = (FontEntityAtom)child[0];
          assertEquals(fnt.getFontName(), "Times New Roman");
      public void testAddFont() throws Exception {
          FontCollection fonts = new FontCollection(data, 0, data.length);
          int idx = fonts.addFont("Times New Roman");
          assertEquals(idx, 0);
          idx = fonts.addFont("Helvetica");
          assertEquals(idx, 1);
          idx = fonts.addFont("Arial");
          assertEquals(idx, 2);
          idx = fonts.addFont("Arial"); //the font being added twice
          assertEquals(idx, 2);
          //font collection should contain 3 fonts
          Record[] child = fonts.getChildRecords();
          assertEquals(child.length, 3);
      public void testWrite() throws Exception {
          FontCollection fonts = new FontCollection(data, 0, data.length);
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          byte[] recdata = out.toByteArray();
          assertTrue(Arrays.equals(recdata, data));

To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

View raw message