1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestTextObjectBaseRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 0x44, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 38 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 39 0x00, 0x00, 40 }; 41 42 public TestTextObjectBaseRecord(String name) 43 { 44 super(name); 45 } 46 47 public void testLoad() 48 throws Exception 49 { 50 TextObjectBaseRecord record = new TextObjectBaseRecord((short)0x1B6, (short)data.length, data); 51 52 53 assertEquals( false, record.isReserved1() ); 55 assertEquals( TextObjectBaseRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED, record.getHorizontalTextAlignment() ); 56 assertEquals( TextObjectBaseRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY, record.getVerticalTextAlignment() ); 57 assertEquals( 0, record.getReserved2() ); 58 assertEquals( true, record.isTextLocked() ); 59 assertEquals( 0, record.getReserved3() ); 60 assertEquals( TextObjectBaseRecord.TEXT_ORIENTATION_ROT_RIGHT, record.getTextOrientation()); 61 assertEquals( 0, record.getReserved4()); 62 assertEquals( 0, record.getReserved5()); 63 assertEquals( 0, record.getReserved6()); 64 assertEquals( 2, record.getTextLength()); 65 assertEquals( 2, record.getFormattingRunLength()); 66 assertEquals( 0, record.getReserved7()); 67 68 69 assertEquals( 22, record.getRecordSize() ); 70 71 record.validateSid((short)0x1B6); 72 } 73 74 public void testStore() 75 { 76 TextObjectBaseRecord record = new TextObjectBaseRecord(); 77 78 79 80 record.setReserved1( false ); 82 record.setHorizontalTextAlignment( TextObjectBaseRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED ); 83 record.setVerticalTextAlignment( TextObjectBaseRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY ); 84 record.setReserved2( (short)0 ); 85 record.setTextLocked( true ); 86 record.setReserved3( (short)0 ); 87 record.setTextOrientation( TextObjectBaseRecord.TEXT_ORIENTATION_ROT_RIGHT ); 88 record.setReserved4( (short)0 ); 89 record.setReserved5( (short)0 ); 90 record.setReserved6( (short)0 ); 91 record.setTextLength( (short)2 ); 92 record.setFormattingRunLength( (short)2 ); 93 record.setReserved7( 0 ); 94 95 byte [] recordBytes = record.serialize(); 96 assertEquals(recordBytes.length - 4, data.length); 97 for (int i = 0; i < data.length; i++) 98 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 99 } 100 } 101 | Popular Tags |